babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640
  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. * Moves the observable to the top of the observer list making it get called first when notified
  4356. * @param observer the observer to move
  4357. */
  4358. makeObserverTopPriority(observer: Observer<T>): void;
  4359. /**
  4360. * Moves the observable to the bottom of the observer list making it get called last when notified
  4361. * @param observer the observer to move
  4362. */
  4363. makeObserverBottomPriority(observer: Observer<T>): void;
  4364. /**
  4365. * Notify all Observers by calling their respective callback with the given data
  4366. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4367. * @param eventData defines the data to send to all observers
  4368. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4369. * @param target defines the original target of the state
  4370. * @param currentTarget defines the current target of the state
  4371. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4372. */
  4373. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4374. /**
  4375. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4376. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4377. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4378. * and it is crucial that all callbacks will be executed.
  4379. * The order of the callbacks is kept, callbacks are not executed parallel.
  4380. *
  4381. * @param eventData The data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. * @param target defines the callback target (see EventState)
  4384. * @param currentTarget defines he current object in the bubbling phase
  4385. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4386. */
  4387. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4388. /**
  4389. * Notify a specific observer
  4390. * @param observer defines the observer to notify
  4391. * @param eventData defines the data to be sent to each callback
  4392. * @param mask is used to filter observers defaults to -1
  4393. */
  4394. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4395. /**
  4396. * Gets a boolean indicating if the observable has at least one observer
  4397. * @returns true is the Observable has at least one Observer registered
  4398. */
  4399. hasObservers(): boolean;
  4400. /**
  4401. * Clear the list of observers
  4402. */
  4403. clear(): void;
  4404. /**
  4405. * Clone the current observable
  4406. * @returns a new observable
  4407. */
  4408. clone(): Observable<T>;
  4409. /**
  4410. * Does this observable handles observer registered with a given mask
  4411. * @param mask defines the mask to be tested
  4412. * @return whether or not one observer registered with the given mask is handeled
  4413. **/
  4414. hasSpecificMask(mask?: number): boolean;
  4415. }
  4416. }
  4417. declare module "babylonjs/Misc/filesInputStore" {
  4418. /**
  4419. * Class used to help managing file picking and drag'n'drop
  4420. * File Storage
  4421. */
  4422. export class FilesInputStore {
  4423. /**
  4424. * List of files ready to be loaded
  4425. */
  4426. static FilesToLoad: {
  4427. [key: string]: File;
  4428. };
  4429. }
  4430. }
  4431. declare module "babylonjs/Engines/constants" {
  4432. /** Defines the cross module used constants to avoid circular dependncies */
  4433. export class Constants {
  4434. /** Defines that alpha blending is disabled */
  4435. static readonly ALPHA_DISABLE: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4437. static readonly ALPHA_ADD: number;
  4438. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_COMBINE: number;
  4440. /** Defines that alpha blending to DEST - SRC * DEST */
  4441. static readonly ALPHA_SUBTRACT: number;
  4442. /** Defines that alpha blending to SRC * DEST */
  4443. static readonly ALPHA_MULTIPLY: number;
  4444. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4445. static readonly ALPHA_MAXIMIZED: number;
  4446. /** Defines that alpha blending to SRC + DEST */
  4447. static readonly ALPHA_ONEONE: number;
  4448. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4449. static readonly ALPHA_PREMULTIPLIED: number;
  4450. /**
  4451. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4452. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4453. */
  4454. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4455. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4456. static readonly ALPHA_INTERPOLATE: number;
  4457. /**
  4458. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4459. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4460. */
  4461. static readonly ALPHA_SCREENMODE: number;
  4462. /** Defines that the ressource is not delayed*/
  4463. static readonly DELAYLOADSTATE_NONE: number;
  4464. /** Defines that the ressource was successfully delay loaded */
  4465. static readonly DELAYLOADSTATE_LOADED: number;
  4466. /** Defines that the ressource is currently delay loading */
  4467. static readonly DELAYLOADSTATE_LOADING: number;
  4468. /** Defines that the ressource is delayed and has not started loading */
  4469. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4471. static readonly NEVER: number;
  4472. /** 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 */
  4473. static readonly ALWAYS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4475. static readonly LESS: number;
  4476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4477. static readonly EQUAL: number;
  4478. /** 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 */
  4479. static readonly LEQUAL: number;
  4480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4481. static readonly GREATER: number;
  4482. /** 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 */
  4483. static readonly GEQUAL: number;
  4484. /** 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 */
  4485. static readonly NOTEQUAL: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be kept */
  4487. static readonly KEEP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4489. static readonly REPLACE: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4491. static readonly INCR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4493. static readonly DECR: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4495. static readonly INVERT: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4497. static readonly INCR_WRAP: number;
  4498. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4499. static readonly DECR_WRAP: number;
  4500. /** Texture is not repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4502. /** Texture is repeating outside of 0..1 UVs */
  4503. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4504. /** Texture is repeating and mirrored */
  4505. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4506. /** ALPHA */
  4507. static readonly TEXTUREFORMAT_ALPHA: number;
  4508. /** LUMINANCE */
  4509. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4510. /** LUMINANCE_ALPHA */
  4511. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4512. /** RGB */
  4513. static readonly TEXTUREFORMAT_RGB: number;
  4514. /** RGBA */
  4515. static readonly TEXTUREFORMAT_RGBA: number;
  4516. /** RED */
  4517. static readonly TEXTUREFORMAT_RED: number;
  4518. /** RED (2nd reference) */
  4519. static readonly TEXTUREFORMAT_R: number;
  4520. /** RG */
  4521. static readonly TEXTUREFORMAT_RG: number;
  4522. /** RED_INTEGER */
  4523. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4524. /** RED_INTEGER (2nd reference) */
  4525. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4526. /** RG_INTEGER */
  4527. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4528. /** RGB_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4530. /** RGBA_INTEGER */
  4531. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4532. /** UNSIGNED_BYTE */
  4533. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4534. /** UNSIGNED_BYTE (2nd reference) */
  4535. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4536. /** FLOAT */
  4537. static readonly TEXTURETYPE_FLOAT: number;
  4538. /** HALF_FLOAT */
  4539. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4540. /** BYTE */
  4541. static readonly TEXTURETYPE_BYTE: number;
  4542. /** SHORT */
  4543. static readonly TEXTURETYPE_SHORT: number;
  4544. /** UNSIGNED_SHORT */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4546. /** INT */
  4547. static readonly TEXTURETYPE_INT: number;
  4548. /** UNSIGNED_INT */
  4549. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4550. /** UNSIGNED_SHORT_4_4_4_4 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4552. /** UNSIGNED_SHORT_5_5_5_1 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4554. /** UNSIGNED_SHORT_5_6_5 */
  4555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4556. /** UNSIGNED_INT_2_10_10_10_REV */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4558. /** UNSIGNED_INT_24_8 */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4560. /** UNSIGNED_INT_10F_11F_11F_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4562. /** UNSIGNED_INT_5_9_9_9_REV */
  4563. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4564. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4565. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4566. /** nearest is mag = nearest and min = nearest and mip = linear */
  4567. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4568. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4569. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4570. /** Trilinear is mag = linear and min = linear and mip = linear */
  4571. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4572. /** nearest is mag = nearest and min = nearest and mip = linear */
  4573. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4574. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4576. /** Trilinear is mag = linear and min = linear and mip = linear */
  4577. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4578. /** mag = nearest and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = nearest */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4582. /** mag = nearest and min = linear and mip = linear */
  4583. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4584. /** mag = nearest and min = linear and mip = none */
  4585. static readonly TEXTURE_NEAREST_LINEAR: number;
  4586. /** mag = nearest and min = nearest and mip = none */
  4587. static readonly TEXTURE_NEAREST_NEAREST: number;
  4588. /** mag = linear and min = nearest and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4590. /** mag = linear and min = nearest and mip = linear */
  4591. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4592. /** mag = linear and min = linear and mip = none */
  4593. static readonly TEXTURE_LINEAR_LINEAR: number;
  4594. /** mag = linear and min = nearest and mip = none */
  4595. static readonly TEXTURE_LINEAR_NEAREST: number;
  4596. /** Explicit coordinates mode */
  4597. static readonly TEXTURE_EXPLICIT_MODE: number;
  4598. /** Spherical coordinates mode */
  4599. static readonly TEXTURE_SPHERICAL_MODE: number;
  4600. /** Planar coordinates mode */
  4601. static readonly TEXTURE_PLANAR_MODE: number;
  4602. /** Cubic coordinates mode */
  4603. static readonly TEXTURE_CUBIC_MODE: number;
  4604. /** Projection coordinates mode */
  4605. static readonly TEXTURE_PROJECTION_MODE: number;
  4606. /** Skybox coordinates mode */
  4607. static readonly TEXTURE_SKYBOX_MODE: number;
  4608. /** Inverse Cubic coordinates mode */
  4609. static readonly TEXTURE_INVCUBIC_MODE: number;
  4610. /** Equirectangular coordinates mode */
  4611. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4614. /** Equirectangular Fixed Mirrored coordinates mode */
  4615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4616. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4617. static readonly SCALEMODE_FLOOR: number;
  4618. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4619. static readonly SCALEMODE_NEAREST: number;
  4620. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4621. static readonly SCALEMODE_CEILING: number;
  4622. /**
  4623. * The dirty texture flag value
  4624. */
  4625. static readonly MATERIAL_TextureDirtyFlag: number;
  4626. /**
  4627. * The dirty light flag value
  4628. */
  4629. static readonly MATERIAL_LightDirtyFlag: number;
  4630. /**
  4631. * The dirty fresnel flag value
  4632. */
  4633. static readonly MATERIAL_FresnelDirtyFlag: number;
  4634. /**
  4635. * The dirty attribute flag value
  4636. */
  4637. static readonly MATERIAL_AttributesDirtyFlag: number;
  4638. /**
  4639. * The dirty misc flag value
  4640. */
  4641. static readonly MATERIAL_MiscDirtyFlag: number;
  4642. /**
  4643. * The all dirty flag value
  4644. */
  4645. static readonly MATERIAL_AllDirtyFlag: number;
  4646. /**
  4647. * Returns the triangle fill mode
  4648. */
  4649. static readonly MATERIAL_TriangleFillMode: number;
  4650. /**
  4651. * Returns the wireframe mode
  4652. */
  4653. static readonly MATERIAL_WireFrameFillMode: number;
  4654. /**
  4655. * Returns the point fill mode
  4656. */
  4657. static readonly MATERIAL_PointFillMode: number;
  4658. /**
  4659. * Returns the point list draw mode
  4660. */
  4661. static readonly MATERIAL_PointListDrawMode: number;
  4662. /**
  4663. * Returns the line list draw mode
  4664. */
  4665. static readonly MATERIAL_LineListDrawMode: number;
  4666. /**
  4667. * Returns the line loop draw mode
  4668. */
  4669. static readonly MATERIAL_LineLoopDrawMode: number;
  4670. /**
  4671. * Returns the line strip draw mode
  4672. */
  4673. static readonly MATERIAL_LineStripDrawMode: number;
  4674. /**
  4675. * Returns the triangle strip draw mode
  4676. */
  4677. static readonly MATERIAL_TriangleStripDrawMode: number;
  4678. /**
  4679. * Returns the triangle fan draw mode
  4680. */
  4681. static readonly MATERIAL_TriangleFanDrawMode: number;
  4682. /**
  4683. * Stores the clock-wise side orientation
  4684. */
  4685. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4686. /**
  4687. * Stores the counter clock-wise side orientation
  4688. */
  4689. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4690. /**
  4691. * Nothing
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_NothingTrigger: number;
  4695. /**
  4696. * On pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnPickTrigger: number;
  4700. /**
  4701. * On left pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnLeftPickTrigger: number;
  4705. /**
  4706. * On right pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnRightPickTrigger: number;
  4710. /**
  4711. * On center pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnCenterPickTrigger: number;
  4715. /**
  4716. * On pick down
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickDownTrigger: number;
  4720. /**
  4721. * On double pick
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnDoublePickTrigger: number;
  4725. /**
  4726. * On pick up
  4727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4728. */
  4729. static readonly ACTION_OnPickUpTrigger: number;
  4730. /**
  4731. * On pick out.
  4732. * This trigger will only be raised if you also declared a OnPickDown
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPickOutTrigger: number;
  4736. /**
  4737. * On long press
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnLongPressTrigger: number;
  4741. /**
  4742. * On pointer over
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnPointerOverTrigger: number;
  4746. /**
  4747. * On pointer out
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnPointerOutTrigger: number;
  4751. /**
  4752. * On every frame
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnEveryFrameTrigger: number;
  4756. /**
  4757. * On intersection enter
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4761. /**
  4762. * On intersection exit
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnIntersectionExitTrigger: number;
  4766. /**
  4767. * On key down
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnKeyDownTrigger: number;
  4771. /**
  4772. * On key up
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnKeyUpTrigger: number;
  4776. /**
  4777. * Billboard mode will only apply to Y axis
  4778. */
  4779. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4780. /**
  4781. * Billboard mode will apply to all axes
  4782. */
  4783. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4784. /**
  4785. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4786. */
  4787. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4788. /**
  4789. * Gets or sets base Assets URL
  4790. */
  4791. static readonly PARTICLES_BaseAssetsUrl: string;
  4792. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4793. * Test order :
  4794. * Is the bounding sphere outside the frustum ?
  4795. * If not, are the bounding box vertices outside the frustum ?
  4796. * It not, then the cullable object is in the frustum.
  4797. */
  4798. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4799. /** Culling strategy : Bounding Sphere Only.
  4800. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4801. * It's also less accurate than the standard because some not visible objects can still be selected.
  4802. * Test : is the bounding sphere outside the frustum ?
  4803. * If not, then the cullable object is in the frustum.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4806. /** Culling strategy : Optimistic Inclusion.
  4807. * This in an inclusion test first, then the standard exclusion test.
  4808. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * Anyway, it's as accurate as the standard strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the default culling strategy.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4816. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4817. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4818. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4819. * 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.
  4820. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4821. * Test :
  4822. * Is the cullable object bounding sphere center in the frustum ?
  4823. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4824. */
  4825. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4826. /**
  4827. * No logging while loading
  4828. */
  4829. static readonly SCENELOADER_NO_LOGGING: number;
  4830. /**
  4831. * Minimal logging while loading
  4832. */
  4833. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4834. /**
  4835. * Summary logging while loading
  4836. */
  4837. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4838. /**
  4839. * Detailled logging while loading
  4840. */
  4841. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4842. }
  4843. }
  4844. declare module "babylonjs/Misc/domManagement" {
  4845. /**
  4846. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4847. * Babylon.js
  4848. */
  4849. export class DomManagement {
  4850. /**
  4851. * Checks if the window object exists
  4852. * @returns true if the window object exists
  4853. */
  4854. static IsWindowObjectExist(): boolean;
  4855. /**
  4856. * Extracts text content from a DOM element hierarchy
  4857. * @param element defines the root element
  4858. * @returns a string
  4859. */
  4860. static GetDOMTextContent(element: HTMLElement): string;
  4861. }
  4862. }
  4863. declare module "babylonjs/Misc/logger" {
  4864. /**
  4865. * Logger used througouht the application to allow configuration of
  4866. * the log level required for the messages.
  4867. */
  4868. export class Logger {
  4869. /**
  4870. * No log
  4871. */
  4872. static readonly NoneLogLevel: number;
  4873. /**
  4874. * Only message logs
  4875. */
  4876. static readonly MessageLogLevel: number;
  4877. /**
  4878. * Only warning logs
  4879. */
  4880. static readonly WarningLogLevel: number;
  4881. /**
  4882. * Only error logs
  4883. */
  4884. static readonly ErrorLogLevel: number;
  4885. /**
  4886. * All logs
  4887. */
  4888. static readonly AllLogLevel: number;
  4889. private static _LogCache;
  4890. /**
  4891. * Gets a value indicating the number of loading errors
  4892. * @ignorenaming
  4893. */
  4894. static errorsCount: number;
  4895. /**
  4896. * Callback called when a new log is added
  4897. */
  4898. static OnNewCacheEntry: (entry: string) => void;
  4899. private static _AddLogEntry;
  4900. private static _FormatMessage;
  4901. private static _LogDisabled;
  4902. private static _LogEnabled;
  4903. private static _WarnDisabled;
  4904. private static _WarnEnabled;
  4905. private static _ErrorDisabled;
  4906. private static _ErrorEnabled;
  4907. /**
  4908. * Log a message to the console
  4909. */
  4910. static Log: (message: string) => void;
  4911. /**
  4912. * Write a warning message to the console
  4913. */
  4914. static Warn: (message: string) => void;
  4915. /**
  4916. * Write an error message to the console
  4917. */
  4918. static Error: (message: string) => void;
  4919. /**
  4920. * Gets current log cache (list of logs)
  4921. */
  4922. static readonly LogCache: string;
  4923. /**
  4924. * Clears the log cache
  4925. */
  4926. static ClearLogCache(): void;
  4927. /**
  4928. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4929. */
  4930. static LogLevels: number;
  4931. }
  4932. }
  4933. declare module "babylonjs/Misc/typeStore" {
  4934. /** @hidden */
  4935. export class _TypeStore {
  4936. /** @hidden */
  4937. static RegisteredTypes: {
  4938. [key: string]: Object;
  4939. };
  4940. /** @hidden */
  4941. static GetClass(fqdn: string): any;
  4942. }
  4943. }
  4944. declare module "babylonjs/Misc/deepCopier" {
  4945. /**
  4946. * Class containing a set of static utilities functions for deep copy.
  4947. */
  4948. export class DeepCopier {
  4949. /**
  4950. * Tries to copy an object by duplicating every property
  4951. * @param source defines the source object
  4952. * @param destination defines the target object
  4953. * @param doNotCopyList defines a list of properties to avoid
  4954. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4955. */
  4956. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4957. }
  4958. }
  4959. declare module "babylonjs/Misc/precisionDate" {
  4960. /**
  4961. * Class containing a set of static utilities functions for precision date
  4962. */
  4963. export class PrecisionDate {
  4964. /**
  4965. * Gets either window.performance.now() if supported or Date.now() else
  4966. */
  4967. static readonly Now: number;
  4968. }
  4969. }
  4970. declare module "babylonjs/Misc/devTools" {
  4971. /** @hidden */
  4972. export class _DevTools {
  4973. static WarnImport(name: string): string;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/webRequest" {
  4977. /**
  4978. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4979. */
  4980. export class WebRequest {
  4981. private _xhr;
  4982. /**
  4983. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4984. * i.e. when loading files, where the server/service expects an Authorization header
  4985. */
  4986. static CustomRequestHeaders: {
  4987. [key: string]: string;
  4988. };
  4989. /**
  4990. * Add callback functions in this array to update all the requests before they get sent to the network
  4991. */
  4992. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4993. private _injectCustomRequestHeaders;
  4994. /**
  4995. * Gets or sets a function to be called when loading progress changes
  4996. */
  4997. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4998. /**
  4999. * Returns client's state
  5000. */
  5001. readonly readyState: number;
  5002. /**
  5003. * Returns client's status
  5004. */
  5005. readonly status: number;
  5006. /**
  5007. * Returns client's status as a text
  5008. */
  5009. readonly statusText: string;
  5010. /**
  5011. * Returns client's response
  5012. */
  5013. readonly response: any;
  5014. /**
  5015. * Returns client's response url
  5016. */
  5017. readonly responseURL: string;
  5018. /**
  5019. * Returns client's response as text
  5020. */
  5021. readonly responseText: string;
  5022. /**
  5023. * Gets or sets the expected response type
  5024. */
  5025. responseType: XMLHttpRequestResponseType;
  5026. /** @hidden */
  5027. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5028. /** @hidden */
  5029. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5030. /**
  5031. * Cancels any network activity
  5032. */
  5033. abort(): void;
  5034. /**
  5035. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5036. * @param body defines an optional request body
  5037. */
  5038. send(body?: Document | BodyInit | null): void;
  5039. /**
  5040. * Sets the request method, request URL
  5041. * @param method defines the method to use (GET, POST, etc..)
  5042. * @param url defines the url to connect with
  5043. */
  5044. open(method: string, url: string): void;
  5045. }
  5046. }
  5047. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5048. /**
  5049. * Class used to evalaute queries containing `and` and `or` operators
  5050. */
  5051. export class AndOrNotEvaluator {
  5052. /**
  5053. * Evaluate a query
  5054. * @param query defines the query to evaluate
  5055. * @param evaluateCallback defines the callback used to filter result
  5056. * @returns true if the query matches
  5057. */
  5058. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5059. private static _HandleParenthesisContent;
  5060. private static _SimplifyNegation;
  5061. }
  5062. }
  5063. declare module "babylonjs/Misc/tags" {
  5064. /**
  5065. * Class used to store custom tags
  5066. */
  5067. export class Tags {
  5068. /**
  5069. * Adds support for tags on the given object
  5070. * @param obj defines the object to use
  5071. */
  5072. static EnableFor(obj: any): void;
  5073. /**
  5074. * Removes tags support
  5075. * @param obj defines the object to use
  5076. */
  5077. static DisableFor(obj: any): void;
  5078. /**
  5079. * Gets a boolean indicating if the given object has tags
  5080. * @param obj defines the object to use
  5081. * @returns a boolean
  5082. */
  5083. static HasTags(obj: any): boolean;
  5084. /**
  5085. * Gets the tags available on a given object
  5086. * @param obj defines the object to use
  5087. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5088. * @returns the tags
  5089. */
  5090. static GetTags(obj: any, asString?: boolean): any;
  5091. /**
  5092. * Adds tags to an object
  5093. * @param obj defines the object to use
  5094. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5095. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5096. */
  5097. static AddTagsTo(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _AddTagTo(obj: any, tag: string): void;
  5102. /**
  5103. * Removes specific tags from a specific object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tags to remove
  5106. */
  5107. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5108. /**
  5109. * @hidden
  5110. */
  5111. static _RemoveTagFrom(obj: any, tag: string): void;
  5112. /**
  5113. * Defines if tags hosted on an object match a given query
  5114. * @param obj defines the object to use
  5115. * @param tagsQuery defines the tag query
  5116. * @returns a boolean
  5117. */
  5118. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5119. }
  5120. }
  5121. declare module "babylonjs/Materials/materialDefines" {
  5122. /**
  5123. * Manages the defines for the Material
  5124. */
  5125. export class MaterialDefines {
  5126. private _keys;
  5127. private _isDirty;
  5128. /** @hidden */
  5129. _renderId: number;
  5130. /** @hidden */
  5131. _areLightsDirty: boolean;
  5132. /** @hidden */
  5133. _areAttributesDirty: boolean;
  5134. /** @hidden */
  5135. _areTexturesDirty: boolean;
  5136. /** @hidden */
  5137. _areFresnelDirty: boolean;
  5138. /** @hidden */
  5139. _areMiscDirty: boolean;
  5140. /** @hidden */
  5141. _areImageProcessingDirty: boolean;
  5142. /** @hidden */
  5143. _normals: boolean;
  5144. /** @hidden */
  5145. _uvs: boolean;
  5146. /** @hidden */
  5147. _needNormals: boolean;
  5148. /** @hidden */
  5149. _needUVs: boolean;
  5150. /**
  5151. * Specifies if the material needs to be re-calculated
  5152. */
  5153. readonly isDirty: boolean;
  5154. /**
  5155. * Marks the material to indicate that it has been re-calculated
  5156. */
  5157. markAsProcessed(): void;
  5158. /**
  5159. * Marks the material to indicate that it needs to be re-calculated
  5160. */
  5161. markAsUnprocessed(): void;
  5162. /**
  5163. * Marks the material to indicate all of its defines need to be re-calculated
  5164. */
  5165. markAllAsDirty(): void;
  5166. /**
  5167. * Marks the material to indicate that image processing needs to be re-calculated
  5168. */
  5169. markAsImageProcessingDirty(): void;
  5170. /**
  5171. * Marks the material to indicate the lights need to be re-calculated
  5172. */
  5173. markAsLightDirty(): void;
  5174. /**
  5175. * Marks the attribute state as changed
  5176. */
  5177. markAsAttributesDirty(): void;
  5178. /**
  5179. * Marks the texture state as changed
  5180. */
  5181. markAsTexturesDirty(): void;
  5182. /**
  5183. * Marks the fresnel state as changed
  5184. */
  5185. markAsFresnelDirty(): void;
  5186. /**
  5187. * Marks the misc state as changed
  5188. */
  5189. markAsMiscDirty(): void;
  5190. /**
  5191. * Rebuilds the material defines
  5192. */
  5193. rebuild(): void;
  5194. /**
  5195. * Specifies if two material defines are equal
  5196. * @param other - A material define instance to compare to
  5197. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5198. */
  5199. isEqual(other: MaterialDefines): boolean;
  5200. /**
  5201. * Clones this instance's defines to another instance
  5202. * @param other - material defines to clone values to
  5203. */
  5204. cloneTo(other: MaterialDefines): void;
  5205. /**
  5206. * Resets the material define values
  5207. */
  5208. reset(): void;
  5209. /**
  5210. * Converts the material define values to a string
  5211. * @returns - String of material define information
  5212. */
  5213. toString(): string;
  5214. }
  5215. }
  5216. declare module "babylonjs/Misc/performanceMonitor" {
  5217. /**
  5218. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5219. */
  5220. export class PerformanceMonitor {
  5221. private _enabled;
  5222. private _rollingFrameTime;
  5223. private _lastFrameTimeMs;
  5224. /**
  5225. * constructor
  5226. * @param frameSampleSize The number of samples required to saturate the sliding window
  5227. */
  5228. constructor(frameSampleSize?: number);
  5229. /**
  5230. * Samples current frame
  5231. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5232. */
  5233. sampleFrame(timeMs?: number): void;
  5234. /**
  5235. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5236. */
  5237. readonly averageFrameTime: number;
  5238. /**
  5239. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5240. */
  5241. readonly averageFrameTimeVariance: number;
  5242. /**
  5243. * Returns the frame time of the most recent frame
  5244. */
  5245. readonly instantaneousFrameTime: number;
  5246. /**
  5247. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5248. */
  5249. readonly averageFPS: number;
  5250. /**
  5251. * Returns the average framerate in frames per second using the most recent frame time
  5252. */
  5253. readonly instantaneousFPS: number;
  5254. /**
  5255. * Returns true if enough samples have been taken to completely fill the sliding window
  5256. */
  5257. readonly isSaturated: boolean;
  5258. /**
  5259. * Enables contributions to the sliding window sample set
  5260. */
  5261. enable(): void;
  5262. /**
  5263. * Disables contributions to the sliding window sample set
  5264. * Samples will not be interpolated over the disabled period
  5265. */
  5266. disable(): void;
  5267. /**
  5268. * Returns true if sampling is enabled
  5269. */
  5270. readonly isEnabled: boolean;
  5271. /**
  5272. * Resets performance monitor
  5273. */
  5274. reset(): void;
  5275. }
  5276. /**
  5277. * RollingAverage
  5278. *
  5279. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5280. */
  5281. export class RollingAverage {
  5282. /**
  5283. * Current average
  5284. */
  5285. average: number;
  5286. /**
  5287. * Current variance
  5288. */
  5289. variance: number;
  5290. protected _samples: Array<number>;
  5291. protected _sampleCount: number;
  5292. protected _pos: number;
  5293. protected _m2: number;
  5294. /**
  5295. * constructor
  5296. * @param length The number of samples required to saturate the sliding window
  5297. */
  5298. constructor(length: number);
  5299. /**
  5300. * Adds a sample to the sample set
  5301. * @param v The sample value
  5302. */
  5303. add(v: number): void;
  5304. /**
  5305. * Returns previously added values or null if outside of history or outside the sliding window domain
  5306. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5307. * @return Value previously recorded with add() or null if outside of range
  5308. */
  5309. history(i: number): number;
  5310. /**
  5311. * Returns true if enough samples have been taken to completely fill the sliding window
  5312. * @return true if sample-set saturated
  5313. */
  5314. isSaturated(): boolean;
  5315. /**
  5316. * Resets the rolling average (equivalent to 0 samples taken so far)
  5317. */
  5318. reset(): void;
  5319. /**
  5320. * Wraps a value around the sample range boundaries
  5321. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5322. * @return Wrapped position in sample range
  5323. */
  5324. protected _wrapPosition(i: number): number;
  5325. }
  5326. }
  5327. declare module "babylonjs/Misc/stringDictionary" {
  5328. import { Nullable } from "babylonjs/types";
  5329. /**
  5330. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5331. * The underlying implementation relies on an associative array to ensure the best performances.
  5332. * The value can be anything including 'null' but except 'undefined'
  5333. */
  5334. export class StringDictionary<T> {
  5335. /**
  5336. * This will clear this dictionary and copy the content from the 'source' one.
  5337. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5338. * @param source the dictionary to take the content from and copy to this dictionary
  5339. */
  5340. copyFrom(source: StringDictionary<T>): void;
  5341. /**
  5342. * Get a value based from its key
  5343. * @param key the given key to get the matching value from
  5344. * @return the value if found, otherwise undefined is returned
  5345. */
  5346. get(key: string): T | undefined;
  5347. /**
  5348. * Get a value from its key or add it if it doesn't exist.
  5349. * This method will ensure you that a given key/data will be present in the dictionary.
  5350. * @param key the given key to get the matching value from
  5351. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5352. * The factory will only be invoked if there's no data for the given key.
  5353. * @return the value corresponding to the key.
  5354. */
  5355. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5356. /**
  5357. * Get a value from its key if present in the dictionary otherwise add it
  5358. * @param key the key to get the value from
  5359. * @param val if there's no such key/value pair in the dictionary add it with this value
  5360. * @return the value corresponding to the key
  5361. */
  5362. getOrAdd(key: string, val: T): T;
  5363. /**
  5364. * Check if there's a given key in the dictionary
  5365. * @param key the key to check for
  5366. * @return true if the key is present, false otherwise
  5367. */
  5368. contains(key: string): boolean;
  5369. /**
  5370. * Add a new key and its corresponding value
  5371. * @param key the key to add
  5372. * @param value the value corresponding to the key
  5373. * @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
  5374. */
  5375. add(key: string, value: T): boolean;
  5376. /**
  5377. * Update a specific value associated to a key
  5378. * @param key defines the key to use
  5379. * @param value defines the value to store
  5380. * @returns true if the value was updated (or false if the key was not found)
  5381. */
  5382. set(key: string, value: T): boolean;
  5383. /**
  5384. * Get the element of the given key and remove it from the dictionary
  5385. * @param key defines the key to search
  5386. * @returns the value associated with the key or null if not found
  5387. */
  5388. getAndRemove(key: string): Nullable<T>;
  5389. /**
  5390. * Remove a key/value from the dictionary.
  5391. * @param key the key to remove
  5392. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5393. */
  5394. remove(key: string): boolean;
  5395. /**
  5396. * Clear the whole content of the dictionary
  5397. */
  5398. clear(): void;
  5399. /**
  5400. * Gets the current count
  5401. */
  5402. readonly count: number;
  5403. /**
  5404. * Execute a callback on each key/val of the dictionary.
  5405. * Note that you can remove any element in this dictionary in the callback implementation
  5406. * @param callback the callback to execute on a given key/value pair
  5407. */
  5408. forEach(callback: (key: string, val: T) => void): void;
  5409. /**
  5410. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5411. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5412. * Note that you can remove any element in this dictionary in the callback implementation
  5413. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5414. * @returns the first item
  5415. */
  5416. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5417. private _count;
  5418. private _data;
  5419. }
  5420. }
  5421. declare module "babylonjs/Misc/promise" {
  5422. /**
  5423. * Helper class that provides a small promise polyfill
  5424. */
  5425. export class PromisePolyfill {
  5426. /**
  5427. * Static function used to check if the polyfill is required
  5428. * If this is the case then the function will inject the polyfill to window.Promise
  5429. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5430. */
  5431. static Apply(force?: boolean): void;
  5432. }
  5433. }
  5434. declare module "babylonjs/Meshes/buffer" {
  5435. import { Nullable, DataArray } from "babylonjs/types";
  5436. /**
  5437. * Class used to store data that will be store in GPU memory
  5438. */
  5439. export class Buffer {
  5440. private _engine;
  5441. private _buffer;
  5442. /** @hidden */
  5443. _data: Nullable<DataArray>;
  5444. private _updatable;
  5445. private _instanced;
  5446. /**
  5447. * Gets the byte stride.
  5448. */
  5449. readonly byteStride: number;
  5450. /**
  5451. * Constructor
  5452. * @param engine the engine
  5453. * @param data the data to use for this buffer
  5454. * @param updatable whether the data is updatable
  5455. * @param stride the stride (optional)
  5456. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5457. * @param instanced whether the buffer is instanced (optional)
  5458. * @param useBytes set to true if the stride in in bytes (optional)
  5459. */
  5460. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5461. /**
  5462. * Create a new VertexBuffer based on the current buffer
  5463. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5464. * @param offset defines offset in the buffer (0 by default)
  5465. * @param size defines the size in floats of attributes (position is 3 for instance)
  5466. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5467. * @param instanced defines if the vertex buffer contains indexed data
  5468. * @param useBytes defines if the offset and stride are in bytes
  5469. * @returns the new vertex buffer
  5470. */
  5471. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5472. /**
  5473. * Gets a boolean indicating if the Buffer is updatable?
  5474. * @returns true if the buffer is updatable
  5475. */
  5476. isUpdatable(): boolean;
  5477. /**
  5478. * Gets current buffer's data
  5479. * @returns a DataArray or null
  5480. */
  5481. getData(): Nullable<DataArray>;
  5482. /**
  5483. * Gets underlying native buffer
  5484. * @returns underlying native buffer
  5485. */
  5486. getBuffer(): Nullable<WebGLBuffer>;
  5487. /**
  5488. * Gets the stride in float32 units (i.e. byte stride / 4).
  5489. * May not be an integer if the byte stride is not divisible by 4.
  5490. * DEPRECATED. Use byteStride instead.
  5491. * @returns the stride in float32 units
  5492. */
  5493. getStrideSize(): number;
  5494. /**
  5495. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5496. * @param data defines the data to store
  5497. */
  5498. create(data?: Nullable<DataArray>): void;
  5499. /** @hidden */
  5500. _rebuild(): void;
  5501. /**
  5502. * Update current buffer data
  5503. * @param data defines the data to store
  5504. */
  5505. update(data: DataArray): void;
  5506. /**
  5507. * Updates the data directly.
  5508. * @param data the new data
  5509. * @param offset the new offset
  5510. * @param vertexCount the vertex count (optional)
  5511. * @param useBytes set to true if the offset is in bytes
  5512. */
  5513. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5514. /**
  5515. * Release all resources
  5516. */
  5517. dispose(): void;
  5518. }
  5519. /**
  5520. * Specialized buffer used to store vertex data
  5521. */
  5522. export class VertexBuffer {
  5523. /** @hidden */
  5524. _buffer: Buffer;
  5525. private _kind;
  5526. private _size;
  5527. private _ownsBuffer;
  5528. private _instanced;
  5529. private _instanceDivisor;
  5530. /**
  5531. * The byte type.
  5532. */
  5533. static readonly BYTE: number;
  5534. /**
  5535. * The unsigned byte type.
  5536. */
  5537. static readonly UNSIGNED_BYTE: number;
  5538. /**
  5539. * The short type.
  5540. */
  5541. static readonly SHORT: number;
  5542. /**
  5543. * The unsigned short type.
  5544. */
  5545. static readonly UNSIGNED_SHORT: number;
  5546. /**
  5547. * The integer type.
  5548. */
  5549. static readonly INT: number;
  5550. /**
  5551. * The unsigned integer type.
  5552. */
  5553. static readonly UNSIGNED_INT: number;
  5554. /**
  5555. * The float type.
  5556. */
  5557. static readonly FLOAT: number;
  5558. /**
  5559. * Gets or sets the instance divisor when in instanced mode
  5560. */
  5561. instanceDivisor: number;
  5562. /**
  5563. * Gets the byte stride.
  5564. */
  5565. readonly byteStride: number;
  5566. /**
  5567. * Gets the byte offset.
  5568. */
  5569. readonly byteOffset: number;
  5570. /**
  5571. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5572. */
  5573. readonly normalized: boolean;
  5574. /**
  5575. * Gets the data type of each component in the array.
  5576. */
  5577. readonly type: number;
  5578. /**
  5579. * Constructor
  5580. * @param engine the engine
  5581. * @param data the data to use for this vertex buffer
  5582. * @param kind the vertex buffer kind
  5583. * @param updatable whether the data is updatable
  5584. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5585. * @param stride the stride (optional)
  5586. * @param instanced whether the buffer is instanced (optional)
  5587. * @param offset the offset of the data (optional)
  5588. * @param size the number of components (optional)
  5589. * @param type the type of the component (optional)
  5590. * @param normalized whether the data contains normalized data (optional)
  5591. * @param useBytes set to true if stride and offset are in bytes (optional)
  5592. */
  5593. 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);
  5594. /** @hidden */
  5595. _rebuild(): void;
  5596. /**
  5597. * Returns the kind of the VertexBuffer (string)
  5598. * @returns a string
  5599. */
  5600. getKind(): string;
  5601. /**
  5602. * Gets a boolean indicating if the VertexBuffer is updatable?
  5603. * @returns true if the buffer is updatable
  5604. */
  5605. isUpdatable(): boolean;
  5606. /**
  5607. * Gets current buffer's data
  5608. * @returns a DataArray or null
  5609. */
  5610. getData(): Nullable<DataArray>;
  5611. /**
  5612. * Gets underlying native buffer
  5613. * @returns underlying native buffer
  5614. */
  5615. getBuffer(): Nullable<WebGLBuffer>;
  5616. /**
  5617. * Gets the stride in float32 units (i.e. byte stride / 4).
  5618. * May not be an integer if the byte stride is not divisible by 4.
  5619. * DEPRECATED. Use byteStride instead.
  5620. * @returns the stride in float32 units
  5621. */
  5622. getStrideSize(): number;
  5623. /**
  5624. * Returns the offset as a multiple of the type byte length.
  5625. * DEPRECATED. Use byteOffset instead.
  5626. * @returns the offset in bytes
  5627. */
  5628. getOffset(): number;
  5629. /**
  5630. * Returns the number of components per vertex attribute (integer)
  5631. * @returns the size in float
  5632. */
  5633. getSize(): number;
  5634. /**
  5635. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5636. * @returns true if this buffer is instanced
  5637. */
  5638. getIsInstanced(): boolean;
  5639. /**
  5640. * Returns the instancing divisor, zero for non-instanced (integer).
  5641. * @returns a number
  5642. */
  5643. getInstanceDivisor(): number;
  5644. /**
  5645. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5646. * @param data defines the data to store
  5647. */
  5648. create(data?: DataArray): void;
  5649. /**
  5650. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5651. * This function will create a new buffer if the current one is not updatable
  5652. * @param data defines the data to store
  5653. */
  5654. update(data: DataArray): void;
  5655. /**
  5656. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5657. * Returns the directly updated WebGLBuffer.
  5658. * @param data the new data
  5659. * @param offset the new offset
  5660. * @param useBytes set to true if the offset is in bytes
  5661. */
  5662. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5663. /**
  5664. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5665. */
  5666. dispose(): void;
  5667. /**
  5668. * Enumerates each value of this vertex buffer as numbers.
  5669. * @param count the number of values to enumerate
  5670. * @param callback the callback function called for each value
  5671. */
  5672. forEach(count: number, callback: (value: number, index: number) => void): void;
  5673. /**
  5674. * Positions
  5675. */
  5676. static readonly PositionKind: string;
  5677. /**
  5678. * Normals
  5679. */
  5680. static readonly NormalKind: string;
  5681. /**
  5682. * Tangents
  5683. */
  5684. static readonly TangentKind: string;
  5685. /**
  5686. * Texture coordinates
  5687. */
  5688. static readonly UVKind: string;
  5689. /**
  5690. * Texture coordinates 2
  5691. */
  5692. static readonly UV2Kind: string;
  5693. /**
  5694. * Texture coordinates 3
  5695. */
  5696. static readonly UV3Kind: string;
  5697. /**
  5698. * Texture coordinates 4
  5699. */
  5700. static readonly UV4Kind: string;
  5701. /**
  5702. * Texture coordinates 5
  5703. */
  5704. static readonly UV5Kind: string;
  5705. /**
  5706. * Texture coordinates 6
  5707. */
  5708. static readonly UV6Kind: string;
  5709. /**
  5710. * Colors
  5711. */
  5712. static readonly ColorKind: string;
  5713. /**
  5714. * Matrix indices (for bones)
  5715. */
  5716. static readonly MatricesIndicesKind: string;
  5717. /**
  5718. * Matrix weights (for bones)
  5719. */
  5720. static readonly MatricesWeightsKind: string;
  5721. /**
  5722. * Additional matrix indices (for bones)
  5723. */
  5724. static readonly MatricesIndicesExtraKind: string;
  5725. /**
  5726. * Additional matrix weights (for bones)
  5727. */
  5728. static readonly MatricesWeightsExtraKind: string;
  5729. /**
  5730. * Deduces the stride given a kind.
  5731. * @param kind The kind string to deduce
  5732. * @returns The deduced stride
  5733. */
  5734. static DeduceStride(kind: string): number;
  5735. /**
  5736. * Gets the byte length of the given type.
  5737. * @param type the type
  5738. * @returns the number of bytes
  5739. */
  5740. static GetTypeByteLength(type: number): number;
  5741. /**
  5742. * Enumerates each value of the given parameters as numbers.
  5743. * @param data the data to enumerate
  5744. * @param byteOffset the byte offset of the data
  5745. * @param byteStride the byte stride of the data
  5746. * @param componentCount the number of components per element
  5747. * @param componentType the type of the component
  5748. * @param count the total number of components
  5749. * @param normalized whether the data is normalized
  5750. * @param callback the callback function called for each value
  5751. */
  5752. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5753. private static _GetFloatValue;
  5754. }
  5755. }
  5756. declare module "babylonjs/Maths/sphericalPolynomial" {
  5757. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5758. /**
  5759. * Class representing spherical polynomial coefficients to the 3rd degree
  5760. */
  5761. export class SphericalPolynomial {
  5762. /**
  5763. * The x coefficients of the spherical polynomial
  5764. */
  5765. x: Vector3;
  5766. /**
  5767. * The y coefficients of the spherical polynomial
  5768. */
  5769. y: Vector3;
  5770. /**
  5771. * The z coefficients of the spherical polynomial
  5772. */
  5773. z: Vector3;
  5774. /**
  5775. * The xx coefficients of the spherical polynomial
  5776. */
  5777. xx: Vector3;
  5778. /**
  5779. * The yy coefficients of the spherical polynomial
  5780. */
  5781. yy: Vector3;
  5782. /**
  5783. * The zz coefficients of the spherical polynomial
  5784. */
  5785. zz: Vector3;
  5786. /**
  5787. * The xy coefficients of the spherical polynomial
  5788. */
  5789. xy: Vector3;
  5790. /**
  5791. * The yz coefficients of the spherical polynomial
  5792. */
  5793. yz: Vector3;
  5794. /**
  5795. * The zx coefficients of the spherical polynomial
  5796. */
  5797. zx: Vector3;
  5798. /**
  5799. * Adds an ambient color to the spherical polynomial
  5800. * @param color the color to add
  5801. */
  5802. addAmbient(color: Color3): void;
  5803. /**
  5804. * Scales the spherical polynomial by the given amount
  5805. * @param scale the amount to scale
  5806. */
  5807. scale(scale: number): void;
  5808. /**
  5809. * Gets the spherical polynomial from harmonics
  5810. * @param harmonics the spherical harmonics
  5811. * @returns the spherical polynomial
  5812. */
  5813. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5814. /**
  5815. * Constructs a spherical polynomial from an array.
  5816. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5817. * @returns the spherical polynomial
  5818. */
  5819. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5820. }
  5821. /**
  5822. * Class representing spherical harmonics coefficients to the 3rd degree
  5823. */
  5824. export class SphericalHarmonics {
  5825. /**
  5826. * The l0,0 coefficients of the spherical harmonics
  5827. */
  5828. l00: Vector3;
  5829. /**
  5830. * The l1,-1 coefficients of the spherical harmonics
  5831. */
  5832. l1_1: Vector3;
  5833. /**
  5834. * The l1,0 coefficients of the spherical harmonics
  5835. */
  5836. l10: Vector3;
  5837. /**
  5838. * The l1,1 coefficients of the spherical harmonics
  5839. */
  5840. l11: Vector3;
  5841. /**
  5842. * The l2,-2 coefficients of the spherical harmonics
  5843. */
  5844. l2_2: Vector3;
  5845. /**
  5846. * The l2,-1 coefficients of the spherical harmonics
  5847. */
  5848. l2_1: Vector3;
  5849. /**
  5850. * The l2,0 coefficients of the spherical harmonics
  5851. */
  5852. l20: Vector3;
  5853. /**
  5854. * The l2,1 coefficients of the spherical harmonics
  5855. */
  5856. l21: Vector3;
  5857. /**
  5858. * The l2,2 coefficients of the spherical harmonics
  5859. */
  5860. lL22: Vector3;
  5861. /**
  5862. * Adds a light to the spherical harmonics
  5863. * @param direction the direction of the light
  5864. * @param color the color of the light
  5865. * @param deltaSolidAngle the delta solid angle of the light
  5866. */
  5867. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5868. /**
  5869. * Scales the spherical harmonics by the given amount
  5870. * @param scale the amount to scale
  5871. */
  5872. scale(scale: number): void;
  5873. /**
  5874. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5875. *
  5876. * ```
  5877. * E_lm = A_l * L_lm
  5878. * ```
  5879. *
  5880. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5881. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5882. * the scaling factors are given in equation 9.
  5883. */
  5884. convertIncidentRadianceToIrradiance(): void;
  5885. /**
  5886. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5887. *
  5888. * ```
  5889. * L = (1/pi) * E * rho
  5890. * ```
  5891. *
  5892. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5893. */
  5894. convertIrradianceToLambertianRadiance(): void;
  5895. /**
  5896. * Gets the spherical harmonics from polynomial
  5897. * @param polynomial the spherical polynomial
  5898. * @returns the spherical harmonics
  5899. */
  5900. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5901. /**
  5902. * Constructs a spherical harmonics from an array.
  5903. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5904. * @returns the spherical harmonics
  5905. */
  5906. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5907. }
  5908. }
  5909. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5910. import { Nullable } from "babylonjs/types";
  5911. /**
  5912. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5913. */
  5914. export interface CubeMapInfo {
  5915. /**
  5916. * The pixel array for the front face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. front: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the back face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. back: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the left face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. left: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the right face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. right: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The pixel array for the up face.
  5937. * This is stored in format, left to right, up to down format.
  5938. */
  5939. up: Nullable<ArrayBufferView>;
  5940. /**
  5941. * The pixel array for the down face.
  5942. * This is stored in format, left to right, up to down format.
  5943. */
  5944. down: Nullable<ArrayBufferView>;
  5945. /**
  5946. * The size of the cubemap stored.
  5947. *
  5948. * Each faces will be size * size pixels.
  5949. */
  5950. size: number;
  5951. /**
  5952. * The format of the texture.
  5953. *
  5954. * RGBA, RGB.
  5955. */
  5956. format: number;
  5957. /**
  5958. * The type of the texture data.
  5959. *
  5960. * UNSIGNED_INT, FLOAT.
  5961. */
  5962. type: number;
  5963. /**
  5964. * Specifies whether the texture is in gamma space.
  5965. */
  5966. gammaSpace: boolean;
  5967. }
  5968. /**
  5969. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5970. */
  5971. export class PanoramaToCubeMapTools {
  5972. private static FACE_FRONT;
  5973. private static FACE_BACK;
  5974. private static FACE_RIGHT;
  5975. private static FACE_LEFT;
  5976. private static FACE_DOWN;
  5977. private static FACE_UP;
  5978. /**
  5979. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5980. *
  5981. * @param float32Array The source data.
  5982. * @param inputWidth The width of the input panorama.
  5983. * @param inputHeight The height of the input panorama.
  5984. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5985. * @return The cubemap data
  5986. */
  5987. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5988. private static CreateCubemapTexture;
  5989. private static CalcProjectionSpherical;
  5990. }
  5991. }
  5992. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5995. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5996. /**
  5997. * Helper class dealing with the extraction of spherical polynomial dataArray
  5998. * from a cube map.
  5999. */
  6000. export class CubeMapToSphericalPolynomialTools {
  6001. private static FileFaces;
  6002. /**
  6003. * Converts a texture to the according Spherical Polynomial data.
  6004. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6005. *
  6006. * @param texture The texture to extract the information from.
  6007. * @return The Spherical Polynomial data.
  6008. */
  6009. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6010. /**
  6011. * Converts a cubemap to the according Spherical Polynomial data.
  6012. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6013. *
  6014. * @param cubeInfo The Cube map to extract the information from.
  6015. * @return The Spherical Polynomial data.
  6016. */
  6017. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6018. }
  6019. }
  6020. declare module "babylonjs/Engines/engineStore" {
  6021. import { Nullable } from "babylonjs/types";
  6022. import { Engine } from "babylonjs/Engines/engine";
  6023. import { Scene } from "babylonjs/scene";
  6024. /**
  6025. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6026. * during the life time of the application.
  6027. */
  6028. export class EngineStore {
  6029. /** Gets the list of created engines */
  6030. static Instances: import("babylonjs/Engines/engine").Engine[];
  6031. /**
  6032. * Gets the latest created engine
  6033. */
  6034. static readonly LastCreatedEngine: Nullable<Engine>;
  6035. /**
  6036. * Gets the latest created scene
  6037. */
  6038. static readonly LastCreatedScene: Nullable<Scene>;
  6039. }
  6040. }
  6041. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6042. /**
  6043. * Define options used to create a render target texture
  6044. */
  6045. export class RenderTargetCreationOptions {
  6046. /**
  6047. * Specifies is mipmaps must be generated
  6048. */
  6049. generateMipMaps?: boolean;
  6050. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6051. generateDepthBuffer?: boolean;
  6052. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6053. generateStencilBuffer?: boolean;
  6054. /** Defines texture type (int by default) */
  6055. type?: number;
  6056. /** Defines sampling mode (trilinear by default) */
  6057. samplingMode?: number;
  6058. /** Defines format (RGBA by default) */
  6059. format?: number;
  6060. }
  6061. }
  6062. declare module "babylonjs/States/alphaCullingState" {
  6063. /**
  6064. * @hidden
  6065. **/
  6066. export class _AlphaState {
  6067. private _isAlphaBlendDirty;
  6068. private _isBlendFunctionParametersDirty;
  6069. private _isBlendEquationParametersDirty;
  6070. private _isBlendConstantsDirty;
  6071. private _alphaBlend;
  6072. private _blendFunctionParameters;
  6073. private _blendEquationParameters;
  6074. private _blendConstants;
  6075. /**
  6076. * Initializes the state.
  6077. */
  6078. constructor();
  6079. readonly isDirty: boolean;
  6080. alphaBlend: boolean;
  6081. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6082. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6083. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6084. reset(): void;
  6085. apply(gl: WebGLRenderingContext): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/States/depthCullingState" {
  6089. import { Nullable } from "babylonjs/types";
  6090. /**
  6091. * @hidden
  6092. **/
  6093. export class _DepthCullingState {
  6094. private _isDepthTestDirty;
  6095. private _isDepthMaskDirty;
  6096. private _isDepthFuncDirty;
  6097. private _isCullFaceDirty;
  6098. private _isCullDirty;
  6099. private _isZOffsetDirty;
  6100. private _isFrontFaceDirty;
  6101. private _depthTest;
  6102. private _depthMask;
  6103. private _depthFunc;
  6104. private _cull;
  6105. private _cullFace;
  6106. private _zOffset;
  6107. private _frontFace;
  6108. /**
  6109. * Initializes the state.
  6110. */
  6111. constructor();
  6112. readonly isDirty: boolean;
  6113. zOffset: number;
  6114. cullFace: Nullable<number>;
  6115. cull: Nullable<boolean>;
  6116. depthFunc: Nullable<number>;
  6117. depthMask: boolean;
  6118. depthTest: boolean;
  6119. frontFace: Nullable<number>;
  6120. reset(): void;
  6121. apply(gl: WebGLRenderingContext): void;
  6122. }
  6123. }
  6124. declare module "babylonjs/States/stencilState" {
  6125. /**
  6126. * @hidden
  6127. **/
  6128. export class _StencilState {
  6129. /** 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 */
  6130. static readonly ALWAYS: number;
  6131. /** Passed to stencilOperation to specify that stencil value must be kept */
  6132. static readonly KEEP: number;
  6133. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6134. static readonly REPLACE: number;
  6135. private _isStencilTestDirty;
  6136. private _isStencilMaskDirty;
  6137. private _isStencilFuncDirty;
  6138. private _isStencilOpDirty;
  6139. private _stencilTest;
  6140. private _stencilMask;
  6141. private _stencilFunc;
  6142. private _stencilFuncRef;
  6143. private _stencilFuncMask;
  6144. private _stencilOpStencilFail;
  6145. private _stencilOpDepthFail;
  6146. private _stencilOpStencilDepthPass;
  6147. readonly isDirty: boolean;
  6148. stencilFunc: number;
  6149. stencilFuncRef: number;
  6150. stencilFuncMask: number;
  6151. stencilOpStencilFail: number;
  6152. stencilOpDepthFail: number;
  6153. stencilOpStencilDepthPass: number;
  6154. stencilMask: number;
  6155. stencilTest: boolean;
  6156. constructor();
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/index" {
  6162. export * from "babylonjs/States/alphaCullingState";
  6163. export * from "babylonjs/States/depthCullingState";
  6164. export * from "babylonjs/States/stencilState";
  6165. }
  6166. declare module "babylonjs/Instrumentation/timeToken" {
  6167. import { Nullable } from "babylonjs/types";
  6168. /**
  6169. * @hidden
  6170. **/
  6171. export class _TimeToken {
  6172. _startTimeQuery: Nullable<WebGLQuery>;
  6173. _endTimeQuery: Nullable<WebGLQuery>;
  6174. _timeElapsedQuery: Nullable<WebGLQuery>;
  6175. _timeElapsedQueryEnded: boolean;
  6176. }
  6177. }
  6178. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6179. import { Nullable } from "babylonjs/types";
  6180. /**
  6181. * Internal interface used to track InternalTexture already bound to the GL context
  6182. */
  6183. export interface IInternalTextureTracker {
  6184. /**
  6185. * Gets or set the previous tracker in the list
  6186. */
  6187. previous: Nullable<IInternalTextureTracker>;
  6188. /**
  6189. * Gets or set the next tracker in the list
  6190. */
  6191. next: Nullable<IInternalTextureTracker>;
  6192. }
  6193. /**
  6194. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6195. */
  6196. export class DummyInternalTextureTracker {
  6197. /**
  6198. * Gets or set the previous tracker in the list
  6199. */
  6200. previous: Nullable<IInternalTextureTracker>;
  6201. /**
  6202. * Gets or set the next tracker in the list
  6203. */
  6204. next: Nullable<IInternalTextureTracker>;
  6205. }
  6206. }
  6207. declare module "babylonjs/Materials/Textures/internalTexture" {
  6208. import { Observable } from "babylonjs/Misc/observable";
  6209. import { Nullable, int } from "babylonjs/types";
  6210. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6211. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6212. import { Engine } from "babylonjs/Engines/engine";
  6213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6214. /**
  6215. * Class used to store data associated with WebGL texture data for the engine
  6216. * This class should not be used directly
  6217. */
  6218. export class InternalTexture implements IInternalTextureTracker {
  6219. /** hidden */
  6220. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6221. /**
  6222. * The source of the texture data is unknown
  6223. */
  6224. static DATASOURCE_UNKNOWN: number;
  6225. /**
  6226. * Texture data comes from an URL
  6227. */
  6228. static DATASOURCE_URL: number;
  6229. /**
  6230. * Texture data is only used for temporary storage
  6231. */
  6232. static DATASOURCE_TEMP: number;
  6233. /**
  6234. * Texture data comes from raw data (ArrayBuffer)
  6235. */
  6236. static DATASOURCE_RAW: number;
  6237. /**
  6238. * Texture content is dynamic (video or dynamic texture)
  6239. */
  6240. static DATASOURCE_DYNAMIC: number;
  6241. /**
  6242. * Texture content is generated by rendering to it
  6243. */
  6244. static DATASOURCE_RENDERTARGET: number;
  6245. /**
  6246. * Texture content is part of a multi render target process
  6247. */
  6248. static DATASOURCE_MULTIRENDERTARGET: number;
  6249. /**
  6250. * Texture data comes from a cube data file
  6251. */
  6252. static DATASOURCE_CUBE: number;
  6253. /**
  6254. * Texture data comes from a raw cube data
  6255. */
  6256. static DATASOURCE_CUBERAW: number;
  6257. /**
  6258. * Texture data come from a prefiltered cube data file
  6259. */
  6260. static DATASOURCE_CUBEPREFILTERED: number;
  6261. /**
  6262. * Texture content is raw 3D data
  6263. */
  6264. static DATASOURCE_RAW3D: number;
  6265. /**
  6266. * Texture content is a depth texture
  6267. */
  6268. static DATASOURCE_DEPTHTEXTURE: number;
  6269. /**
  6270. * Texture data comes from a raw cube data encoded with RGBD
  6271. */
  6272. static DATASOURCE_CUBERAW_RGBD: number;
  6273. /**
  6274. * Defines if the texture is ready
  6275. */
  6276. isReady: boolean;
  6277. /**
  6278. * Defines if the texture is a cube texture
  6279. */
  6280. isCube: boolean;
  6281. /**
  6282. * Defines if the texture contains 3D data
  6283. */
  6284. is3D: boolean;
  6285. /**
  6286. * Defines if the texture contains multiview data
  6287. */
  6288. isMultiview: boolean;
  6289. /**
  6290. * Gets the URL used to load this texture
  6291. */
  6292. url: string;
  6293. /**
  6294. * Gets the sampling mode of the texture
  6295. */
  6296. samplingMode: number;
  6297. /**
  6298. * Gets a boolean indicating if the texture needs mipmaps generation
  6299. */
  6300. generateMipMaps: boolean;
  6301. /**
  6302. * Gets the number of samples used by the texture (WebGL2+ only)
  6303. */
  6304. samples: number;
  6305. /**
  6306. * Gets the type of the texture (int, float...)
  6307. */
  6308. type: number;
  6309. /**
  6310. * Gets the format of the texture (RGB, RGBA...)
  6311. */
  6312. format: number;
  6313. /**
  6314. * Observable called when the texture is loaded
  6315. */
  6316. onLoadedObservable: Observable<InternalTexture>;
  6317. /**
  6318. * Gets the width of the texture
  6319. */
  6320. width: number;
  6321. /**
  6322. * Gets the height of the texture
  6323. */
  6324. height: number;
  6325. /**
  6326. * Gets the depth of the texture
  6327. */
  6328. depth: number;
  6329. /**
  6330. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6331. */
  6332. baseWidth: number;
  6333. /**
  6334. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6335. */
  6336. baseHeight: number;
  6337. /**
  6338. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6339. */
  6340. baseDepth: number;
  6341. /**
  6342. * Gets a boolean indicating if the texture is inverted on Y axis
  6343. */
  6344. invertY: boolean;
  6345. /**
  6346. * Gets or set the previous tracker in the list
  6347. */
  6348. previous: Nullable<IInternalTextureTracker>;
  6349. /**
  6350. * Gets or set the next tracker in the list
  6351. */
  6352. next: Nullable<IInternalTextureTracker>;
  6353. /** @hidden */
  6354. _invertVScale: boolean;
  6355. /** @hidden */
  6356. _initialSlot: number;
  6357. /** @hidden */
  6358. _designatedSlot: number;
  6359. /** @hidden */
  6360. _dataSource: number;
  6361. /** @hidden */
  6362. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6363. /** @hidden */
  6364. _bufferView: Nullable<ArrayBufferView>;
  6365. /** @hidden */
  6366. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6367. /** @hidden */
  6368. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6369. /** @hidden */
  6370. _size: number;
  6371. /** @hidden */
  6372. _extension: string;
  6373. /** @hidden */
  6374. _files: Nullable<string[]>;
  6375. /** @hidden */
  6376. _workingCanvas: HTMLCanvasElement;
  6377. /** @hidden */
  6378. _workingContext: CanvasRenderingContext2D;
  6379. /** @hidden */
  6380. _framebuffer: Nullable<WebGLFramebuffer>;
  6381. /** @hidden */
  6382. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6383. /** @hidden */
  6384. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6385. /** @hidden */
  6386. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6387. /** @hidden */
  6388. _attachments: Nullable<number[]>;
  6389. /** @hidden */
  6390. _cachedCoordinatesMode: Nullable<number>;
  6391. /** @hidden */
  6392. _cachedWrapU: Nullable<number>;
  6393. /** @hidden */
  6394. _cachedWrapV: Nullable<number>;
  6395. /** @hidden */
  6396. _cachedWrapR: Nullable<number>;
  6397. /** @hidden */
  6398. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6399. /** @hidden */
  6400. _isDisabled: boolean;
  6401. /** @hidden */
  6402. _compression: Nullable<string>;
  6403. /** @hidden */
  6404. _generateStencilBuffer: boolean;
  6405. /** @hidden */
  6406. _generateDepthBuffer: boolean;
  6407. /** @hidden */
  6408. _comparisonFunction: number;
  6409. /** @hidden */
  6410. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6411. /** @hidden */
  6412. _lodGenerationScale: number;
  6413. /** @hidden */
  6414. _lodGenerationOffset: number;
  6415. /** @hidden */
  6416. _colorTextureArray: Nullable<WebGLTexture>;
  6417. /** @hidden */
  6418. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6419. /** @hidden */
  6420. _lodTextureHigh: BaseTexture;
  6421. /** @hidden */
  6422. _lodTextureMid: BaseTexture;
  6423. /** @hidden */
  6424. _lodTextureLow: BaseTexture;
  6425. /** @hidden */
  6426. _isRGBD: boolean;
  6427. /** @hidden */
  6428. _webGLTexture: Nullable<WebGLTexture>;
  6429. /** @hidden */
  6430. _references: number;
  6431. private _engine;
  6432. /**
  6433. * Gets the Engine the texture belongs to.
  6434. * @returns The babylon engine
  6435. */
  6436. getEngine(): Engine;
  6437. /**
  6438. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6439. */
  6440. readonly dataSource: number;
  6441. /**
  6442. * Creates a new InternalTexture
  6443. * @param engine defines the engine to use
  6444. * @param dataSource defines the type of data that will be used
  6445. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6446. */
  6447. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6448. /**
  6449. * Increments the number of references (ie. the number of Texture that point to it)
  6450. */
  6451. incrementReferences(): void;
  6452. /**
  6453. * Change the size of the texture (not the size of the content)
  6454. * @param width defines the new width
  6455. * @param height defines the new height
  6456. * @param depth defines the new depth (1 by default)
  6457. */
  6458. updateSize(width: int, height: int, depth?: int): void;
  6459. /** @hidden */
  6460. _rebuild(): void;
  6461. /** @hidden */
  6462. _swapAndDie(target: InternalTexture): void;
  6463. /**
  6464. * Dispose the current allocated resources
  6465. */
  6466. dispose(): void;
  6467. }
  6468. }
  6469. declare module "babylonjs/Animations/easing" {
  6470. /**
  6471. * This represents the main contract an easing function should follow.
  6472. * Easing functions are used throughout the animation system.
  6473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6474. */
  6475. export interface IEasingFunction {
  6476. /**
  6477. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6478. * of the easing function.
  6479. * The link below provides some of the most common examples of easing functions.
  6480. * @see https://easings.net/
  6481. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6482. * @returns the corresponding value on the curve defined by the easing function
  6483. */
  6484. ease(gradient: number): number;
  6485. }
  6486. /**
  6487. * Base class used for every default easing function.
  6488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6489. */
  6490. export class EasingFunction implements IEasingFunction {
  6491. /**
  6492. * Interpolation follows the mathematical formula associated with the easing function.
  6493. */
  6494. static readonly EASINGMODE_EASEIN: number;
  6495. /**
  6496. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6497. */
  6498. static readonly EASINGMODE_EASEOUT: number;
  6499. /**
  6500. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6501. */
  6502. static readonly EASINGMODE_EASEINOUT: number;
  6503. private _easingMode;
  6504. /**
  6505. * Sets the easing mode of the current function.
  6506. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6507. */
  6508. setEasingMode(easingMode: number): void;
  6509. /**
  6510. * Gets the current easing mode.
  6511. * @returns the easing mode
  6512. */
  6513. getEasingMode(): number;
  6514. /**
  6515. * @hidden
  6516. */
  6517. easeInCore(gradient: number): number;
  6518. /**
  6519. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6520. * of the easing function.
  6521. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6522. * @returns the corresponding value on the curve defined by the easing function
  6523. */
  6524. ease(gradient: number): number;
  6525. }
  6526. /**
  6527. * Easing function with a circle shape (see link below).
  6528. * @see https://easings.net/#easeInCirc
  6529. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6530. */
  6531. export class CircleEase extends EasingFunction implements IEasingFunction {
  6532. /** @hidden */
  6533. easeInCore(gradient: number): number;
  6534. }
  6535. /**
  6536. * Easing function with a ease back shape (see link below).
  6537. * @see https://easings.net/#easeInBack
  6538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6539. */
  6540. export class BackEase extends EasingFunction implements IEasingFunction {
  6541. /** Defines the amplitude of the function */
  6542. amplitude: number;
  6543. /**
  6544. * Instantiates a back ease easing
  6545. * @see https://easings.net/#easeInBack
  6546. * @param amplitude Defines the amplitude of the function
  6547. */
  6548. constructor(
  6549. /** Defines the amplitude of the function */
  6550. amplitude?: number);
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with a bouncing shape (see link below).
  6556. * @see https://easings.net/#easeInBounce
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class BounceEase extends EasingFunction implements IEasingFunction {
  6560. /** Defines the number of bounces */
  6561. bounces: number;
  6562. /** Defines the amplitude of the bounce */
  6563. bounciness: number;
  6564. /**
  6565. * Instantiates a bounce easing
  6566. * @see https://easings.net/#easeInBounce
  6567. * @param bounces Defines the number of bounces
  6568. * @param bounciness Defines the amplitude of the bounce
  6569. */
  6570. constructor(
  6571. /** Defines the number of bounces */
  6572. bounces?: number,
  6573. /** Defines the amplitude of the bounce */
  6574. bounciness?: number);
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 3 shape (see link below).
  6580. * @see https://easings.net/#easeInCubic
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class CubicEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with an elastic shape (see link below).
  6589. * @see https://easings.net/#easeInElastic
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6593. /** Defines the number of oscillations*/
  6594. oscillations: number;
  6595. /** Defines the amplitude of the oscillations*/
  6596. springiness: number;
  6597. /**
  6598. * Instantiates an elastic easing function
  6599. * @see https://easings.net/#easeInElastic
  6600. * @param oscillations Defines the number of oscillations
  6601. * @param springiness Defines the amplitude of the oscillations
  6602. */
  6603. constructor(
  6604. /** Defines the number of oscillations*/
  6605. oscillations?: number,
  6606. /** Defines the amplitude of the oscillations*/
  6607. springiness?: number);
  6608. /** @hidden */
  6609. easeInCore(gradient: number): number;
  6610. }
  6611. /**
  6612. * Easing function with an exponential shape (see link below).
  6613. * @see https://easings.net/#easeInExpo
  6614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6615. */
  6616. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6617. /** Defines the exponent of the function */
  6618. exponent: number;
  6619. /**
  6620. * Instantiates an exponential easing function
  6621. * @see https://easings.net/#easeInExpo
  6622. * @param exponent Defines the exponent of the function
  6623. */
  6624. constructor(
  6625. /** Defines the exponent of the function */
  6626. exponent?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. /**
  6631. * Easing function with a power shape (see link below).
  6632. * @see https://easings.net/#easeInQuad
  6633. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6634. */
  6635. export class PowerEase extends EasingFunction implements IEasingFunction {
  6636. /** Defines the power of the function */
  6637. power: number;
  6638. /**
  6639. * Instantiates an power base easing function
  6640. * @see https://easings.net/#easeInQuad
  6641. * @param power Defines the power of the function
  6642. */
  6643. constructor(
  6644. /** Defines the power of the function */
  6645. power?: number);
  6646. /** @hidden */
  6647. easeInCore(gradient: number): number;
  6648. }
  6649. /**
  6650. * Easing function with a power of 2 shape (see link below).
  6651. * @see https://easings.net/#easeInQuad
  6652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6653. */
  6654. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a power of 4 shape (see link below).
  6660. * @see https://easings.net/#easeInQuart
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a power of 5 shape (see link below).
  6669. * @see https://easings.net/#easeInQuint
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6673. /** @hidden */
  6674. easeInCore(gradient: number): number;
  6675. }
  6676. /**
  6677. * Easing function with a sin shape (see link below).
  6678. * @see https://easings.net/#easeInSine
  6679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6680. */
  6681. export class SineEase extends EasingFunction implements IEasingFunction {
  6682. /** @hidden */
  6683. easeInCore(gradient: number): number;
  6684. }
  6685. /**
  6686. * Easing function with a bezier shape (see link below).
  6687. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6691. /** Defines the x component of the start tangent in the bezier curve */
  6692. x1: number;
  6693. /** Defines the y component of the start tangent in the bezier curve */
  6694. y1: number;
  6695. /** Defines the x component of the end tangent in the bezier curve */
  6696. x2: number;
  6697. /** Defines the y component of the end tangent in the bezier curve */
  6698. y2: number;
  6699. /**
  6700. * Instantiates a bezier function
  6701. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6702. * @param x1 Defines the x component of the start tangent in the bezier curve
  6703. * @param y1 Defines the y component of the start tangent in the bezier curve
  6704. * @param x2 Defines the x component of the end tangent in the bezier curve
  6705. * @param y2 Defines the y component of the end tangent in the bezier curve
  6706. */
  6707. constructor(
  6708. /** Defines the x component of the start tangent in the bezier curve */
  6709. x1?: number,
  6710. /** Defines the y component of the start tangent in the bezier curve */
  6711. y1?: number,
  6712. /** Defines the x component of the end tangent in the bezier curve */
  6713. x2?: number,
  6714. /** Defines the y component of the end tangent in the bezier curve */
  6715. y2?: number);
  6716. /** @hidden */
  6717. easeInCore(gradient: number): number;
  6718. }
  6719. }
  6720. declare module "babylonjs/Animations/animationKey" {
  6721. /**
  6722. * Defines an interface which represents an animation key frame
  6723. */
  6724. export interface IAnimationKey {
  6725. /**
  6726. * Frame of the key frame
  6727. */
  6728. frame: number;
  6729. /**
  6730. * Value at the specifies key frame
  6731. */
  6732. value: any;
  6733. /**
  6734. * The input tangent for the cubic hermite spline
  6735. */
  6736. inTangent?: any;
  6737. /**
  6738. * The output tangent for the cubic hermite spline
  6739. */
  6740. outTangent?: any;
  6741. /**
  6742. * The animation interpolation type
  6743. */
  6744. interpolation?: AnimationKeyInterpolation;
  6745. }
  6746. /**
  6747. * Enum for the animation key frame interpolation type
  6748. */
  6749. export enum AnimationKeyInterpolation {
  6750. /**
  6751. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6752. */
  6753. STEP = 1
  6754. }
  6755. }
  6756. declare module "babylonjs/Animations/animationRange" {
  6757. /**
  6758. * Represents the range of an animation
  6759. */
  6760. export class AnimationRange {
  6761. /**The name of the animation range**/
  6762. name: string;
  6763. /**The starting frame of the animation */
  6764. from: number;
  6765. /**The ending frame of the animation*/
  6766. to: number;
  6767. /**
  6768. * Initializes the range of an animation
  6769. * @param name The name of the animation range
  6770. * @param from The starting frame of the animation
  6771. * @param to The ending frame of the animation
  6772. */
  6773. constructor(
  6774. /**The name of the animation range**/
  6775. name: string,
  6776. /**The starting frame of the animation */
  6777. from: number,
  6778. /**The ending frame of the animation*/
  6779. to: number);
  6780. /**
  6781. * Makes a copy of the animation range
  6782. * @returns A copy of the animation range
  6783. */
  6784. clone(): AnimationRange;
  6785. }
  6786. }
  6787. declare module "babylonjs/Animations/animationEvent" {
  6788. /**
  6789. * Composed of a frame, and an action function
  6790. */
  6791. export class AnimationEvent {
  6792. /** The frame for which the event is triggered **/
  6793. frame: number;
  6794. /** The event to perform when triggered **/
  6795. action: (currentFrame: number) => void;
  6796. /** Specifies if the event should be triggered only once**/
  6797. onlyOnce?: boolean | undefined;
  6798. /**
  6799. * Specifies if the animation event is done
  6800. */
  6801. isDone: boolean;
  6802. /**
  6803. * Initializes the animation event
  6804. * @param frame The frame for which the event is triggered
  6805. * @param action The event to perform when triggered
  6806. * @param onlyOnce Specifies if the event should be triggered only once
  6807. */
  6808. constructor(
  6809. /** The frame for which the event is triggered **/
  6810. frame: number,
  6811. /** The event to perform when triggered **/
  6812. action: (currentFrame: number) => void,
  6813. /** Specifies if the event should be triggered only once**/
  6814. onlyOnce?: boolean | undefined);
  6815. /** @hidden */
  6816. _clone(): AnimationEvent;
  6817. }
  6818. }
  6819. declare module "babylonjs/Behaviors/behavior" {
  6820. import { Nullable } from "babylonjs/types";
  6821. /**
  6822. * Interface used to define a behavior
  6823. */
  6824. export interface Behavior<T> {
  6825. /** gets or sets behavior's name */
  6826. name: string;
  6827. /**
  6828. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6829. */
  6830. init(): void;
  6831. /**
  6832. * Called when the behavior is attached to a target
  6833. * @param target defines the target where the behavior is attached to
  6834. */
  6835. attach(target: T): void;
  6836. /**
  6837. * Called when the behavior is detached from its target
  6838. */
  6839. detach(): void;
  6840. }
  6841. /**
  6842. * Interface implemented by classes supporting behaviors
  6843. */
  6844. export interface IBehaviorAware<T> {
  6845. /**
  6846. * Attach a behavior
  6847. * @param behavior defines the behavior to attach
  6848. * @returns the current host
  6849. */
  6850. addBehavior(behavior: Behavior<T>): T;
  6851. /**
  6852. * Remove a behavior from the current object
  6853. * @param behavior defines the behavior to detach
  6854. * @returns the current host
  6855. */
  6856. removeBehavior(behavior: Behavior<T>): T;
  6857. /**
  6858. * Gets a behavior using its name to search
  6859. * @param name defines the name to search
  6860. * @returns the behavior or null if not found
  6861. */
  6862. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6863. }
  6864. }
  6865. declare module "babylonjs/Collisions/intersectionInfo" {
  6866. import { Nullable } from "babylonjs/types";
  6867. /**
  6868. * @hidden
  6869. */
  6870. export class IntersectionInfo {
  6871. bu: Nullable<number>;
  6872. bv: Nullable<number>;
  6873. distance: number;
  6874. faceId: number;
  6875. subMeshId: number;
  6876. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingSphere" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6882. /**
  6883. * Class used to store bounding sphere information
  6884. */
  6885. export class BoundingSphere {
  6886. /**
  6887. * Gets the center of the bounding sphere in local space
  6888. */
  6889. readonly center: Vector3;
  6890. /**
  6891. * Radius of the bounding sphere in local space
  6892. */
  6893. radius: number;
  6894. /**
  6895. * Gets the center of the bounding sphere in world space
  6896. */
  6897. readonly centerWorld: Vector3;
  6898. /**
  6899. * Radius of the bounding sphere in world space
  6900. */
  6901. radiusWorld: number;
  6902. /**
  6903. * Gets the minimum vector in local space
  6904. */
  6905. readonly minimum: Vector3;
  6906. /**
  6907. * Gets the maximum vector in local space
  6908. */
  6909. readonly maximum: Vector3;
  6910. private _worldMatrix;
  6911. private static readonly TmpVector3;
  6912. /**
  6913. * Creates a new bounding sphere
  6914. * @param min defines the minimum vector (in local space)
  6915. * @param max defines the maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6919. /**
  6920. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6921. * @param min defines the new minimum vector (in local space)
  6922. * @param max defines the new maximum vector (in local space)
  6923. * @param worldMatrix defines the new world matrix
  6924. */
  6925. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6926. /**
  6927. * Scale the current bounding sphere by applying a scale factor
  6928. * @param factor defines the scale factor to apply
  6929. * @returns the current bounding box
  6930. */
  6931. scale(factor: number): BoundingSphere;
  6932. /**
  6933. * Gets the world matrix of the bounding box
  6934. * @returns a matrix
  6935. */
  6936. getWorldMatrix(): DeepImmutable<Matrix>;
  6937. /** @hidden */
  6938. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6939. /**
  6940. * Tests if the bounding sphere is intersecting the frustum planes
  6941. * @param frustumPlanes defines the frustum planes to test
  6942. * @returns true if there is an intersection
  6943. */
  6944. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6945. /**
  6946. * Tests if the bounding sphere center is in between the frustum planes.
  6947. * Used for optimistic fast inclusion.
  6948. * @param frustumPlanes defines the frustum planes to test
  6949. * @returns true if the sphere center is in between the frustum planes
  6950. */
  6951. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6952. /**
  6953. * Tests if a point is inside the bounding sphere
  6954. * @param point defines the point to test
  6955. * @returns true if the point is inside the bounding sphere
  6956. */
  6957. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6958. /**
  6959. * Checks if two sphere intersct
  6960. * @param sphere0 sphere 0
  6961. * @param sphere1 sphere 1
  6962. * @returns true if the speres intersect
  6963. */
  6964. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6965. }
  6966. }
  6967. declare module "babylonjs/Culling/boundingBox" {
  6968. import { DeepImmutable } from "babylonjs/types";
  6969. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6970. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6971. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6972. /**
  6973. * Class used to store bounding box information
  6974. */
  6975. export class BoundingBox implements ICullable {
  6976. /**
  6977. * Gets the 8 vectors representing the bounding box in local space
  6978. */
  6979. readonly vectors: Vector3[];
  6980. /**
  6981. * Gets the center of the bounding box in local space
  6982. */
  6983. readonly center: Vector3;
  6984. /**
  6985. * Gets the center of the bounding box in world space
  6986. */
  6987. readonly centerWorld: Vector3;
  6988. /**
  6989. * Gets the extend size in local space
  6990. */
  6991. readonly extendSize: Vector3;
  6992. /**
  6993. * Gets the extend size in world space
  6994. */
  6995. readonly extendSizeWorld: Vector3;
  6996. /**
  6997. * Gets the OBB (object bounding box) directions
  6998. */
  6999. readonly directions: Vector3[];
  7000. /**
  7001. * Gets the 8 vectors representing the bounding box in world space
  7002. */
  7003. readonly vectorsWorld: Vector3[];
  7004. /**
  7005. * Gets the minimum vector in world space
  7006. */
  7007. readonly minimumWorld: Vector3;
  7008. /**
  7009. * Gets the maximum vector in world space
  7010. */
  7011. readonly maximumWorld: Vector3;
  7012. /**
  7013. * Gets the minimum vector in local space
  7014. */
  7015. readonly minimum: Vector3;
  7016. /**
  7017. * Gets the maximum vector in local space
  7018. */
  7019. readonly maximum: Vector3;
  7020. private _worldMatrix;
  7021. private static readonly TmpVector3;
  7022. /**
  7023. * @hidden
  7024. */
  7025. _tag: number;
  7026. /**
  7027. * Creates a new bounding box
  7028. * @param min defines the minimum vector (in local space)
  7029. * @param max defines the maximum vector (in local space)
  7030. * @param worldMatrix defines the new world matrix
  7031. */
  7032. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7033. /**
  7034. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7035. * @param min defines the new minimum vector (in local space)
  7036. * @param max defines the new maximum vector (in local space)
  7037. * @param worldMatrix defines the new world matrix
  7038. */
  7039. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7040. /**
  7041. * Scale the current bounding box by applying a scale factor
  7042. * @param factor defines the scale factor to apply
  7043. * @returns the current bounding box
  7044. */
  7045. scale(factor: number): BoundingBox;
  7046. /**
  7047. * Gets the world matrix of the bounding box
  7048. * @returns a matrix
  7049. */
  7050. getWorldMatrix(): DeepImmutable<Matrix>;
  7051. /** @hidden */
  7052. _update(world: DeepImmutable<Matrix>): void;
  7053. /**
  7054. * Tests if the bounding box is intersecting the frustum planes
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @returns true if there is an intersection
  7057. */
  7058. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. /**
  7060. * Tests if the bounding box is entirely inside the frustum planes
  7061. * @param frustumPlanes defines the frustum planes to test
  7062. * @returns true if there is an inclusion
  7063. */
  7064. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7065. /**
  7066. * Tests if a point is inside the bounding box
  7067. * @param point defines the point to test
  7068. * @returns true if the point is inside the bounding box
  7069. */
  7070. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7071. /**
  7072. * Tests if the bounding box intersects with a bounding sphere
  7073. * @param sphere defines the sphere to test
  7074. * @returns true if there is an intersection
  7075. */
  7076. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7077. /**
  7078. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7079. * @param min defines the min vector to use
  7080. * @param max defines the max vector to use
  7081. * @returns true if there is an intersection
  7082. */
  7083. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7084. /**
  7085. * Tests if two bounding boxes are intersections
  7086. * @param box0 defines the first box to test
  7087. * @param box1 defines the second box to test
  7088. * @returns true if there is an intersection
  7089. */
  7090. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7091. /**
  7092. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7093. * @param minPoint defines the minimum vector of the bounding box
  7094. * @param maxPoint defines the maximum vector of the bounding box
  7095. * @param sphereCenter defines the sphere center
  7096. * @param sphereRadius defines the sphere radius
  7097. * @returns true if there is an intersection
  7098. */
  7099. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7100. /**
  7101. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7102. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7103. * @param frustumPlanes defines the frustum planes to test
  7104. * @return true if there is an inclusion
  7105. */
  7106. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7107. /**
  7108. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7109. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7110. * @param frustumPlanes defines the frustum planes to test
  7111. * @return true if there is an intersection
  7112. */
  7113. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7114. }
  7115. }
  7116. declare module "babylonjs/Collisions/collider" {
  7117. import { Nullable, IndicesArray } from "babylonjs/types";
  7118. import { Vector3, Plane } from "babylonjs/Maths/math";
  7119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7120. /** @hidden */
  7121. export class Collider {
  7122. /** Define if a collision was found */
  7123. collisionFound: boolean;
  7124. /**
  7125. * Define last intersection point in local space
  7126. */
  7127. intersectionPoint: Vector3;
  7128. /**
  7129. * Define last collided mesh
  7130. */
  7131. collidedMesh: Nullable<AbstractMesh>;
  7132. private _collisionPoint;
  7133. private _planeIntersectionPoint;
  7134. private _tempVector;
  7135. private _tempVector2;
  7136. private _tempVector3;
  7137. private _tempVector4;
  7138. private _edge;
  7139. private _baseToVertex;
  7140. private _destinationPoint;
  7141. private _slidePlaneNormal;
  7142. private _displacementVector;
  7143. /** @hidden */
  7144. _radius: Vector3;
  7145. /** @hidden */
  7146. _retry: number;
  7147. private _velocity;
  7148. private _basePoint;
  7149. private _epsilon;
  7150. /** @hidden */
  7151. _velocityWorldLength: number;
  7152. /** @hidden */
  7153. _basePointWorld: Vector3;
  7154. private _velocityWorld;
  7155. private _normalizedVelocity;
  7156. /** @hidden */
  7157. _initialVelocity: Vector3;
  7158. /** @hidden */
  7159. _initialPosition: Vector3;
  7160. private _nearestDistance;
  7161. private _collisionMask;
  7162. collisionMask: number;
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. readonly slidePlaneNormal: Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Collider } from "babylonjs/Collisions/collider";
  7187. /**
  7188. * Interface for cullable objects
  7189. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7190. */
  7191. export interface ICullable {
  7192. /**
  7193. * Checks if the object or part of the object is in the frustum
  7194. * @param frustumPlanes Camera near/planes
  7195. * @returns true if the object is in frustum otherwise false
  7196. */
  7197. isInFrustum(frustumPlanes: Plane[]): boolean;
  7198. /**
  7199. * Checks if a cullable object (mesh...) is in the camera frustum
  7200. * Unlike isInFrustum this cheks the full bounding box
  7201. * @param frustumPlanes Camera near/planes
  7202. * @returns true if the object is in frustum otherwise false
  7203. */
  7204. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7205. }
  7206. /**
  7207. * Info for a bounding data of a mesh
  7208. */
  7209. export class BoundingInfo implements ICullable {
  7210. /**
  7211. * Bounding box for the mesh
  7212. */
  7213. readonly boundingBox: BoundingBox;
  7214. /**
  7215. * Bounding sphere for the mesh
  7216. */
  7217. readonly boundingSphere: BoundingSphere;
  7218. private _isLocked;
  7219. private static readonly TmpVector3;
  7220. /**
  7221. * Constructs bounding info
  7222. * @param minimum min vector of the bounding box/sphere
  7223. * @param maximum max vector of the bounding box/sphere
  7224. * @param worldMatrix defines the new world matrix
  7225. */
  7226. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7227. /**
  7228. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7229. * @param min defines the new minimum vector (in local space)
  7230. * @param max defines the new maximum vector (in local space)
  7231. * @param worldMatrix defines the new world matrix
  7232. */
  7233. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7234. /**
  7235. * min vector of the bounding box/sphere
  7236. */
  7237. readonly minimum: Vector3;
  7238. /**
  7239. * max vector of the bounding box/sphere
  7240. */
  7241. readonly maximum: Vector3;
  7242. /**
  7243. * If the info is locked and won't be updated to avoid perf overhead
  7244. */
  7245. isLocked: boolean;
  7246. /**
  7247. * Updates the bounding sphere and box
  7248. * @param world world matrix to be used to update
  7249. */
  7250. update(world: DeepImmutable<Matrix>): void;
  7251. /**
  7252. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7253. * @param center New center of the bounding info
  7254. * @param extend New extend of the bounding info
  7255. * @returns the current bounding info
  7256. */
  7257. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7258. /**
  7259. * Scale the current bounding info by applying a scale factor
  7260. * @param factor defines the scale factor to apply
  7261. * @returns the current bounding info
  7262. */
  7263. scale(factor: number): BoundingInfo;
  7264. /**
  7265. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7266. * @param frustumPlanes defines the frustum to test
  7267. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7268. * @returns true if the bounding info is in the frustum planes
  7269. */
  7270. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7271. /**
  7272. * Gets the world distance between the min and max points of the bounding box
  7273. */
  7274. readonly diagonalLength: number;
  7275. /**
  7276. * Checks if a cullable object (mesh...) is in the camera frustum
  7277. * Unlike isInFrustum this cheks the full bounding box
  7278. * @param frustumPlanes Camera near/planes
  7279. * @returns true if the object is in frustum otherwise false
  7280. */
  7281. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7282. /** @hidden */
  7283. _checkCollision(collider: Collider): boolean;
  7284. /**
  7285. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7286. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7287. * @param point the point to check intersection with
  7288. * @returns if the point intersects
  7289. */
  7290. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7291. /**
  7292. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7293. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7294. * @param boundingInfo the bounding info to check intersection with
  7295. * @param precise if the intersection should be done using OBB
  7296. * @returns if the bounding info intersects
  7297. */
  7298. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7299. }
  7300. }
  7301. declare module "babylonjs/Misc/smartArray" {
  7302. /**
  7303. * Defines an array and its length.
  7304. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7305. */
  7306. export interface ISmartArrayLike<T> {
  7307. /**
  7308. * The data of the array.
  7309. */
  7310. data: Array<T>;
  7311. /**
  7312. * The active length of the array.
  7313. */
  7314. length: number;
  7315. }
  7316. /**
  7317. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7318. */
  7319. export class SmartArray<T> implements ISmartArrayLike<T> {
  7320. /**
  7321. * The full set of data from the array.
  7322. */
  7323. data: Array<T>;
  7324. /**
  7325. * The active length of the array.
  7326. */
  7327. length: number;
  7328. protected _id: number;
  7329. /**
  7330. * Instantiates a Smart Array.
  7331. * @param capacity defines the default capacity of the array.
  7332. */
  7333. constructor(capacity: number);
  7334. /**
  7335. * Pushes a value at the end of the active data.
  7336. * @param value defines the object to push in the array.
  7337. */
  7338. push(value: T): void;
  7339. /**
  7340. * Iterates over the active data and apply the lambda to them.
  7341. * @param func defines the action to apply on each value.
  7342. */
  7343. forEach(func: (content: T) => void): void;
  7344. /**
  7345. * Sorts the full sets of data.
  7346. * @param compareFn defines the comparison function to apply.
  7347. */
  7348. sort(compareFn: (a: T, b: T) => number): void;
  7349. /**
  7350. * Resets the active data to an empty array.
  7351. */
  7352. reset(): void;
  7353. /**
  7354. * Releases all the data from the array as well as the array.
  7355. */
  7356. dispose(): void;
  7357. /**
  7358. * Concats the active data with a given array.
  7359. * @param array defines the data to concatenate with.
  7360. */
  7361. concat(array: any): void;
  7362. /**
  7363. * Returns the position of a value in the active data.
  7364. * @param value defines the value to find the index for
  7365. * @returns the index if found in the active data otherwise -1
  7366. */
  7367. indexOf(value: T): number;
  7368. /**
  7369. * Returns whether an element is part of the active data.
  7370. * @param value defines the value to look for
  7371. * @returns true if found in the active data otherwise false
  7372. */
  7373. contains(value: T): boolean;
  7374. private static _GlobalId;
  7375. }
  7376. /**
  7377. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7378. * The data in this array can only be present once
  7379. */
  7380. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7381. private _duplicateId;
  7382. /**
  7383. * Pushes a value at the end of the active data.
  7384. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7385. * @param value defines the object to push in the array.
  7386. */
  7387. push(value: T): void;
  7388. /**
  7389. * Pushes a value at the end of the active data.
  7390. * If the data is already present, it won t be added again
  7391. * @param value defines the object to push in the array.
  7392. * @returns true if added false if it was already present
  7393. */
  7394. pushNoDuplicate(value: T): boolean;
  7395. /**
  7396. * Resets the active data to an empty array.
  7397. */
  7398. reset(): void;
  7399. /**
  7400. * Concats the active data with a given array.
  7401. * This ensures no dupplicate will be present in the result.
  7402. * @param array defines the data to concatenate with.
  7403. */
  7404. concatWithNoDuplicate(array: any): void;
  7405. }
  7406. }
  7407. declare module "babylonjs/Materials/multiMaterial" {
  7408. import { Nullable } from "babylonjs/types";
  7409. import { Scene } from "babylonjs/scene";
  7410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7411. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7413. import { Material } from "babylonjs/Materials/material";
  7414. /**
  7415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7416. * separate meshes. This can be use to improve performances.
  7417. * @see http://doc.babylonjs.com/how_to/multi_materials
  7418. */
  7419. export class MultiMaterial extends Material {
  7420. private _subMaterials;
  7421. /**
  7422. * Gets or Sets the list of Materials used within the multi material.
  7423. * They need to be ordered according to the submeshes order in the associated mesh
  7424. */
  7425. subMaterials: Nullable<Material>[];
  7426. /**
  7427. * Function used to align with Node.getChildren()
  7428. * @returns the list of Materials used within the multi material
  7429. */
  7430. getChildren(): Nullable<Material>[];
  7431. /**
  7432. * Instantiates a new Multi Material
  7433. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7434. * separate meshes. This can be use to improve performances.
  7435. * @see http://doc.babylonjs.com/how_to/multi_materials
  7436. * @param name Define the name in the scene
  7437. * @param scene Define the scene the material belongs to
  7438. */
  7439. constructor(name: string, scene: Scene);
  7440. private _hookArray;
  7441. /**
  7442. * Get one of the submaterial by its index in the submaterials array
  7443. * @param index The index to look the sub material at
  7444. * @returns The Material if the index has been defined
  7445. */
  7446. getSubMaterial(index: number): Nullable<Material>;
  7447. /**
  7448. * Get the list of active textures for the whole sub materials list.
  7449. * @returns All the textures that will be used during the rendering
  7450. */
  7451. getActiveTextures(): BaseTexture[];
  7452. /**
  7453. * Gets the current class name of the material e.g. "MultiMaterial"
  7454. * Mainly use in serialization.
  7455. * @returns the class name
  7456. */
  7457. getClassName(): string;
  7458. /**
  7459. * Checks if the material is ready to render the requested sub mesh
  7460. * @param mesh Define the mesh the submesh belongs to
  7461. * @param subMesh Define the sub mesh to look readyness for
  7462. * @param useInstances Define whether or not the material is used with instances
  7463. * @returns true if ready, otherwise false
  7464. */
  7465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7466. /**
  7467. * Clones the current material and its related sub materials
  7468. * @param name Define the name of the newly cloned material
  7469. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7470. * @returns the cloned material
  7471. */
  7472. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7473. /**
  7474. * Serializes the materials into a JSON representation.
  7475. * @returns the JSON representation
  7476. */
  7477. serialize(): any;
  7478. /**
  7479. * Dispose the material and release its associated resources
  7480. * @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)
  7481. * @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)
  7482. * @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)
  7483. */
  7484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7485. /**
  7486. * Creates a MultiMaterial from parsed MultiMaterial data.
  7487. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7488. * @param scene defines the hosting scene
  7489. * @returns a new MultiMaterial
  7490. */
  7491. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7492. }
  7493. }
  7494. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7495. /**
  7496. * Class used to represent data loading progression
  7497. */
  7498. export class SceneLoaderFlags {
  7499. private static _ForceFullSceneLoadingForIncremental;
  7500. private static _ShowLoadingScreen;
  7501. private static _CleanBoneMatrixWeights;
  7502. private static _loggingLevel;
  7503. /**
  7504. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7505. */
  7506. static ForceFullSceneLoadingForIncremental: boolean;
  7507. /**
  7508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7509. */
  7510. static ShowLoadingScreen: boolean;
  7511. /**
  7512. * Defines the current logging level (while loading the scene)
  7513. * @ignorenaming
  7514. */
  7515. static loggingLevel: number;
  7516. /**
  7517. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7518. */
  7519. static CleanBoneMatrixWeights: boolean;
  7520. }
  7521. }
  7522. declare module "babylonjs/Meshes/transformNode" {
  7523. import { DeepImmutable } from "babylonjs/types";
  7524. import { Observable } from "babylonjs/Misc/observable";
  7525. import { Nullable } from "babylonjs/types";
  7526. import { Camera } from "babylonjs/Cameras/camera";
  7527. import { Scene } from "babylonjs/scene";
  7528. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7529. import { Node } from "babylonjs/node";
  7530. import { Bone } from "babylonjs/Bones/bone";
  7531. /**
  7532. * 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.
  7533. * @see https://doc.babylonjs.com/how_to/transformnode
  7534. */
  7535. export class TransformNode extends Node {
  7536. /**
  7537. * Object will not rotate to face the camera
  7538. */
  7539. static BILLBOARDMODE_NONE: number;
  7540. /**
  7541. * Object will rotate to face the camera but only on the x axis
  7542. */
  7543. static BILLBOARDMODE_X: number;
  7544. /**
  7545. * Object will rotate to face the camera but only on the y axis
  7546. */
  7547. static BILLBOARDMODE_Y: number;
  7548. /**
  7549. * Object will rotate to face the camera but only on the z axis
  7550. */
  7551. static BILLBOARDMODE_Z: number;
  7552. /**
  7553. * Object will rotate to face the camera
  7554. */
  7555. static BILLBOARDMODE_ALL: number;
  7556. private _forward;
  7557. private _forwardInverted;
  7558. private _up;
  7559. private _right;
  7560. private _rightInverted;
  7561. private _position;
  7562. private _rotation;
  7563. private _rotationQuaternion;
  7564. protected _scaling: Vector3;
  7565. protected _isDirty: boolean;
  7566. private _transformToBoneReferal;
  7567. /**
  7568. * Set the billboard mode. Default is 0.
  7569. *
  7570. * | Value | Type | Description |
  7571. * | --- | --- | --- |
  7572. * | 0 | BILLBOARDMODE_NONE | |
  7573. * | 1 | BILLBOARDMODE_X | |
  7574. * | 2 | BILLBOARDMODE_Y | |
  7575. * | 4 | BILLBOARDMODE_Z | |
  7576. * | 7 | BILLBOARDMODE_ALL | |
  7577. *
  7578. */
  7579. billboardMode: number;
  7580. /**
  7581. * 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
  7582. */
  7583. scalingDeterminant: number;
  7584. /**
  7585. * Sets the distance of the object to max, often used by skybox
  7586. */
  7587. infiniteDistance: boolean;
  7588. /**
  7589. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7590. * By default the system will update normals to compensate
  7591. */
  7592. ignoreNonUniformScaling: boolean;
  7593. /** @hidden */
  7594. _poseMatrix: Matrix;
  7595. /** @hidden */
  7596. _localMatrix: Matrix;
  7597. private _absolutePosition;
  7598. private _pivotMatrix;
  7599. private _pivotMatrixInverse;
  7600. protected _postMultiplyPivotMatrix: boolean;
  7601. private _tempMatrix;
  7602. private _tempMatrix2;
  7603. protected _isWorldMatrixFrozen: boolean;
  7604. /** @hidden */
  7605. _indexInSceneTransformNodesArray: number;
  7606. /**
  7607. * An event triggered after the world matrix is updated
  7608. */
  7609. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7610. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7611. /**
  7612. * Gets a string identifying the name of the class
  7613. * @returns "TransformNode" string
  7614. */
  7615. getClassName(): string;
  7616. /**
  7617. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7618. */
  7619. position: Vector3;
  7620. /**
  7621. * 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)).
  7622. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7623. */
  7624. rotation: Vector3;
  7625. /**
  7626. * 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)).
  7627. */
  7628. scaling: Vector3;
  7629. /**
  7630. * 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).
  7631. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7632. */
  7633. rotationQuaternion: Nullable<Quaternion>;
  7634. /**
  7635. * The forward direction of that transform in world space.
  7636. */
  7637. readonly forward: Vector3;
  7638. /**
  7639. * The up direction of that transform in world space.
  7640. */
  7641. readonly up: Vector3;
  7642. /**
  7643. * The right direction of that transform in world space.
  7644. */
  7645. readonly right: Vector3;
  7646. /**
  7647. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7648. * @param matrix the matrix to copy the pose from
  7649. * @returns this TransformNode.
  7650. */
  7651. updatePoseMatrix(matrix: Matrix): TransformNode;
  7652. /**
  7653. * Returns the mesh Pose matrix.
  7654. * @returns the pose matrix
  7655. */
  7656. getPoseMatrix(): Matrix;
  7657. /** @hidden */
  7658. _isSynchronized(): boolean;
  7659. /** @hidden */
  7660. _initCache(): void;
  7661. /**
  7662. * Flag the transform node as dirty (Forcing it to update everything)
  7663. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7664. * @returns this transform node
  7665. */
  7666. markAsDirty(property: string): TransformNode;
  7667. /**
  7668. * Returns the current mesh absolute position.
  7669. * Returns a Vector3.
  7670. */
  7671. readonly absolutePosition: Vector3;
  7672. /**
  7673. * Sets a new matrix to apply before all other transformation
  7674. * @param matrix defines the transform matrix
  7675. * @returns the current TransformNode
  7676. */
  7677. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7678. /**
  7679. * Sets a new pivot matrix to the current node
  7680. * @param matrix defines the new pivot matrix to use
  7681. * @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
  7682. * @returns the current TransformNode
  7683. */
  7684. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7685. /**
  7686. * Returns the mesh pivot matrix.
  7687. * Default : Identity.
  7688. * @returns the matrix
  7689. */
  7690. getPivotMatrix(): Matrix;
  7691. /**
  7692. * Prevents the World matrix to be computed any longer.
  7693. * @returns the TransformNode.
  7694. */
  7695. freezeWorldMatrix(): TransformNode;
  7696. /**
  7697. * Allows back the World matrix computation.
  7698. * @returns the TransformNode.
  7699. */
  7700. unfreezeWorldMatrix(): this;
  7701. /**
  7702. * True if the World matrix has been frozen.
  7703. */
  7704. readonly isWorldMatrixFrozen: boolean;
  7705. /**
  7706. * Retuns the mesh absolute position in the World.
  7707. * @returns a Vector3.
  7708. */
  7709. getAbsolutePosition(): Vector3;
  7710. /**
  7711. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7712. * @param absolutePosition the absolute position to set
  7713. * @returns the TransformNode.
  7714. */
  7715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7716. /**
  7717. * Sets the mesh position in its local space.
  7718. * @param vector3 the position to set in localspace
  7719. * @returns the TransformNode.
  7720. */
  7721. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7722. /**
  7723. * Returns the mesh position in the local space from the current World matrix values.
  7724. * @returns a new Vector3.
  7725. */
  7726. getPositionExpressedInLocalSpace(): Vector3;
  7727. /**
  7728. * Translates the mesh along the passed Vector3 in its local space.
  7729. * @param vector3 the distance to translate in localspace
  7730. * @returns the TransformNode.
  7731. */
  7732. locallyTranslate(vector3: Vector3): TransformNode;
  7733. private static _lookAtVectorCache;
  7734. /**
  7735. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7736. * @param targetPoint the position (must be in same space as current mesh) to look at
  7737. * @param yawCor optional yaw (y-axis) correction in radians
  7738. * @param pitchCor optional pitch (x-axis) correction in radians
  7739. * @param rollCor optional roll (z-axis) correction in radians
  7740. * @param space the choosen space of the target
  7741. * @returns the TransformNode.
  7742. */
  7743. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7744. /**
  7745. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7746. * This Vector3 is expressed in the World space.
  7747. * @param localAxis axis to rotate
  7748. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7749. */
  7750. getDirection(localAxis: Vector3): Vector3;
  7751. /**
  7752. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7753. * localAxis is expressed in the mesh local space.
  7754. * result is computed in the Wordl space from the mesh World matrix.
  7755. * @param localAxis axis to rotate
  7756. * @param result the resulting transformnode
  7757. * @returns this TransformNode.
  7758. */
  7759. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7760. /**
  7761. * Sets this transform node rotation to the given local axis.
  7762. * @param localAxis the axis in local space
  7763. * @param yawCor optional yaw (y-axis) correction in radians
  7764. * @param pitchCor optional pitch (x-axis) correction in radians
  7765. * @param rollCor optional roll (z-axis) correction in radians
  7766. * @returns this TransformNode
  7767. */
  7768. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7769. /**
  7770. * Sets a new pivot point to the current node
  7771. * @param point defines the new pivot point to use
  7772. * @param space defines if the point is in world or local space (local by default)
  7773. * @returns the current TransformNode
  7774. */
  7775. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7776. /**
  7777. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7778. * @returns the pivot point
  7779. */
  7780. getPivotPoint(): Vector3;
  7781. /**
  7782. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7783. * @param result the vector3 to store the result
  7784. * @returns this TransformNode.
  7785. */
  7786. getPivotPointToRef(result: Vector3): TransformNode;
  7787. /**
  7788. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7789. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7790. */
  7791. getAbsolutePivotPoint(): Vector3;
  7792. /**
  7793. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7794. * @param result vector3 to store the result
  7795. * @returns this TransformNode.
  7796. */
  7797. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7798. /**
  7799. * Defines the passed node as the parent of the current node.
  7800. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7801. * @see https://doc.babylonjs.com/how_to/parenting
  7802. * @param node the node ot set as the parent
  7803. * @returns this TransformNode.
  7804. */
  7805. setParent(node: Nullable<Node>): TransformNode;
  7806. private _nonUniformScaling;
  7807. /**
  7808. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7809. */
  7810. readonly nonUniformScaling: boolean;
  7811. /** @hidden */
  7812. _updateNonUniformScalingState(value: boolean): boolean;
  7813. /**
  7814. * Attach the current TransformNode to another TransformNode associated with a bone
  7815. * @param bone Bone affecting the TransformNode
  7816. * @param affectedTransformNode TransformNode associated with the bone
  7817. * @returns this object
  7818. */
  7819. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7820. /**
  7821. * Detach the transform node if its associated with a bone
  7822. * @returns this object
  7823. */
  7824. detachFromBone(): TransformNode;
  7825. private static _rotationAxisCache;
  7826. /**
  7827. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7828. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7830. * The passed axis is also normalized.
  7831. * @param axis the axis to rotate around
  7832. * @param amount the amount to rotate in radians
  7833. * @param space Space to rotate in (Default: local)
  7834. * @returns the TransformNode.
  7835. */
  7836. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7837. /**
  7838. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7839. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7840. * The passed axis is also normalized. .
  7841. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7842. * @param point the point to rotate around
  7843. * @param axis the axis to rotate around
  7844. * @param amount the amount to rotate in radians
  7845. * @returns the TransformNode
  7846. */
  7847. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7848. /**
  7849. * Translates the mesh along the axis vector for the passed distance in the given space.
  7850. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7851. * @param axis the axis to translate in
  7852. * @param distance the distance to translate
  7853. * @param space Space to rotate in (Default: local)
  7854. * @returns the TransformNode.
  7855. */
  7856. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7857. /**
  7858. * Adds a rotation step to the mesh current rotation.
  7859. * x, y, z are Euler angles expressed in radians.
  7860. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7861. * This means this rotation is made in the mesh local space only.
  7862. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7863. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7864. * ```javascript
  7865. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7866. * ```
  7867. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7868. * 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.
  7869. * @param x Rotation to add
  7870. * @param y Rotation to add
  7871. * @param z Rotation to add
  7872. * @returns the TransformNode.
  7873. */
  7874. addRotation(x: number, y: number, z: number): TransformNode;
  7875. /**
  7876. * Computes the world matrix of the node
  7877. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7878. * @returns the world matrix
  7879. */
  7880. computeWorldMatrix(force?: boolean): Matrix;
  7881. protected _afterComputeWorldMatrix(): void;
  7882. /**
  7883. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7884. * @param func callback function to add
  7885. *
  7886. * @returns the TransformNode.
  7887. */
  7888. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7889. /**
  7890. * Removes a registered callback function.
  7891. * @param func callback function to remove
  7892. * @returns the TransformNode.
  7893. */
  7894. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7895. /**
  7896. * Gets the position of the current mesh in camera space
  7897. * @param camera defines the camera to use
  7898. * @returns a position
  7899. */
  7900. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7901. /**
  7902. * Returns the distance from the mesh to the active camera
  7903. * @param camera defines the camera to use
  7904. * @returns the distance
  7905. */
  7906. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7907. /**
  7908. * Clone the current transform node
  7909. * @param name Name of the new clone
  7910. * @param newParent New parent for the clone
  7911. * @param doNotCloneChildren Do not clone children hierarchy
  7912. * @returns the new transform node
  7913. */
  7914. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7915. /**
  7916. * Serializes the objects information.
  7917. * @param currentSerializationObject defines the object to serialize in
  7918. * @returns the serialized object
  7919. */
  7920. serialize(currentSerializationObject?: any): any;
  7921. /**
  7922. * Returns a new TransformNode object parsed from the source provided.
  7923. * @param parsedTransformNode is the source.
  7924. * @param scene the scne the object belongs to
  7925. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7926. * @returns a new TransformNode object parsed from the source provided.
  7927. */
  7928. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7929. /**
  7930. * Get all child-transformNodes of this node
  7931. * @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
  7932. * @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
  7933. * @returns an array of TransformNode
  7934. */
  7935. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7936. /**
  7937. * Releases resources associated with this transform node.
  7938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7940. */
  7941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7942. }
  7943. }
  7944. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7945. /**
  7946. * Class used to override all child animations of a given target
  7947. */
  7948. export class AnimationPropertiesOverride {
  7949. /**
  7950. * Gets or sets a value indicating if animation blending must be used
  7951. */
  7952. enableBlending: boolean;
  7953. /**
  7954. * Gets or sets the blending speed to use when enableBlending is true
  7955. */
  7956. blendingSpeed: number;
  7957. /**
  7958. * Gets or sets the default loop mode to use
  7959. */
  7960. loopMode: number;
  7961. }
  7962. }
  7963. declare module "babylonjs/Bones/bone" {
  7964. import { Skeleton } from "babylonjs/Bones/skeleton";
  7965. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7966. import { Nullable } from "babylonjs/types";
  7967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7968. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7969. import { Node } from "babylonjs/node";
  7970. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7971. /**
  7972. * Class used to store bone information
  7973. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7974. */
  7975. export class Bone extends Node {
  7976. /**
  7977. * defines the bone name
  7978. */
  7979. name: string;
  7980. private static _tmpVecs;
  7981. private static _tmpQuat;
  7982. private static _tmpMats;
  7983. /**
  7984. * Gets the list of child bones
  7985. */
  7986. children: Bone[];
  7987. /** Gets the animations associated with this bone */
  7988. animations: import("babylonjs/Animations/animation").Animation[];
  7989. /**
  7990. * Gets or sets bone length
  7991. */
  7992. length: number;
  7993. /**
  7994. * @hidden Internal only
  7995. * Set this value to map this bone to a different index in the transform matrices
  7996. * Set this value to -1 to exclude the bone from the transform matrices
  7997. */
  7998. _index: Nullable<number>;
  7999. private _skeleton;
  8000. private _localMatrix;
  8001. private _restPose;
  8002. private _baseMatrix;
  8003. private _absoluteTransform;
  8004. private _invertedAbsoluteTransform;
  8005. private _parent;
  8006. private _scalingDeterminant;
  8007. private _worldTransform;
  8008. private _localScaling;
  8009. private _localRotation;
  8010. private _localPosition;
  8011. private _needToDecompose;
  8012. private _needToCompose;
  8013. /** @hidden */
  8014. _linkedTransformNode: Nullable<TransformNode>;
  8015. /** @hidden */
  8016. /** @hidden */
  8017. _matrix: Matrix;
  8018. /**
  8019. * Create a new bone
  8020. * @param name defines the bone name
  8021. * @param skeleton defines the parent skeleton
  8022. * @param parentBone defines the parent (can be null if the bone is the root)
  8023. * @param localMatrix defines the local matrix
  8024. * @param restPose defines the rest pose matrix
  8025. * @param baseMatrix defines the base matrix
  8026. * @param index defines index of the bone in the hiearchy
  8027. */
  8028. constructor(
  8029. /**
  8030. * defines the bone name
  8031. */
  8032. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8033. /**
  8034. * Gets the current object class name.
  8035. * @return the class name
  8036. */
  8037. getClassName(): string;
  8038. /**
  8039. * Gets the parent skeleton
  8040. * @returns a skeleton
  8041. */
  8042. getSkeleton(): Skeleton;
  8043. /**
  8044. * Gets parent bone
  8045. * @returns a bone or null if the bone is the root of the bone hierarchy
  8046. */
  8047. getParent(): Nullable<Bone>;
  8048. /**
  8049. * Returns an array containing the root bones
  8050. * @returns an array containing the root bones
  8051. */
  8052. getChildren(): Array<Bone>;
  8053. /**
  8054. * Sets the parent bone
  8055. * @param parent defines the parent (can be null if the bone is the root)
  8056. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8057. */
  8058. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8059. /**
  8060. * Gets the local matrix
  8061. * @returns a matrix
  8062. */
  8063. getLocalMatrix(): Matrix;
  8064. /**
  8065. * Gets the base matrix (initial matrix which remains unchanged)
  8066. * @returns a matrix
  8067. */
  8068. getBaseMatrix(): Matrix;
  8069. /**
  8070. * Gets the rest pose matrix
  8071. * @returns a matrix
  8072. */
  8073. getRestPose(): Matrix;
  8074. /**
  8075. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8076. */
  8077. getWorldMatrix(): Matrix;
  8078. /**
  8079. * Sets the local matrix to rest pose matrix
  8080. */
  8081. returnToRest(): void;
  8082. /**
  8083. * Gets the inverse of the absolute transform matrix.
  8084. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8085. * @returns a matrix
  8086. */
  8087. getInvertedAbsoluteTransform(): Matrix;
  8088. /**
  8089. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8090. * @returns a matrix
  8091. */
  8092. getAbsoluteTransform(): Matrix;
  8093. /**
  8094. * Links with the given transform node.
  8095. * The local matrix of this bone is copied from the transform node every frame.
  8096. * @param transformNode defines the transform node to link to
  8097. */
  8098. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8099. /** Gets or sets current position (in local space) */
  8100. position: Vector3;
  8101. /** Gets or sets current rotation (in local space) */
  8102. rotation: Vector3;
  8103. /** Gets or sets current rotation quaternion (in local space) */
  8104. rotationQuaternion: Quaternion;
  8105. /** Gets or sets current scaling (in local space) */
  8106. scaling: Vector3;
  8107. /**
  8108. * Gets the animation properties override
  8109. */
  8110. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8111. private _decompose;
  8112. private _compose;
  8113. /**
  8114. * Update the base and local matrices
  8115. * @param matrix defines the new base or local matrix
  8116. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8117. * @param updateLocalMatrix defines if the local matrix should be updated
  8118. */
  8119. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8120. /** @hidden */
  8121. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8122. /**
  8123. * Flag the bone as dirty (Forcing it to update everything)
  8124. */
  8125. markAsDirty(): void;
  8126. private _markAsDirtyAndCompose;
  8127. private _markAsDirtyAndDecompose;
  8128. /**
  8129. * Translate the bone in local or world space
  8130. * @param vec The amount to translate the bone
  8131. * @param space The space that the translation is in
  8132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8133. */
  8134. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8135. /**
  8136. * Set the postion of the bone in local or world space
  8137. * @param position The position to set the bone
  8138. * @param space The space that the position is in
  8139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8140. */
  8141. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8142. /**
  8143. * Set the absolute position of the bone (world space)
  8144. * @param position The position to set the bone
  8145. * @param mesh The mesh that this bone is attached to
  8146. */
  8147. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8148. /**
  8149. * Scale the bone on the x, y and z axes (in local space)
  8150. * @param x The amount to scale the bone on the x axis
  8151. * @param y The amount to scale the bone on the y axis
  8152. * @param z The amount to scale the bone on the z axis
  8153. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8154. */
  8155. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8156. /**
  8157. * Set the bone scaling in local space
  8158. * @param scale defines the scaling vector
  8159. */
  8160. setScale(scale: Vector3): void;
  8161. /**
  8162. * Gets the current scaling in local space
  8163. * @returns the current scaling vector
  8164. */
  8165. getScale(): Vector3;
  8166. /**
  8167. * Gets the current scaling in local space and stores it in a target vector
  8168. * @param result defines the target vector
  8169. */
  8170. getScaleToRef(result: Vector3): void;
  8171. /**
  8172. * Set the yaw, pitch, and roll of the bone in local or world space
  8173. * @param yaw The rotation of the bone on the y axis
  8174. * @param pitch The rotation of the bone on the x axis
  8175. * @param roll The rotation of the bone on the z axis
  8176. * @param space The space that the axes of rotation are in
  8177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8178. */
  8179. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8180. /**
  8181. * Add a rotation to the bone on an axis in local or world space
  8182. * @param axis The axis to rotate the bone on
  8183. * @param amount The amount to rotate the bone
  8184. * @param space The space that the axis is in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. */
  8187. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8188. /**
  8189. * Set the rotation of the bone to a particular axis angle in local or world space
  8190. * @param axis The axis to rotate the bone on
  8191. * @param angle The angle that the bone should be rotated to
  8192. * @param space The space that the axis is in
  8193. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8194. */
  8195. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8196. /**
  8197. * Set the euler rotation of the bone in local of world space
  8198. * @param rotation The euler rotation that the bone should be set to
  8199. * @param space The space that the rotation is in
  8200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8201. */
  8202. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8203. /**
  8204. * Set the quaternion rotation of the bone in local of world space
  8205. * @param quat The quaternion rotation that the bone should be set to
  8206. * @param space The space that the rotation is in
  8207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8208. */
  8209. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8210. /**
  8211. * Set the rotation matrix of the bone in local of world space
  8212. * @param rotMat The rotation matrix that the bone should be set to
  8213. * @param space The space that the rotation is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. */
  8216. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8217. private _rotateWithMatrix;
  8218. private _getNegativeRotationToRef;
  8219. /**
  8220. * Get the position of the bone in local or world space
  8221. * @param space The space that the returned position is in
  8222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8223. * @returns The position of the bone
  8224. */
  8225. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8226. /**
  8227. * Copy the position of the bone to a vector3 in local or world space
  8228. * @param space The space that the returned position is in
  8229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8230. * @param result The vector3 to copy the position to
  8231. */
  8232. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8233. /**
  8234. * Get the absolute position of the bone (world space)
  8235. * @param mesh The mesh that this bone is attached to
  8236. * @returns The absolute position of the bone
  8237. */
  8238. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8239. /**
  8240. * Copy the absolute position of the bone (world space) to the result param
  8241. * @param mesh The mesh that this bone is attached to
  8242. * @param result The vector3 to copy the absolute position to
  8243. */
  8244. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8245. /**
  8246. * Compute the absolute transforms of this bone and its children
  8247. */
  8248. computeAbsoluteTransforms(): void;
  8249. /**
  8250. * Get the world direction from an axis that is in the local space of the bone
  8251. * @param localAxis The local direction that is used to compute the world direction
  8252. * @param mesh The mesh that this bone is attached to
  8253. * @returns The world direction
  8254. */
  8255. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8256. /**
  8257. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8258. * @param localAxis The local direction that is used to compute the world direction
  8259. * @param mesh The mesh that this bone is attached to
  8260. * @param result The vector3 that the world direction will be copied to
  8261. */
  8262. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8263. /**
  8264. * Get the euler rotation of the bone in local or world space
  8265. * @param space The space that the rotation should be in
  8266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8267. * @returns The euler rotation
  8268. */
  8269. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8270. /**
  8271. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8272. * @param space The space that the rotation should be in
  8273. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8274. * @param result The vector3 that the rotation should be copied to
  8275. */
  8276. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8277. /**
  8278. * Get the quaternion rotation of the bone in either local or world space
  8279. * @param space The space that the rotation should be in
  8280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8281. * @returns The quaternion rotation
  8282. */
  8283. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8284. /**
  8285. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8286. * @param space The space that the rotation should be in
  8287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8288. * @param result The quaternion that the rotation should be copied to
  8289. */
  8290. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8291. /**
  8292. * Get the rotation matrix of the bone in local or world space
  8293. * @param space The space that the rotation should be in
  8294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8295. * @returns The rotation matrix
  8296. */
  8297. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8298. /**
  8299. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8300. * @param space The space that the rotation should be in
  8301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8302. * @param result The quaternion that the rotation should be copied to
  8303. */
  8304. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8305. /**
  8306. * Get the world position of a point that is in the local space of the bone
  8307. * @param position The local position
  8308. * @param mesh The mesh that this bone is attached to
  8309. * @returns The world position
  8310. */
  8311. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8312. /**
  8313. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8314. * @param position The local position
  8315. * @param mesh The mesh that this bone is attached to
  8316. * @param result The vector3 that the world position should be copied to
  8317. */
  8318. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8319. /**
  8320. * Get the local position of a point that is in world space
  8321. * @param position The world position
  8322. * @param mesh The mesh that this bone is attached to
  8323. * @returns The local position
  8324. */
  8325. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8326. /**
  8327. * Get the local position of a point that is in world space and copy it to the result param
  8328. * @param position The world position
  8329. * @param mesh The mesh that this bone is attached to
  8330. * @param result The vector3 that the local position should be copied to
  8331. */
  8332. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8333. }
  8334. }
  8335. declare module "babylonjs/Misc/iInspectable" {
  8336. /**
  8337. * Enum that determines the text-wrapping mode to use.
  8338. */
  8339. export enum InspectableType {
  8340. /**
  8341. * Checkbox for booleans
  8342. */
  8343. Checkbox = 0,
  8344. /**
  8345. * Sliders for numbers
  8346. */
  8347. Slider = 1,
  8348. /**
  8349. * Vector3
  8350. */
  8351. Vector3 = 2,
  8352. /**
  8353. * Quaternions
  8354. */
  8355. Quaternion = 3,
  8356. /**
  8357. * Color3
  8358. */
  8359. Color3 = 4
  8360. }
  8361. /**
  8362. * Interface used to define custom inspectable properties.
  8363. * This interface is used by the inspector to display custom property grids
  8364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8365. */
  8366. export interface IInspectable {
  8367. /**
  8368. * Gets the label to display
  8369. */
  8370. label: string;
  8371. /**
  8372. * Gets the name of the property to edit
  8373. */
  8374. propertyName: string;
  8375. /**
  8376. * Gets the type of the editor to use
  8377. */
  8378. type: InspectableType;
  8379. /**
  8380. * Gets the minimum value of the property when using in "slider" mode
  8381. */
  8382. min?: number;
  8383. /**
  8384. * Gets the maximum value of the property when using in "slider" mode
  8385. */
  8386. max?: number;
  8387. /**
  8388. * Gets the setp to use when using in "slider" mode
  8389. */
  8390. step?: number;
  8391. }
  8392. }
  8393. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8394. import { Nullable } from "babylonjs/types";
  8395. import { Scene } from "babylonjs/scene";
  8396. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8398. /**
  8399. * Class for creating a cube texture
  8400. */
  8401. export class CubeTexture extends BaseTexture {
  8402. private _delayedOnLoad;
  8403. /**
  8404. * The url of the texture
  8405. */
  8406. url: string;
  8407. /**
  8408. * Gets or sets the center of the bounding box associated with the cube texture.
  8409. * It must define where the camera used to render the texture was set
  8410. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8411. */
  8412. boundingBoxPosition: Vector3;
  8413. private _boundingBoxSize;
  8414. /**
  8415. * Gets or sets the size of the bounding box associated with the cube texture
  8416. * When defined, the cubemap will switch to local mode
  8417. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8418. * @example https://www.babylonjs-playground.com/#RNASML
  8419. */
  8420. /**
  8421. * Returns the bounding box size
  8422. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8423. */
  8424. boundingBoxSize: Vector3;
  8425. protected _rotationY: number;
  8426. /**
  8427. * Sets texture matrix rotation angle around Y axis in radians.
  8428. */
  8429. /**
  8430. * Gets texture matrix rotation angle around Y axis radians.
  8431. */
  8432. rotationY: number;
  8433. /**
  8434. * Are mip maps generated for this texture or not.
  8435. */
  8436. readonly noMipmap: boolean;
  8437. private _noMipmap;
  8438. private _files;
  8439. private _extensions;
  8440. private _textureMatrix;
  8441. private _format;
  8442. private _createPolynomials;
  8443. /** @hidden */
  8444. _prefiltered: boolean;
  8445. /**
  8446. * Creates a cube texture from an array of image urls
  8447. * @param files defines an array of image urls
  8448. * @param scene defines the hosting scene
  8449. * @param noMipmap specifies if mip maps are not used
  8450. * @returns a cube texture
  8451. */
  8452. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8453. /**
  8454. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8455. * @param url defines the url of the prefiltered texture
  8456. * @param scene defines the scene the texture is attached to
  8457. * @param forcedExtension defines the extension of the file if different from the url
  8458. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8459. * @return the prefiltered texture
  8460. */
  8461. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8462. /**
  8463. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8464. * as prefiltered data.
  8465. * @param rootUrl defines the url of the texture or the root name of the six images
  8466. * @param scene defines the scene the texture is attached to
  8467. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8468. * @param noMipmap defines if mipmaps should be created or not
  8469. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8470. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8471. * @param onError defines a callback triggered in case of error during load
  8472. * @param format defines the internal format to use for the texture once loaded
  8473. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8474. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8475. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8476. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8477. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8478. * @return the cube texture
  8479. */
  8480. 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);
  8481. /**
  8482. * Get the current class name of the texture useful for serialization or dynamic coding.
  8483. * @returns "CubeTexture"
  8484. */
  8485. getClassName(): string;
  8486. /**
  8487. * Update the url (and optional buffer) of this texture if url was null during construction.
  8488. * @param url the url of the texture
  8489. * @param forcedExtension defines the extension to use
  8490. * @param onLoad callback called when the texture is loaded (defaults to null)
  8491. */
  8492. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8493. /**
  8494. * Delays loading of the cube texture
  8495. * @param forcedExtension defines the extension to use
  8496. */
  8497. delayLoad(forcedExtension?: string): void;
  8498. /**
  8499. * Returns the reflection texture matrix
  8500. * @returns the reflection texture matrix
  8501. */
  8502. getReflectionTextureMatrix(): Matrix;
  8503. /**
  8504. * Sets the reflection texture matrix
  8505. * @param value Reflection texture matrix
  8506. */
  8507. setReflectionTextureMatrix(value: Matrix): void;
  8508. /**
  8509. * Parses text to create a cube texture
  8510. * @param parsedTexture define the serialized text to read from
  8511. * @param scene defines the hosting scene
  8512. * @param rootUrl defines the root url of the cube texture
  8513. * @returns a cube texture
  8514. */
  8515. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8516. /**
  8517. * Makes a clone, or deep copy, of the cube texture
  8518. * @returns a new cube texture
  8519. */
  8520. clone(): CubeTexture;
  8521. }
  8522. }
  8523. declare module "babylonjs/Shaders/postprocess.vertex" {
  8524. /** @hidden */
  8525. export var postprocessVertexShader: {
  8526. name: string;
  8527. shader: string;
  8528. };
  8529. }
  8530. declare module "babylonjs/Cameras/targetCamera" {
  8531. import { Nullable } from "babylonjs/types";
  8532. import { Camera } from "babylonjs/Cameras/camera";
  8533. import { Scene } from "babylonjs/scene";
  8534. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8535. /**
  8536. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8537. * This is the base of the follow, arc rotate cameras and Free camera
  8538. * @see http://doc.babylonjs.com/features/cameras
  8539. */
  8540. export class TargetCamera extends Camera {
  8541. private static _RigCamTransformMatrix;
  8542. private static _TargetTransformMatrix;
  8543. private static _TargetFocalPoint;
  8544. /**
  8545. * Define the current direction the camera is moving to
  8546. */
  8547. cameraDirection: Vector3;
  8548. /**
  8549. * Define the current rotation the camera is rotating to
  8550. */
  8551. cameraRotation: Vector2;
  8552. /**
  8553. * When set, the up vector of the camera will be updated by the rotation of the camera
  8554. */
  8555. updateUpVectorFromRotation: boolean;
  8556. private _tmpQuaternion;
  8557. /**
  8558. * Define the current rotation of the camera
  8559. */
  8560. rotation: Vector3;
  8561. /**
  8562. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8563. */
  8564. rotationQuaternion: Quaternion;
  8565. /**
  8566. * Define the current speed of the camera
  8567. */
  8568. speed: number;
  8569. /**
  8570. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8571. * around all axis.
  8572. */
  8573. noRotationConstraint: boolean;
  8574. /**
  8575. * Define the current target of the camera as an object or a position.
  8576. */
  8577. lockedTarget: any;
  8578. /** @hidden */
  8579. _currentTarget: Vector3;
  8580. /** @hidden */
  8581. _initialFocalDistance: number;
  8582. /** @hidden */
  8583. _viewMatrix: Matrix;
  8584. /** @hidden */
  8585. _camMatrix: Matrix;
  8586. /** @hidden */
  8587. _cameraTransformMatrix: Matrix;
  8588. /** @hidden */
  8589. _cameraRotationMatrix: Matrix;
  8590. /** @hidden */
  8591. _referencePoint: Vector3;
  8592. /** @hidden */
  8593. _transformedReferencePoint: Vector3;
  8594. protected _globalCurrentTarget: Vector3;
  8595. protected _globalCurrentUpVector: Vector3;
  8596. /** @hidden */
  8597. _reset: () => void;
  8598. private _defaultUp;
  8599. /**
  8600. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8601. * This is the base of the follow, arc rotate cameras and Free camera
  8602. * @see http://doc.babylonjs.com/features/cameras
  8603. * @param name Defines the name of the camera in the scene
  8604. * @param position Defines the start position of the camera in the scene
  8605. * @param scene Defines the scene the camera belongs to
  8606. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8607. */
  8608. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8609. /**
  8610. * Gets the position in front of the camera at a given distance.
  8611. * @param distance The distance from the camera we want the position to be
  8612. * @returns the position
  8613. */
  8614. getFrontPosition(distance: number): Vector3;
  8615. /** @hidden */
  8616. _getLockedTargetPosition(): Nullable<Vector3>;
  8617. private _storedPosition;
  8618. private _storedRotation;
  8619. private _storedRotationQuaternion;
  8620. /**
  8621. * Store current camera state of the camera (fov, position, rotation, etc..)
  8622. * @returns the camera
  8623. */
  8624. storeState(): Camera;
  8625. /**
  8626. * Restored camera state. You must call storeState() first
  8627. * @returns whether it was successful or not
  8628. * @hidden
  8629. */
  8630. _restoreStateValues(): boolean;
  8631. /** @hidden */
  8632. _initCache(): void;
  8633. /** @hidden */
  8634. _updateCache(ignoreParentClass?: boolean): void;
  8635. /** @hidden */
  8636. _isSynchronizedViewMatrix(): boolean;
  8637. /** @hidden */
  8638. _computeLocalCameraSpeed(): number;
  8639. /**
  8640. * Defines the target the camera should look at.
  8641. * This will automatically adapt alpha beta and radius to fit within the new target.
  8642. * @param target Defines the new target as a Vector or a mesh
  8643. */
  8644. setTarget(target: Vector3): void;
  8645. /**
  8646. * Return the current target position of the camera. This value is expressed in local space.
  8647. * @returns the target position
  8648. */
  8649. getTarget(): Vector3;
  8650. /** @hidden */
  8651. _decideIfNeedsToMove(): boolean;
  8652. /** @hidden */
  8653. _updatePosition(): void;
  8654. /** @hidden */
  8655. _checkInputs(): void;
  8656. protected _updateCameraRotationMatrix(): void;
  8657. /**
  8658. * 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)
  8659. * @returns the current camera
  8660. */
  8661. private _rotateUpVectorWithCameraRotationMatrix;
  8662. private _cachedRotationZ;
  8663. private _cachedQuaternionRotationZ;
  8664. /** @hidden */
  8665. _getViewMatrix(): Matrix;
  8666. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8667. /**
  8668. * @hidden
  8669. */
  8670. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8671. /**
  8672. * @hidden
  8673. */
  8674. _updateRigCameras(): void;
  8675. private _getRigCamPositionAndTarget;
  8676. /**
  8677. * Gets the current object class name.
  8678. * @return the class name
  8679. */
  8680. getClassName(): string;
  8681. }
  8682. }
  8683. declare module "babylonjs/Cameras/cameraInputsManager" {
  8684. import { Nullable } from "babylonjs/types";
  8685. import { Camera } from "babylonjs/Cameras/camera";
  8686. /**
  8687. * @ignore
  8688. * This is a list of all the different input types that are available in the application.
  8689. * Fo instance: ArcRotateCameraGamepadInput...
  8690. */
  8691. export var CameraInputTypes: {};
  8692. /**
  8693. * This is the contract to implement in order to create a new input class.
  8694. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8695. */
  8696. export interface ICameraInput<TCamera extends Camera> {
  8697. /**
  8698. * Defines the camera the input is attached to.
  8699. */
  8700. camera: Nullable<TCamera>;
  8701. /**
  8702. * Gets the class name of the current intput.
  8703. * @returns the class name
  8704. */
  8705. getClassName(): string;
  8706. /**
  8707. * Get the friendly name associated with the input class.
  8708. * @returns the input friendly name
  8709. */
  8710. getSimpleName(): string;
  8711. /**
  8712. * Attach the input controls to a specific dom element to get the input from.
  8713. * @param element Defines the element the controls should be listened from
  8714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8715. */
  8716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8717. /**
  8718. * Detach the current controls from the specified dom element.
  8719. * @param element Defines the element to stop listening the inputs from
  8720. */
  8721. detachControl(element: Nullable<HTMLElement>): void;
  8722. /**
  8723. * Update the current camera state depending on the inputs that have been used this frame.
  8724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8725. */
  8726. checkInputs?: () => void;
  8727. }
  8728. /**
  8729. * Represents a map of input types to input instance or input index to input instance.
  8730. */
  8731. export interface CameraInputsMap<TCamera extends Camera> {
  8732. /**
  8733. * Accessor to the input by input type.
  8734. */
  8735. [name: string]: ICameraInput<TCamera>;
  8736. /**
  8737. * Accessor to the input by input index.
  8738. */
  8739. [idx: number]: ICameraInput<TCamera>;
  8740. }
  8741. /**
  8742. * This represents the input manager used within a camera.
  8743. * It helps dealing with all the different kind of input attached to a camera.
  8744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8745. */
  8746. export class CameraInputsManager<TCamera extends Camera> {
  8747. /**
  8748. * Defines the list of inputs attahed to the camera.
  8749. */
  8750. attached: CameraInputsMap<TCamera>;
  8751. /**
  8752. * Defines the dom element the camera is collecting inputs from.
  8753. * This is null if the controls have not been attached.
  8754. */
  8755. attachedElement: Nullable<HTMLElement>;
  8756. /**
  8757. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8758. */
  8759. noPreventDefault: boolean;
  8760. /**
  8761. * Defined the camera the input manager belongs to.
  8762. */
  8763. camera: TCamera;
  8764. /**
  8765. * Update the current camera state depending on the inputs that have been used this frame.
  8766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8767. */
  8768. checkInputs: () => void;
  8769. /**
  8770. * Instantiate a new Camera Input Manager.
  8771. * @param camera Defines the camera the input manager blongs to
  8772. */
  8773. constructor(camera: TCamera);
  8774. /**
  8775. * Add an input method to a camera
  8776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8777. * @param input camera input method
  8778. */
  8779. add(input: ICameraInput<TCamera>): void;
  8780. /**
  8781. * Remove a specific input method from a camera
  8782. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8783. * @param inputToRemove camera input method
  8784. */
  8785. remove(inputToRemove: ICameraInput<TCamera>): void;
  8786. /**
  8787. * Remove a specific input type from a camera
  8788. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8789. * @param inputType the type of the input to remove
  8790. */
  8791. removeByType(inputType: string): void;
  8792. private _addCheckInputs;
  8793. /**
  8794. * Attach the input controls to the currently attached dom element to listen the events from.
  8795. * @param input Defines the input to attach
  8796. */
  8797. attachInput(input: ICameraInput<TCamera>): void;
  8798. /**
  8799. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8800. * @param element Defines the dom element to collect the events from
  8801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8802. */
  8803. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8804. /**
  8805. * Detach the current manager inputs controls from a specific dom element.
  8806. * @param element Defines the dom element to collect the events from
  8807. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8808. */
  8809. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8810. /**
  8811. * Rebuild the dynamic inputCheck function from the current list of
  8812. * defined inputs in the manager.
  8813. */
  8814. rebuildInputCheck(): void;
  8815. /**
  8816. * Remove all attached input methods from a camera
  8817. */
  8818. clear(): void;
  8819. /**
  8820. * Serialize the current input manager attached to a camera.
  8821. * This ensures than once parsed,
  8822. * the input associated to the camera will be identical to the current ones
  8823. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8824. */
  8825. serialize(serializedCamera: any): void;
  8826. /**
  8827. * Parses an input manager serialized JSON to restore the previous list of inputs
  8828. * and states associated to a camera.
  8829. * @param parsedCamera Defines the JSON to parse
  8830. */
  8831. parse(parsedCamera: any): void;
  8832. }
  8833. }
  8834. declare module "babylonjs/Events/keyboardEvents" {
  8835. /**
  8836. * Gather the list of keyboard event types as constants.
  8837. */
  8838. export class KeyboardEventTypes {
  8839. /**
  8840. * The keydown event is fired when a key becomes active (pressed).
  8841. */
  8842. static readonly KEYDOWN: number;
  8843. /**
  8844. * The keyup event is fired when a key has been released.
  8845. */
  8846. static readonly KEYUP: number;
  8847. }
  8848. /**
  8849. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8850. */
  8851. export class KeyboardInfo {
  8852. /**
  8853. * Defines the type of event (KeyboardEventTypes)
  8854. */
  8855. type: number;
  8856. /**
  8857. * Defines the related dom event
  8858. */
  8859. event: KeyboardEvent;
  8860. /**
  8861. * Instantiates a new keyboard info.
  8862. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8863. * @param type Defines the type of event (KeyboardEventTypes)
  8864. * @param event Defines the related dom event
  8865. */
  8866. constructor(
  8867. /**
  8868. * Defines the type of event (KeyboardEventTypes)
  8869. */
  8870. type: number,
  8871. /**
  8872. * Defines the related dom event
  8873. */
  8874. event: KeyboardEvent);
  8875. }
  8876. /**
  8877. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8878. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8879. */
  8880. export class KeyboardInfoPre extends KeyboardInfo {
  8881. /**
  8882. * Defines the type of event (KeyboardEventTypes)
  8883. */
  8884. type: number;
  8885. /**
  8886. * Defines the related dom event
  8887. */
  8888. event: KeyboardEvent;
  8889. /**
  8890. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8891. */
  8892. skipOnPointerObservable: boolean;
  8893. /**
  8894. * Instantiates a new keyboard pre info.
  8895. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8896. * @param type Defines the type of event (KeyboardEventTypes)
  8897. * @param event Defines the related dom event
  8898. */
  8899. constructor(
  8900. /**
  8901. * Defines the type of event (KeyboardEventTypes)
  8902. */
  8903. type: number,
  8904. /**
  8905. * Defines the related dom event
  8906. */
  8907. event: KeyboardEvent);
  8908. }
  8909. }
  8910. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8911. import { Nullable } from "babylonjs/types";
  8912. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8913. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8914. /**
  8915. * Manage the keyboard inputs to control the movement of a free camera.
  8916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8917. */
  8918. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8919. /**
  8920. * Defines the camera the input is attached to.
  8921. */
  8922. camera: FreeCamera;
  8923. /**
  8924. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8925. */
  8926. keysUp: number[];
  8927. /**
  8928. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8929. */
  8930. keysDown: number[];
  8931. /**
  8932. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8933. */
  8934. keysLeft: number[];
  8935. /**
  8936. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8937. */
  8938. keysRight: number[];
  8939. private _keys;
  8940. private _onCanvasBlurObserver;
  8941. private _onKeyboardObserver;
  8942. private _engine;
  8943. private _scene;
  8944. /**
  8945. * Attach the input controls to a specific dom element to get the input from.
  8946. * @param element Defines the element the controls should be listened from
  8947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8948. */
  8949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8950. /**
  8951. * Detach the current controls from the specified dom element.
  8952. * @param element Defines the element to stop listening the inputs from
  8953. */
  8954. detachControl(element: Nullable<HTMLElement>): void;
  8955. /**
  8956. * Update the current camera state depending on the inputs that have been used this frame.
  8957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8958. */
  8959. checkInputs(): void;
  8960. /**
  8961. * Gets the class name of the current intput.
  8962. * @returns the class name
  8963. */
  8964. getClassName(): string;
  8965. /** @hidden */
  8966. _onLostFocus(): void;
  8967. /**
  8968. * Get the friendly name associated with the input class.
  8969. * @returns the input friendly name
  8970. */
  8971. getSimpleName(): string;
  8972. }
  8973. }
  8974. declare module "babylonjs/Lights/shadowLight" {
  8975. import { Camera } from "babylonjs/Cameras/camera";
  8976. import { Scene } from "babylonjs/scene";
  8977. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8979. import { Light } from "babylonjs/Lights/light";
  8980. /**
  8981. * Interface describing all the common properties and methods a shadow light needs to implement.
  8982. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8983. * as well as binding the different shadow properties to the effects.
  8984. */
  8985. export interface IShadowLight extends Light {
  8986. /**
  8987. * The light id in the scene (used in scene.findLighById for instance)
  8988. */
  8989. id: string;
  8990. /**
  8991. * The position the shdow will be casted from.
  8992. */
  8993. position: Vector3;
  8994. /**
  8995. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8996. */
  8997. direction: Vector3;
  8998. /**
  8999. * The transformed position. Position of the light in world space taking parenting in account.
  9000. */
  9001. transformedPosition: Vector3;
  9002. /**
  9003. * The transformed direction. Direction of the light in world space taking parenting in account.
  9004. */
  9005. transformedDirection: Vector3;
  9006. /**
  9007. * The friendly name of the light in the scene.
  9008. */
  9009. name: string;
  9010. /**
  9011. * Defines the shadow projection clipping minimum z value.
  9012. */
  9013. shadowMinZ: number;
  9014. /**
  9015. * Defines the shadow projection clipping maximum z value.
  9016. */
  9017. shadowMaxZ: number;
  9018. /**
  9019. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9020. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9021. */
  9022. computeTransformedInformation(): boolean;
  9023. /**
  9024. * Gets the scene the light belongs to.
  9025. * @returns The scene
  9026. */
  9027. getScene(): Scene;
  9028. /**
  9029. * Callback defining a custom Projection Matrix Builder.
  9030. * This can be used to override the default projection matrix computation.
  9031. */
  9032. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9033. /**
  9034. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9035. * @param matrix The materix to updated with the projection information
  9036. * @param viewMatrix The transform matrix of the light
  9037. * @param renderList The list of mesh to render in the map
  9038. * @returns The current light
  9039. */
  9040. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9041. /**
  9042. * Gets the current depth scale used in ESM.
  9043. * @returns The scale
  9044. */
  9045. getDepthScale(): number;
  9046. /**
  9047. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9048. * @returns true if a cube texture needs to be use
  9049. */
  9050. needCube(): boolean;
  9051. /**
  9052. * Detects if the projection matrix requires to be recomputed this frame.
  9053. * @returns true if it requires to be recomputed otherwise, false.
  9054. */
  9055. needProjectionMatrixCompute(): boolean;
  9056. /**
  9057. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9058. */
  9059. forceProjectionMatrixCompute(): void;
  9060. /**
  9061. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9062. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9063. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9064. */
  9065. getShadowDirection(faceIndex?: number): Vector3;
  9066. /**
  9067. * Gets the minZ used for shadow according to both the scene and the light.
  9068. * @param activeCamera The camera we are returning the min for
  9069. * @returns the depth min z
  9070. */
  9071. getDepthMinZ(activeCamera: Camera): number;
  9072. /**
  9073. * Gets the maxZ used for shadow according to both the scene and the light.
  9074. * @param activeCamera The camera we are returning the max for
  9075. * @returns the depth max z
  9076. */
  9077. getDepthMaxZ(activeCamera: Camera): number;
  9078. }
  9079. /**
  9080. * Base implementation IShadowLight
  9081. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9082. */
  9083. export abstract class ShadowLight extends Light implements IShadowLight {
  9084. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9085. protected _position: Vector3;
  9086. protected _setPosition(value: Vector3): void;
  9087. /**
  9088. * Sets the position the shadow will be casted from. Also use as the light position for both
  9089. * point and spot lights.
  9090. */
  9091. /**
  9092. * Sets the position the shadow will be casted from. Also use as the light position for both
  9093. * point and spot lights.
  9094. */
  9095. position: Vector3;
  9096. protected _direction: Vector3;
  9097. protected _setDirection(value: Vector3): void;
  9098. /**
  9099. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9100. * Also use as the light direction on spot and directional lights.
  9101. */
  9102. /**
  9103. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9104. * Also use as the light direction on spot and directional lights.
  9105. */
  9106. direction: Vector3;
  9107. private _shadowMinZ;
  9108. /**
  9109. * Gets the shadow projection clipping minimum z value.
  9110. */
  9111. /**
  9112. * Sets the shadow projection clipping minimum z value.
  9113. */
  9114. shadowMinZ: number;
  9115. private _shadowMaxZ;
  9116. /**
  9117. * Sets the shadow projection clipping maximum z value.
  9118. */
  9119. /**
  9120. * Gets the shadow projection clipping maximum z value.
  9121. */
  9122. shadowMaxZ: number;
  9123. /**
  9124. * Callback defining a custom Projection Matrix Builder.
  9125. * This can be used to override the default projection matrix computation.
  9126. */
  9127. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9128. /**
  9129. * The transformed position. Position of the light in world space taking parenting in account.
  9130. */
  9131. transformedPosition: Vector3;
  9132. /**
  9133. * The transformed direction. Direction of the light in world space taking parenting in account.
  9134. */
  9135. transformedDirection: Vector3;
  9136. private _needProjectionMatrixCompute;
  9137. /**
  9138. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9139. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9140. */
  9141. computeTransformedInformation(): boolean;
  9142. /**
  9143. * Return the depth scale used for the shadow map.
  9144. * @returns the depth scale.
  9145. */
  9146. getDepthScale(): number;
  9147. /**
  9148. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9149. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9150. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9151. */
  9152. getShadowDirection(faceIndex?: number): Vector3;
  9153. /**
  9154. * Returns the ShadowLight absolute position in the World.
  9155. * @returns the position vector in world space
  9156. */
  9157. getAbsolutePosition(): Vector3;
  9158. /**
  9159. * Sets the ShadowLight direction toward the passed target.
  9160. * @param target The point to target in local space
  9161. * @returns the updated ShadowLight direction
  9162. */
  9163. setDirectionToTarget(target: Vector3): Vector3;
  9164. /**
  9165. * Returns the light rotation in euler definition.
  9166. * @returns the x y z rotation in local space.
  9167. */
  9168. getRotation(): Vector3;
  9169. /**
  9170. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9171. * @returns true if a cube texture needs to be use
  9172. */
  9173. needCube(): boolean;
  9174. /**
  9175. * Detects if the projection matrix requires to be recomputed this frame.
  9176. * @returns true if it requires to be recomputed otherwise, false.
  9177. */
  9178. needProjectionMatrixCompute(): boolean;
  9179. /**
  9180. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9181. */
  9182. forceProjectionMatrixCompute(): void;
  9183. /** @hidden */
  9184. _initCache(): void;
  9185. /** @hidden */
  9186. _isSynchronized(): boolean;
  9187. /**
  9188. * Computes the world matrix of the node
  9189. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9190. * @returns the world matrix
  9191. */
  9192. computeWorldMatrix(force?: boolean): Matrix;
  9193. /**
  9194. * Gets the minZ used for shadow according to both the scene and the light.
  9195. * @param activeCamera The camera we are returning the min for
  9196. * @returns the depth min z
  9197. */
  9198. getDepthMinZ(activeCamera: Camera): number;
  9199. /**
  9200. * Gets the maxZ used for shadow according to both the scene and the light.
  9201. * @param activeCamera The camera we are returning the max for
  9202. * @returns the depth max z
  9203. */
  9204. getDepthMaxZ(activeCamera: Camera): number;
  9205. /**
  9206. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9207. * @param matrix The materix to updated with the projection information
  9208. * @param viewMatrix The transform matrix of the light
  9209. * @param renderList The list of mesh to render in the map
  9210. * @returns The current light
  9211. */
  9212. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9213. }
  9214. }
  9215. declare module "babylonjs/Materials/materialHelper" {
  9216. import { Nullable } from "babylonjs/types";
  9217. import { Scene } from "babylonjs/scene";
  9218. import { Engine } from "babylonjs/Engines/engine";
  9219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9220. import { Light } from "babylonjs/Lights/light";
  9221. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9222. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9224. /**
  9225. * "Static Class" containing the most commonly used helper while dealing with material for
  9226. * rendering purpose.
  9227. *
  9228. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9229. *
  9230. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9231. */
  9232. export class MaterialHelper {
  9233. /**
  9234. * Bind the current view position to an effect.
  9235. * @param effect The effect to be bound
  9236. * @param scene The scene the eyes position is used from
  9237. */
  9238. static BindEyePosition(effect: Effect, scene: Scene): void;
  9239. /**
  9240. * Helps preparing the defines values about the UVs in used in the effect.
  9241. * UVs are shared as much as we can accross channels in the shaders.
  9242. * @param texture The texture we are preparing the UVs for
  9243. * @param defines The defines to update
  9244. * @param key The channel key "diffuse", "specular"... used in the shader
  9245. */
  9246. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9247. /**
  9248. * Binds a texture matrix value to its corrsponding uniform
  9249. * @param texture The texture to bind the matrix for
  9250. * @param uniformBuffer The uniform buffer receivin the data
  9251. * @param key The channel key "diffuse", "specular"... used in the shader
  9252. */
  9253. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9254. /**
  9255. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9256. * @param mesh defines the current mesh
  9257. * @param scene defines the current scene
  9258. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9259. * @param pointsCloud defines if point cloud rendering has to be turned on
  9260. * @param fogEnabled defines if fog has to be turned on
  9261. * @param alphaTest defines if alpha testing has to be turned on
  9262. * @param defines defines the current list of defines
  9263. */
  9264. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9265. /**
  9266. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9267. * @param scene defines the current scene
  9268. * @param engine defines the current engine
  9269. * @param defines specifies the list of active defines
  9270. * @param useInstances defines if instances have to be turned on
  9271. * @param useClipPlane defines if clip plane have to be turned on
  9272. */
  9273. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9274. /**
  9275. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9276. * @param mesh The mesh containing the geometry data we will draw
  9277. * @param defines The defines to update
  9278. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9279. * @param useBones Precise whether bones should be used or not (override mesh info)
  9280. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9281. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9282. * @returns false if defines are considered not dirty and have not been checked
  9283. */
  9284. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9285. /**
  9286. * Prepares the defines related to the light information passed in parameter
  9287. * @param scene The scene we are intending to draw
  9288. * @param mesh The mesh the effect is compiling for
  9289. * @param defines The defines to update
  9290. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9291. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9292. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9293. * @returns true if normals will be required for the rest of the effect
  9294. */
  9295. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9296. /**
  9297. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9298. * that won t be acctive due to defines being turned off.
  9299. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9300. * @param samplersList The samplers list
  9301. * @param defines The defines helping in the list generation
  9302. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9303. */
  9304. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9305. /**
  9306. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9307. * @param defines The defines to update while falling back
  9308. * @param fallbacks The authorized effect fallbacks
  9309. * @param maxSimultaneousLights The maximum number of lights allowed
  9310. * @param rank the current rank of the Effect
  9311. * @returns The newly affected rank
  9312. */
  9313. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9314. /**
  9315. * Prepares the list of attributes required for morph targets according to the effect defines.
  9316. * @param attribs The current list of supported attribs
  9317. * @param mesh The mesh to prepare the morph targets attributes for
  9318. * @param defines The current Defines of the effect
  9319. */
  9320. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9321. /**
  9322. * Prepares the list of attributes required for bones according to the effect defines.
  9323. * @param attribs The current list of supported attribs
  9324. * @param mesh The mesh to prepare the bones attributes for
  9325. * @param defines The current Defines of the effect
  9326. * @param fallbacks The current efffect fallback strategy
  9327. */
  9328. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9329. /**
  9330. * Prepares the list of attributes required for instances according to the effect defines.
  9331. * @param attribs The current list of supported attribs
  9332. * @param defines The current Defines of the effect
  9333. */
  9334. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9335. /**
  9336. * Binds the light shadow information to the effect for the given mesh.
  9337. * @param light The light containing the generator
  9338. * @param scene The scene the lights belongs to
  9339. * @param mesh The mesh we are binding the information to render
  9340. * @param lightIndex The light index in the effect used to render the mesh
  9341. * @param effect The effect we are binding the data to
  9342. */
  9343. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9344. /**
  9345. * Binds the light information to the effect.
  9346. * @param light The light containing the generator
  9347. * @param effect The effect we are binding the data to
  9348. * @param lightIndex The light index in the effect used to render
  9349. */
  9350. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9351. /**
  9352. * Binds the lights information from the scene to the effect for the given mesh.
  9353. * @param scene The scene the lights belongs to
  9354. * @param mesh The mesh we are binding the information to render
  9355. * @param effect The effect we are binding the data to
  9356. * @param defines The generated defines for the effect
  9357. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9358. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9359. */
  9360. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9361. private static _tempFogColor;
  9362. /**
  9363. * Binds the fog information from the scene to the effect for the given mesh.
  9364. * @param scene The scene the lights belongs to
  9365. * @param mesh The mesh we are binding the information to render
  9366. * @param effect The effect we are binding the data to
  9367. * @param linearSpace Defines if the fog effect is applied in linear space
  9368. */
  9369. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9370. /**
  9371. * Binds the bones information from the mesh to the effect.
  9372. * @param mesh The mesh we are binding the information to render
  9373. * @param effect The effect we are binding the data to
  9374. */
  9375. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9376. /**
  9377. * Binds the morph targets information from the mesh to the effect.
  9378. * @param abstractMesh The mesh we are binding the information to render
  9379. * @param effect The effect we are binding the data to
  9380. */
  9381. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9382. /**
  9383. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9384. * @param defines The generated defines used in the effect
  9385. * @param effect The effect we are binding the data to
  9386. * @param scene The scene we are willing to render with logarithmic scale for
  9387. */
  9388. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9389. /**
  9390. * Binds the clip plane information from the scene to the effect.
  9391. * @param scene The scene the clip plane information are extracted from
  9392. * @param effect The effect we are binding the data to
  9393. */
  9394. static BindClipPlane(effect: Effect, scene: Scene): void;
  9395. }
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9398. /** @hidden */
  9399. export var kernelBlurVaryingDeclaration: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9405. /** @hidden */
  9406. export var kernelBlurFragment: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9412. /** @hidden */
  9413. export var kernelBlurFragment2: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9419. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9420. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9421. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9422. /** @hidden */
  9423. export var kernelBlurPixelShader: {
  9424. name: string;
  9425. shader: string;
  9426. };
  9427. }
  9428. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9429. /** @hidden */
  9430. export var kernelBlurVertex: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9436. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9437. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9438. /** @hidden */
  9439. export var kernelBlurVertexShader: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9445. import { Vector2 } from "babylonjs/Maths/math";
  9446. import { Nullable } from "babylonjs/types";
  9447. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9448. import { Camera } from "babylonjs/Cameras/camera";
  9449. import { Effect } from "babylonjs/Materials/effect";
  9450. import { Engine } from "babylonjs/Engines/engine";
  9451. import "babylonjs/Shaders/kernelBlur.fragment";
  9452. import "babylonjs/Shaders/kernelBlur.vertex";
  9453. /**
  9454. * The Blur Post Process which blurs an image based on a kernel and direction.
  9455. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9456. */
  9457. export class BlurPostProcess extends PostProcess {
  9458. /** The direction in which to blur the image. */
  9459. direction: Vector2;
  9460. private blockCompilation;
  9461. protected _kernel: number;
  9462. protected _idealKernel: number;
  9463. protected _packedFloat: boolean;
  9464. private _staticDefines;
  9465. /**
  9466. * Sets the length in pixels of the blur sample region
  9467. */
  9468. /**
  9469. * Gets the length in pixels of the blur sample region
  9470. */
  9471. kernel: number;
  9472. /**
  9473. * Sets wether or not the blur needs to unpack/repack floats
  9474. */
  9475. /**
  9476. * Gets wether or not the blur is unpacking/repacking floats
  9477. */
  9478. packedFloat: boolean;
  9479. /**
  9480. * Creates a new instance BlurPostProcess
  9481. * @param name The name of the effect.
  9482. * @param direction The direction in which to blur the image.
  9483. * @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.
  9484. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9485. * @param camera The camera to apply the render pass to.
  9486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9487. * @param engine The engine which the post process will be applied. (default: current engine)
  9488. * @param reusable If the post process can be reused on the same frame. (default: false)
  9489. * @param textureType Type of textures used when performing the post process. (default: 0)
  9490. * @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)
  9491. */
  9492. constructor(name: string,
  9493. /** The direction in which to blur the image. */
  9494. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9495. /**
  9496. * Updates the effect with the current post process compile time values and recompiles the shader.
  9497. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9498. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9499. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9500. * @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
  9501. * @param onCompiled Called when the shader has been compiled.
  9502. * @param onError Called if there is an error when compiling a shader.
  9503. */
  9504. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9505. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9506. /**
  9507. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9508. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9509. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9510. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9511. * The gaps between physical kernels are compensated for in the weighting of the samples
  9512. * @param idealKernel Ideal blur kernel.
  9513. * @return Nearest best kernel.
  9514. */
  9515. protected _nearestBestKernel(idealKernel: number): number;
  9516. /**
  9517. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9518. * @param x The point on the Gaussian distribution to sample.
  9519. * @return the value of the Gaussian function at x.
  9520. */
  9521. protected _gaussianWeight(x: number): number;
  9522. /**
  9523. * Generates a string that can be used as a floating point number in GLSL.
  9524. * @param x Value to print.
  9525. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9526. * @return GLSL float string.
  9527. */
  9528. protected _glslFloat(x: number, decimalFigures?: number): string;
  9529. }
  9530. }
  9531. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9532. /** @hidden */
  9533. export var shadowMapPixelShader: {
  9534. name: string;
  9535. shader: string;
  9536. };
  9537. }
  9538. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9539. /** @hidden */
  9540. export var bonesDeclaration: {
  9541. name: string;
  9542. shader: string;
  9543. };
  9544. }
  9545. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9546. /** @hidden */
  9547. export var morphTargetsVertexGlobalDeclaration: {
  9548. name: string;
  9549. shader: string;
  9550. };
  9551. }
  9552. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9553. /** @hidden */
  9554. export var morphTargetsVertexDeclaration: {
  9555. name: string;
  9556. shader: string;
  9557. };
  9558. }
  9559. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9560. /** @hidden */
  9561. export var instancesDeclaration: {
  9562. name: string;
  9563. shader: string;
  9564. };
  9565. }
  9566. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9567. /** @hidden */
  9568. export var helperFunctions: {
  9569. name: string;
  9570. shader: string;
  9571. };
  9572. }
  9573. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9574. /** @hidden */
  9575. export var morphTargetsVertex: {
  9576. name: string;
  9577. shader: string;
  9578. };
  9579. }
  9580. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9581. /** @hidden */
  9582. export var instancesVertex: {
  9583. name: string;
  9584. shader: string;
  9585. };
  9586. }
  9587. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9588. /** @hidden */
  9589. export var bonesVertex: {
  9590. name: string;
  9591. shader: string;
  9592. };
  9593. }
  9594. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9595. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9596. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9597. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9598. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9599. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9600. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9601. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9602. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9603. /** @hidden */
  9604. export var shadowMapVertexShader: {
  9605. name: string;
  9606. shader: string;
  9607. };
  9608. }
  9609. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9610. /** @hidden */
  9611. export var depthBoxBlurPixelShader: {
  9612. name: string;
  9613. shader: string;
  9614. };
  9615. }
  9616. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9617. import { Nullable } from "babylonjs/types";
  9618. import { Scene } from "babylonjs/scene";
  9619. import { Matrix } from "babylonjs/Maths/math";
  9620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9622. import { Mesh } from "babylonjs/Meshes/mesh";
  9623. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9624. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9625. import { Effect } from "babylonjs/Materials/effect";
  9626. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9627. import "babylonjs/Shaders/shadowMap.fragment";
  9628. import "babylonjs/Shaders/shadowMap.vertex";
  9629. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9630. import { Observable } from "babylonjs/Misc/observable";
  9631. /**
  9632. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9633. */
  9634. export interface ICustomShaderOptions {
  9635. /**
  9636. * Gets or sets the custom shader name to use
  9637. */
  9638. shaderName: string;
  9639. /**
  9640. * The list of attribute names used in the shader
  9641. */
  9642. attributes?: string[];
  9643. /**
  9644. * The list of unifrom names used in the shader
  9645. */
  9646. uniforms?: string[];
  9647. /**
  9648. * The list of sampler names used in the shader
  9649. */
  9650. samplers?: string[];
  9651. /**
  9652. * The list of defines used in the shader
  9653. */
  9654. defines?: string[];
  9655. }
  9656. /**
  9657. * Interface to implement to create a shadow generator compatible with BJS.
  9658. */
  9659. export interface IShadowGenerator {
  9660. /**
  9661. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9662. * @returns The render target texture if present otherwise, null
  9663. */
  9664. getShadowMap(): Nullable<RenderTargetTexture>;
  9665. /**
  9666. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9667. * @returns The render target texture if the shadow map is present otherwise, null
  9668. */
  9669. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9670. /**
  9671. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9672. * @param subMesh The submesh we want to render in the shadow map
  9673. * @param useInstances Defines wether will draw in the map using instances
  9674. * @returns true if ready otherwise, false
  9675. */
  9676. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9677. /**
  9678. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9679. * @param defines Defines of the material we want to update
  9680. * @param lightIndex Index of the light in the enabled light list of the material
  9681. */
  9682. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9683. /**
  9684. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9685. * defined in the generator but impacting the effect).
  9686. * It implies the unifroms available on the materials are the standard BJS ones.
  9687. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9688. * @param effect The effect we are binfing the information for
  9689. */
  9690. bindShadowLight(lightIndex: string, effect: Effect): void;
  9691. /**
  9692. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9693. * (eq to shadow prjection matrix * light transform matrix)
  9694. * @returns The transform matrix used to create the shadow map
  9695. */
  9696. getTransformMatrix(): Matrix;
  9697. /**
  9698. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9699. * Cube and 2D textures for instance.
  9700. */
  9701. recreateShadowMap(): void;
  9702. /**
  9703. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9704. * @param onCompiled Callback triggered at the and of the effects compilation
  9705. * @param options Sets of optional options forcing the compilation with different modes
  9706. */
  9707. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9708. useInstances: boolean;
  9709. }>): void;
  9710. /**
  9711. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9712. * @param options Sets of optional options forcing the compilation with different modes
  9713. * @returns A promise that resolves when the compilation completes
  9714. */
  9715. forceCompilationAsync(options?: Partial<{
  9716. useInstances: boolean;
  9717. }>): Promise<void>;
  9718. /**
  9719. * Serializes the shadow generator setup to a json object.
  9720. * @returns The serialized JSON object
  9721. */
  9722. serialize(): any;
  9723. /**
  9724. * Disposes the Shadow map and related Textures and effects.
  9725. */
  9726. dispose(): void;
  9727. }
  9728. /**
  9729. * Default implementation IShadowGenerator.
  9730. * This is the main object responsible of generating shadows in the framework.
  9731. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9732. */
  9733. export class ShadowGenerator implements IShadowGenerator {
  9734. /**
  9735. * Shadow generator mode None: no filtering applied.
  9736. */
  9737. static readonly FILTER_NONE: number;
  9738. /**
  9739. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9740. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9741. */
  9742. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9743. /**
  9744. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9745. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9746. */
  9747. static readonly FILTER_POISSONSAMPLING: number;
  9748. /**
  9749. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9750. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9751. */
  9752. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9753. /**
  9754. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9755. * edge artifacts on steep falloff.
  9756. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9757. */
  9758. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9759. /**
  9760. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9761. * edge artifacts on steep falloff.
  9762. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9763. */
  9764. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9765. /**
  9766. * Shadow generator mode PCF: Percentage Closer Filtering
  9767. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9768. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9769. */
  9770. static readonly FILTER_PCF: number;
  9771. /**
  9772. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9773. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9774. * Contact Hardening
  9775. */
  9776. static readonly FILTER_PCSS: number;
  9777. /**
  9778. * Reserved for PCF and PCSS
  9779. * Highest Quality.
  9780. *
  9781. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9782. *
  9783. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9784. */
  9785. static readonly QUALITY_HIGH: number;
  9786. /**
  9787. * Reserved for PCF and PCSS
  9788. * Good tradeoff for quality/perf cross devices
  9789. *
  9790. * Execute PCF on a 3*3 kernel.
  9791. *
  9792. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9793. */
  9794. static readonly QUALITY_MEDIUM: number;
  9795. /**
  9796. * Reserved for PCF and PCSS
  9797. * The lowest quality but the fastest.
  9798. *
  9799. * Execute PCF on a 1*1 kernel.
  9800. *
  9801. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9802. */
  9803. static readonly QUALITY_LOW: number;
  9804. /** Gets or sets the custom shader name to use */
  9805. customShaderOptions: ICustomShaderOptions;
  9806. /**
  9807. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9808. */
  9809. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9810. /**
  9811. * Observable triggered before a mesh is rendered in the shadow map.
  9812. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9813. */
  9814. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9815. private _bias;
  9816. /**
  9817. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9818. */
  9819. /**
  9820. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9821. */
  9822. bias: number;
  9823. private _normalBias;
  9824. /**
  9825. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9826. */
  9827. /**
  9828. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9829. */
  9830. normalBias: number;
  9831. private _blurBoxOffset;
  9832. /**
  9833. * Gets the blur box offset: offset applied during the blur pass.
  9834. * Only useful if useKernelBlur = false
  9835. */
  9836. /**
  9837. * Sets the blur box offset: offset applied during the blur pass.
  9838. * Only useful if useKernelBlur = false
  9839. */
  9840. blurBoxOffset: number;
  9841. private _blurScale;
  9842. /**
  9843. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9844. * 2 means half of the size.
  9845. */
  9846. /**
  9847. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9848. * 2 means half of the size.
  9849. */
  9850. blurScale: number;
  9851. private _blurKernel;
  9852. /**
  9853. * Gets the blur kernel: kernel size of the blur pass.
  9854. * Only useful if useKernelBlur = true
  9855. */
  9856. /**
  9857. * Sets the blur kernel: kernel size of the blur pass.
  9858. * Only useful if useKernelBlur = true
  9859. */
  9860. blurKernel: number;
  9861. private _useKernelBlur;
  9862. /**
  9863. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9864. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9865. */
  9866. /**
  9867. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9868. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9869. */
  9870. useKernelBlur: boolean;
  9871. private _depthScale;
  9872. /**
  9873. * Gets the depth scale used in ESM mode.
  9874. */
  9875. /**
  9876. * Sets the depth scale used in ESM mode.
  9877. * This can override the scale stored on the light.
  9878. */
  9879. depthScale: number;
  9880. private _filter;
  9881. /**
  9882. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9883. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9884. */
  9885. /**
  9886. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9887. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9888. */
  9889. filter: number;
  9890. /**
  9891. * Gets if the current filter is set to Poisson Sampling.
  9892. */
  9893. /**
  9894. * Sets the current filter to Poisson Sampling.
  9895. */
  9896. usePoissonSampling: boolean;
  9897. /**
  9898. * Gets if the current filter is set to ESM.
  9899. */
  9900. /**
  9901. * Sets the current filter is to ESM.
  9902. */
  9903. useExponentialShadowMap: boolean;
  9904. /**
  9905. * Gets if the current filter is set to filtered ESM.
  9906. */
  9907. /**
  9908. * Gets if the current filter is set to filtered ESM.
  9909. */
  9910. useBlurExponentialShadowMap: boolean;
  9911. /**
  9912. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9913. * exponential to prevent steep falloff artifacts).
  9914. */
  9915. /**
  9916. * Sets the current filter to "close ESM" (using the inverse of the
  9917. * exponential to prevent steep falloff artifacts).
  9918. */
  9919. useCloseExponentialShadowMap: boolean;
  9920. /**
  9921. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9922. * exponential to prevent steep falloff artifacts).
  9923. */
  9924. /**
  9925. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9926. * exponential to prevent steep falloff artifacts).
  9927. */
  9928. useBlurCloseExponentialShadowMap: boolean;
  9929. /**
  9930. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9931. */
  9932. /**
  9933. * Sets the current filter to "PCF" (percentage closer filtering).
  9934. */
  9935. usePercentageCloserFiltering: boolean;
  9936. private _filteringQuality;
  9937. /**
  9938. * Gets the PCF or PCSS Quality.
  9939. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9940. */
  9941. /**
  9942. * Sets the PCF or PCSS Quality.
  9943. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9944. */
  9945. filteringQuality: number;
  9946. /**
  9947. * Gets if the current filter is set to "PCSS" (contact hardening).
  9948. */
  9949. /**
  9950. * Sets the current filter to "PCSS" (contact hardening).
  9951. */
  9952. useContactHardeningShadow: boolean;
  9953. private _contactHardeningLightSizeUVRatio;
  9954. /**
  9955. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9956. * Using a ratio helps keeping shape stability independently of the map size.
  9957. *
  9958. * It does not account for the light projection as it was having too much
  9959. * instability during the light setup or during light position changes.
  9960. *
  9961. * Only valid if useContactHardeningShadow is true.
  9962. */
  9963. /**
  9964. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9965. * Using a ratio helps keeping shape stability independently of the map size.
  9966. *
  9967. * It does not account for the light projection as it was having too much
  9968. * instability during the light setup or during light position changes.
  9969. *
  9970. * Only valid if useContactHardeningShadow is true.
  9971. */
  9972. contactHardeningLightSizeUVRatio: number;
  9973. private _darkness;
  9974. /**
  9975. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9976. * 0 means strongest and 1 would means no shadow.
  9977. * @returns the darkness.
  9978. */
  9979. getDarkness(): number;
  9980. /**
  9981. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9982. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9983. * @returns the shadow generator allowing fluent coding.
  9984. */
  9985. setDarkness(darkness: number): ShadowGenerator;
  9986. private _transparencyShadow;
  9987. /**
  9988. * Sets the ability to have transparent shadow (boolean).
  9989. * @param transparent True if transparent else False
  9990. * @returns the shadow generator allowing fluent coding
  9991. */
  9992. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9993. private _shadowMap;
  9994. private _shadowMap2;
  9995. /**
  9996. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9997. * @returns The render target texture if present otherwise, null
  9998. */
  9999. getShadowMap(): Nullable<RenderTargetTexture>;
  10000. /**
  10001. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10002. * @returns The render target texture if the shadow map is present otherwise, null
  10003. */
  10004. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10005. /**
  10006. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10007. * @param mesh Mesh to add
  10008. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10009. * @returns the Shadow Generator itself
  10010. */
  10011. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10012. /**
  10013. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10014. * @param mesh Mesh to remove
  10015. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10016. * @returns the Shadow Generator itself
  10017. */
  10018. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10019. /**
  10020. * Controls the extent to which the shadows fade out at the edge of the frustum
  10021. * Used only by directionals and spots
  10022. */
  10023. frustumEdgeFalloff: number;
  10024. private _light;
  10025. /**
  10026. * Returns the associated light object.
  10027. * @returns the light generating the shadow
  10028. */
  10029. getLight(): IShadowLight;
  10030. /**
  10031. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10032. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10033. * It might on the other hand introduce peter panning.
  10034. */
  10035. forceBackFacesOnly: boolean;
  10036. private _scene;
  10037. private _lightDirection;
  10038. private _effect;
  10039. private _viewMatrix;
  10040. private _projectionMatrix;
  10041. private _transformMatrix;
  10042. private _cachedPosition;
  10043. private _cachedDirection;
  10044. private _cachedDefines;
  10045. private _currentRenderID;
  10046. private _boxBlurPostprocess;
  10047. private _kernelBlurXPostprocess;
  10048. private _kernelBlurYPostprocess;
  10049. private _blurPostProcesses;
  10050. private _mapSize;
  10051. private _currentFaceIndex;
  10052. private _currentFaceIndexCache;
  10053. private _textureType;
  10054. private _defaultTextureMatrix;
  10055. /** @hidden */
  10056. static _SceneComponentInitialization: (scene: Scene) => void;
  10057. /**
  10058. * Creates a ShadowGenerator object.
  10059. * A ShadowGenerator is the required tool to use the shadows.
  10060. * Each light casting shadows needs to use its own ShadowGenerator.
  10061. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10062. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10063. * @param light The light object generating the shadows.
  10064. * @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.
  10065. */
  10066. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10067. private _initializeGenerator;
  10068. private _initializeShadowMap;
  10069. private _initializeBlurRTTAndPostProcesses;
  10070. private _renderForShadowMap;
  10071. private _renderSubMeshForShadowMap;
  10072. private _applyFilterValues;
  10073. /**
  10074. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10075. * @param onCompiled Callback triggered at the and of the effects compilation
  10076. * @param options Sets of optional options forcing the compilation with different modes
  10077. */
  10078. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10079. useInstances: boolean;
  10080. }>): void;
  10081. /**
  10082. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10083. * @param options Sets of optional options forcing the compilation with different modes
  10084. * @returns A promise that resolves when the compilation completes
  10085. */
  10086. forceCompilationAsync(options?: Partial<{
  10087. useInstances: boolean;
  10088. }>): Promise<void>;
  10089. /**
  10090. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10091. * @param subMesh The submesh we want to render in the shadow map
  10092. * @param useInstances Defines wether will draw in the map using instances
  10093. * @returns true if ready otherwise, false
  10094. */
  10095. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10096. /**
  10097. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10098. * @param defines Defines of the material we want to update
  10099. * @param lightIndex Index of the light in the enabled light list of the material
  10100. */
  10101. prepareDefines(defines: any, lightIndex: number): void;
  10102. /**
  10103. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10104. * defined in the generator but impacting the effect).
  10105. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10106. * @param effect The effect we are binfing the information for
  10107. */
  10108. bindShadowLight(lightIndex: string, effect: Effect): void;
  10109. /**
  10110. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10111. * (eq to shadow prjection matrix * light transform matrix)
  10112. * @returns The transform matrix used to create the shadow map
  10113. */
  10114. getTransformMatrix(): Matrix;
  10115. /**
  10116. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10117. * Cube and 2D textures for instance.
  10118. */
  10119. recreateShadowMap(): void;
  10120. private _disposeBlurPostProcesses;
  10121. private _disposeRTTandPostProcesses;
  10122. /**
  10123. * Disposes the ShadowGenerator.
  10124. * Returns nothing.
  10125. */
  10126. dispose(): void;
  10127. /**
  10128. * Serializes the shadow generator setup to a json object.
  10129. * @returns The serialized JSON object
  10130. */
  10131. serialize(): any;
  10132. /**
  10133. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10134. * @param parsedShadowGenerator The JSON object to parse
  10135. * @param scene The scene to create the shadow map for
  10136. * @returns The parsed shadow generator
  10137. */
  10138. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10139. }
  10140. }
  10141. declare module "babylonjs/Lights/light" {
  10142. import { Nullable } from "babylonjs/types";
  10143. import { Scene } from "babylonjs/scene";
  10144. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10145. import { Node } from "babylonjs/node";
  10146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10147. import { Effect } from "babylonjs/Materials/effect";
  10148. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10149. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10150. /**
  10151. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10152. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10153. * 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.
  10154. */
  10155. export abstract class Light extends Node {
  10156. /**
  10157. * Falloff Default: light is falling off following the material specification:
  10158. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10159. */
  10160. static readonly FALLOFF_DEFAULT: number;
  10161. /**
  10162. * Falloff Physical: light is falling off following the inverse squared distance law.
  10163. */
  10164. static readonly FALLOFF_PHYSICAL: number;
  10165. /**
  10166. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10167. * to enhance interoperability with other engines.
  10168. */
  10169. static readonly FALLOFF_GLTF: number;
  10170. /**
  10171. * Falloff Standard: light is falling off like in the standard material
  10172. * to enhance interoperability with other materials.
  10173. */
  10174. static readonly FALLOFF_STANDARD: number;
  10175. /**
  10176. * If every light affecting the material is in this lightmapMode,
  10177. * material.lightmapTexture adds or multiplies
  10178. * (depends on material.useLightmapAsShadowmap)
  10179. * after every other light calculations.
  10180. */
  10181. static readonly LIGHTMAP_DEFAULT: number;
  10182. /**
  10183. * material.lightmapTexture as only diffuse lighting from this light
  10184. * adds only specular lighting from this light
  10185. * adds dynamic shadows
  10186. */
  10187. static readonly LIGHTMAP_SPECULAR: number;
  10188. /**
  10189. * material.lightmapTexture as only lighting
  10190. * no light calculation from this light
  10191. * only adds dynamic shadows from this light
  10192. */
  10193. static readonly LIGHTMAP_SHADOWSONLY: number;
  10194. /**
  10195. * Each light type uses the default quantity according to its type:
  10196. * point/spot lights use luminous intensity
  10197. * directional lights use illuminance
  10198. */
  10199. static readonly INTENSITYMODE_AUTOMATIC: number;
  10200. /**
  10201. * lumen (lm)
  10202. */
  10203. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10204. /**
  10205. * candela (lm/sr)
  10206. */
  10207. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10208. /**
  10209. * lux (lm/m^2)
  10210. */
  10211. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10212. /**
  10213. * nit (cd/m^2)
  10214. */
  10215. static readonly INTENSITYMODE_LUMINANCE: number;
  10216. /**
  10217. * Light type const id of the point light.
  10218. */
  10219. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10220. /**
  10221. * Light type const id of the directional light.
  10222. */
  10223. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10224. /**
  10225. * Light type const id of the spot light.
  10226. */
  10227. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10228. /**
  10229. * Light type const id of the hemispheric light.
  10230. */
  10231. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10232. /**
  10233. * Diffuse gives the basic color to an object.
  10234. */
  10235. diffuse: Color3;
  10236. /**
  10237. * Specular produces a highlight color on an object.
  10238. * Note: This is note affecting PBR materials.
  10239. */
  10240. specular: Color3;
  10241. /**
  10242. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10243. * falling off base on range or angle.
  10244. * This can be set to any values in Light.FALLOFF_x.
  10245. *
  10246. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10247. * other types of materials.
  10248. */
  10249. falloffType: number;
  10250. /**
  10251. * Strength of the light.
  10252. * Note: By default it is define in the framework own unit.
  10253. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10254. */
  10255. intensity: number;
  10256. private _range;
  10257. protected _inverseSquaredRange: number;
  10258. /**
  10259. * Defines how far from the source the light is impacting in scene units.
  10260. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10261. */
  10262. /**
  10263. * Defines how far from the source the light is impacting in scene units.
  10264. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10265. */
  10266. range: number;
  10267. /**
  10268. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10269. * of light.
  10270. */
  10271. private _photometricScale;
  10272. private _intensityMode;
  10273. /**
  10274. * Gets the photometric scale used to interpret the intensity.
  10275. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10276. */
  10277. /**
  10278. * Sets the photometric scale used to interpret the intensity.
  10279. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10280. */
  10281. intensityMode: number;
  10282. private _radius;
  10283. /**
  10284. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10285. */
  10286. /**
  10287. * sets the light radius used by PBR Materials to simulate soft area lights.
  10288. */
  10289. radius: number;
  10290. private _renderPriority;
  10291. /**
  10292. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10293. * exceeding the number allowed of the materials.
  10294. */
  10295. renderPriority: number;
  10296. private _shadowEnabled;
  10297. /**
  10298. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10299. * the current shadow generator.
  10300. */
  10301. /**
  10302. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10303. * the current shadow generator.
  10304. */
  10305. shadowEnabled: boolean;
  10306. private _includedOnlyMeshes;
  10307. /**
  10308. * Gets the only meshes impacted by this light.
  10309. */
  10310. /**
  10311. * Sets the only meshes impacted by this light.
  10312. */
  10313. includedOnlyMeshes: AbstractMesh[];
  10314. private _excludedMeshes;
  10315. /**
  10316. * Gets the meshes not impacted by this light.
  10317. */
  10318. /**
  10319. * Sets the meshes not impacted by this light.
  10320. */
  10321. excludedMeshes: AbstractMesh[];
  10322. private _excludeWithLayerMask;
  10323. /**
  10324. * Gets the layer id use to find what meshes are not impacted by the light.
  10325. * Inactive if 0
  10326. */
  10327. /**
  10328. * Sets the layer id use to find what meshes are not impacted by the light.
  10329. * Inactive if 0
  10330. */
  10331. excludeWithLayerMask: number;
  10332. private _includeOnlyWithLayerMask;
  10333. /**
  10334. * Gets the layer id use to find what meshes are impacted by the light.
  10335. * Inactive if 0
  10336. */
  10337. /**
  10338. * Sets the layer id use to find what meshes are impacted by the light.
  10339. * Inactive if 0
  10340. */
  10341. includeOnlyWithLayerMask: number;
  10342. private _lightmapMode;
  10343. /**
  10344. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10345. */
  10346. /**
  10347. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10348. */
  10349. lightmapMode: number;
  10350. /**
  10351. * Shadow generator associted to the light.
  10352. * @hidden Internal use only.
  10353. */
  10354. _shadowGenerator: Nullable<IShadowGenerator>;
  10355. /**
  10356. * @hidden Internal use only.
  10357. */
  10358. _excludedMeshesIds: string[];
  10359. /**
  10360. * @hidden Internal use only.
  10361. */
  10362. _includedOnlyMeshesIds: string[];
  10363. /**
  10364. * The current light unifom buffer.
  10365. * @hidden Internal use only.
  10366. */
  10367. _uniformBuffer: UniformBuffer;
  10368. /**
  10369. * Creates a Light object in the scene.
  10370. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10371. * @param name The firendly name of the light
  10372. * @param scene The scene the light belongs too
  10373. */
  10374. constructor(name: string, scene: Scene);
  10375. protected abstract _buildUniformLayout(): void;
  10376. /**
  10377. * Sets the passed Effect "effect" with the Light information.
  10378. * @param effect The effect to update
  10379. * @param lightIndex The index of the light in the effect to update
  10380. * @returns The light
  10381. */
  10382. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10383. /**
  10384. * Returns the string "Light".
  10385. * @returns the class name
  10386. */
  10387. getClassName(): string;
  10388. /** @hidden */
  10389. readonly _isLight: boolean;
  10390. /**
  10391. * Converts the light information to a readable string for debug purpose.
  10392. * @param fullDetails Supports for multiple levels of logging within scene loading
  10393. * @returns the human readable light info
  10394. */
  10395. toString(fullDetails?: boolean): string;
  10396. /** @hidden */
  10397. protected _syncParentEnabledState(): void;
  10398. /**
  10399. * Set the enabled state of this node.
  10400. * @param value - the new enabled state
  10401. */
  10402. setEnabled(value: boolean): void;
  10403. /**
  10404. * Returns the Light associated shadow generator if any.
  10405. * @return the associated shadow generator.
  10406. */
  10407. getShadowGenerator(): Nullable<IShadowGenerator>;
  10408. /**
  10409. * Returns a Vector3, the absolute light position in the World.
  10410. * @returns the world space position of the light
  10411. */
  10412. getAbsolutePosition(): Vector3;
  10413. /**
  10414. * Specifies if the light will affect the passed mesh.
  10415. * @param mesh The mesh to test against the light
  10416. * @return true the mesh is affected otherwise, false.
  10417. */
  10418. canAffectMesh(mesh: AbstractMesh): boolean;
  10419. /**
  10420. * Sort function to order lights for rendering.
  10421. * @param a First Light object to compare to second.
  10422. * @param b Second Light object to compare first.
  10423. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10424. */
  10425. static CompareLightsPriority(a: Light, b: Light): number;
  10426. /**
  10427. * Releases resources associated with this node.
  10428. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10429. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10430. */
  10431. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10432. /**
  10433. * Returns the light type ID (integer).
  10434. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10435. */
  10436. getTypeID(): number;
  10437. /**
  10438. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10439. * @returns the scaled intensity in intensity mode unit
  10440. */
  10441. getScaledIntensity(): number;
  10442. /**
  10443. * Returns a new Light object, named "name", from the current one.
  10444. * @param name The name of the cloned light
  10445. * @returns the new created light
  10446. */
  10447. clone(name: string): Nullable<Light>;
  10448. /**
  10449. * Serializes the current light into a Serialization object.
  10450. * @returns the serialized object.
  10451. */
  10452. serialize(): any;
  10453. /**
  10454. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10455. * This new light is named "name" and added to the passed scene.
  10456. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10457. * @param name The friendly name of the light
  10458. * @param scene The scene the new light will belong to
  10459. * @returns the constructor function
  10460. */
  10461. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10462. /**
  10463. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10464. * @param parsedLight The JSON representation of the light
  10465. * @param scene The scene to create the parsed light in
  10466. * @returns the created light after parsing
  10467. */
  10468. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10469. private _hookArrayForExcluded;
  10470. private _hookArrayForIncludedOnly;
  10471. private _resyncMeshes;
  10472. /**
  10473. * Forces the meshes to update their light related information in their rendering used effects
  10474. * @hidden Internal Use Only
  10475. */
  10476. _markMeshesAsLightDirty(): void;
  10477. /**
  10478. * Recomputes the cached photometric scale if needed.
  10479. */
  10480. private _computePhotometricScale;
  10481. /**
  10482. * Returns the Photometric Scale according to the light type and intensity mode.
  10483. */
  10484. private _getPhotometricScale;
  10485. /**
  10486. * Reorder the light in the scene according to their defined priority.
  10487. * @hidden Internal Use Only
  10488. */
  10489. _reorderLightsInScene(): void;
  10490. /**
  10491. * Prepares the list of defines specific to the light type.
  10492. * @param defines the list of defines
  10493. * @param lightIndex defines the index of the light for the effect
  10494. */
  10495. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10496. }
  10497. }
  10498. declare module "babylonjs/Actions/action" {
  10499. import { Observable } from "babylonjs/Misc/observable";
  10500. import { Condition } from "babylonjs/Actions/condition";
  10501. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10502. import { ActionManager } from "babylonjs/Actions/actionManager";
  10503. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10504. /**
  10505. * Interface used to define Action
  10506. */
  10507. export interface IAction {
  10508. /**
  10509. * Trigger for the action
  10510. */
  10511. trigger: number;
  10512. /** Options of the trigger */
  10513. triggerOptions: any;
  10514. /**
  10515. * Gets the trigger parameters
  10516. * @returns the trigger parameters
  10517. */
  10518. getTriggerParameter(): any;
  10519. /**
  10520. * Internal only - executes current action event
  10521. * @hidden
  10522. */
  10523. _executeCurrent(evt?: ActionEvent): void;
  10524. /**
  10525. * Serialize placeholder for child classes
  10526. * @param parent of child
  10527. * @returns the serialized object
  10528. */
  10529. serialize(parent: any): any;
  10530. /**
  10531. * Internal only
  10532. * @hidden
  10533. */
  10534. _prepare(): void;
  10535. /**
  10536. * Internal only - manager for action
  10537. * @hidden
  10538. */
  10539. _actionManager: AbstractActionManager;
  10540. }
  10541. /**
  10542. * The action to be carried out following a trigger
  10543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10544. */
  10545. export class Action implements IAction {
  10546. /** the trigger, with or without parameters, for the action */
  10547. triggerOptions: any;
  10548. /**
  10549. * Trigger for the action
  10550. */
  10551. trigger: number;
  10552. /**
  10553. * Internal only - manager for action
  10554. * @hidden
  10555. */
  10556. _actionManager: ActionManager;
  10557. private _nextActiveAction;
  10558. private _child;
  10559. private _condition?;
  10560. private _triggerParameter;
  10561. /**
  10562. * An event triggered prior to action being executed.
  10563. */
  10564. onBeforeExecuteObservable: Observable<Action>;
  10565. /**
  10566. * Creates a new Action
  10567. * @param triggerOptions the trigger, with or without parameters, for the action
  10568. * @param condition an optional determinant of action
  10569. */
  10570. constructor(
  10571. /** the trigger, with or without parameters, for the action */
  10572. triggerOptions: any, condition?: Condition);
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. _prepare(): void;
  10578. /**
  10579. * Gets the trigger parameters
  10580. * @returns the trigger parameters
  10581. */
  10582. getTriggerParameter(): any;
  10583. /**
  10584. * Internal only - executes current action event
  10585. * @hidden
  10586. */
  10587. _executeCurrent(evt?: ActionEvent): void;
  10588. /**
  10589. * Execute placeholder for child classes
  10590. * @param evt optional action event
  10591. */
  10592. execute(evt?: ActionEvent): void;
  10593. /**
  10594. * Skips to next active action
  10595. */
  10596. skipToNextActiveAction(): void;
  10597. /**
  10598. * Adds action to chain of actions, may be a DoNothingAction
  10599. * @param action defines the next action to execute
  10600. * @returns The action passed in
  10601. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10602. */
  10603. then(action: Action): Action;
  10604. /**
  10605. * Internal only
  10606. * @hidden
  10607. */
  10608. _getProperty(propertyPath: string): string;
  10609. /**
  10610. * Internal only
  10611. * @hidden
  10612. */
  10613. _getEffectiveTarget(target: any, propertyPath: string): any;
  10614. /**
  10615. * Serialize placeholder for child classes
  10616. * @param parent of child
  10617. * @returns the serialized object
  10618. */
  10619. serialize(parent: any): any;
  10620. /**
  10621. * Internal only called by serialize
  10622. * @hidden
  10623. */
  10624. protected _serialize(serializedAction: any, parent?: any): any;
  10625. /**
  10626. * Internal only
  10627. * @hidden
  10628. */
  10629. static _SerializeValueAsString: (value: any) => string;
  10630. /**
  10631. * Internal only
  10632. * @hidden
  10633. */
  10634. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10635. name: string;
  10636. targetType: string;
  10637. value: string;
  10638. };
  10639. }
  10640. }
  10641. declare module "babylonjs/Actions/condition" {
  10642. import { ActionManager } from "babylonjs/Actions/actionManager";
  10643. /**
  10644. * A Condition applied to an Action
  10645. */
  10646. export class Condition {
  10647. /**
  10648. * Internal only - manager for action
  10649. * @hidden
  10650. */
  10651. _actionManager: ActionManager;
  10652. /**
  10653. * Internal only
  10654. * @hidden
  10655. */
  10656. _evaluationId: number;
  10657. /**
  10658. * Internal only
  10659. * @hidden
  10660. */
  10661. _currentResult: boolean;
  10662. /**
  10663. * Creates a new Condition
  10664. * @param actionManager the manager of the action the condition is applied to
  10665. */
  10666. constructor(actionManager: ActionManager);
  10667. /**
  10668. * Check if the current condition is valid
  10669. * @returns a boolean
  10670. */
  10671. isValid(): boolean;
  10672. /**
  10673. * Internal only
  10674. * @hidden
  10675. */
  10676. _getProperty(propertyPath: string): string;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. _getEffectiveTarget(target: any, propertyPath: string): any;
  10682. /**
  10683. * Serialize placeholder for child classes
  10684. * @returns the serialized object
  10685. */
  10686. serialize(): any;
  10687. /**
  10688. * Internal only
  10689. * @hidden
  10690. */
  10691. protected _serialize(serializedCondition: any): any;
  10692. }
  10693. /**
  10694. * Defines specific conditional operators as extensions of Condition
  10695. */
  10696. export class ValueCondition extends Condition {
  10697. /** path to specify the property of the target the conditional operator uses */
  10698. propertyPath: string;
  10699. /** the value compared by the conditional operator against the current value of the property */
  10700. value: any;
  10701. /** the conditional operator, default ValueCondition.IsEqual */
  10702. operator: number;
  10703. /**
  10704. * Internal only
  10705. * @hidden
  10706. */
  10707. private static _IsEqual;
  10708. /**
  10709. * Internal only
  10710. * @hidden
  10711. */
  10712. private static _IsDifferent;
  10713. /**
  10714. * Internal only
  10715. * @hidden
  10716. */
  10717. private static _IsGreater;
  10718. /**
  10719. * Internal only
  10720. * @hidden
  10721. */
  10722. private static _IsLesser;
  10723. /**
  10724. * returns the number for IsEqual
  10725. */
  10726. static readonly IsEqual: number;
  10727. /**
  10728. * Returns the number for IsDifferent
  10729. */
  10730. static readonly IsDifferent: number;
  10731. /**
  10732. * Returns the number for IsGreater
  10733. */
  10734. static readonly IsGreater: number;
  10735. /**
  10736. * Returns the number for IsLesser
  10737. */
  10738. static readonly IsLesser: number;
  10739. /**
  10740. * Internal only The action manager for the condition
  10741. * @hidden
  10742. */
  10743. _actionManager: ActionManager;
  10744. /**
  10745. * Internal only
  10746. * @hidden
  10747. */
  10748. private _target;
  10749. /**
  10750. * Internal only
  10751. * @hidden
  10752. */
  10753. private _effectiveTarget;
  10754. /**
  10755. * Internal only
  10756. * @hidden
  10757. */
  10758. private _property;
  10759. /**
  10760. * Creates a new ValueCondition
  10761. * @param actionManager manager for the action the condition applies to
  10762. * @param target for the action
  10763. * @param propertyPath path to specify the property of the target the conditional operator uses
  10764. * @param value the value compared by the conditional operator against the current value of the property
  10765. * @param operator the conditional operator, default ValueCondition.IsEqual
  10766. */
  10767. constructor(actionManager: ActionManager, target: any,
  10768. /** path to specify the property of the target the conditional operator uses */
  10769. propertyPath: string,
  10770. /** the value compared by the conditional operator against the current value of the property */
  10771. value: any,
  10772. /** the conditional operator, default ValueCondition.IsEqual */
  10773. operator?: number);
  10774. /**
  10775. * Compares the given value with the property value for the specified conditional operator
  10776. * @returns the result of the comparison
  10777. */
  10778. isValid(): boolean;
  10779. /**
  10780. * Serialize the ValueCondition into a JSON compatible object
  10781. * @returns serialization object
  10782. */
  10783. serialize(): any;
  10784. /**
  10785. * Gets the name of the conditional operator for the ValueCondition
  10786. * @param operator the conditional operator
  10787. * @returns the name
  10788. */
  10789. static GetOperatorName(operator: number): string;
  10790. }
  10791. /**
  10792. * Defines a predicate condition as an extension of Condition
  10793. */
  10794. export class PredicateCondition extends Condition {
  10795. /** defines the predicate function used to validate the condition */
  10796. predicate: () => boolean;
  10797. /**
  10798. * Internal only - manager for action
  10799. * @hidden
  10800. */
  10801. _actionManager: ActionManager;
  10802. /**
  10803. * Creates a new PredicateCondition
  10804. * @param actionManager manager for the action the condition applies to
  10805. * @param predicate defines the predicate function used to validate the condition
  10806. */
  10807. constructor(actionManager: ActionManager,
  10808. /** defines the predicate function used to validate the condition */
  10809. predicate: () => boolean);
  10810. /**
  10811. * @returns the validity of the predicate condition
  10812. */
  10813. isValid(): boolean;
  10814. }
  10815. /**
  10816. * Defines a state condition as an extension of Condition
  10817. */
  10818. export class StateCondition extends Condition {
  10819. /** Value to compare with target state */
  10820. value: string;
  10821. /**
  10822. * Internal only - manager for action
  10823. * @hidden
  10824. */
  10825. _actionManager: ActionManager;
  10826. /**
  10827. * Internal only
  10828. * @hidden
  10829. */
  10830. private _target;
  10831. /**
  10832. * Creates a new StateCondition
  10833. * @param actionManager manager for the action the condition applies to
  10834. * @param target of the condition
  10835. * @param value to compare with target state
  10836. */
  10837. constructor(actionManager: ActionManager, target: any,
  10838. /** Value to compare with target state */
  10839. value: string);
  10840. /**
  10841. * Gets a boolean indicating if the current condition is met
  10842. * @returns the validity of the state
  10843. */
  10844. isValid(): boolean;
  10845. /**
  10846. * Serialize the StateCondition into a JSON compatible object
  10847. * @returns serialization object
  10848. */
  10849. serialize(): any;
  10850. }
  10851. }
  10852. declare module "babylonjs/Actions/directActions" {
  10853. import { Action } from "babylonjs/Actions/action";
  10854. import { Condition } from "babylonjs/Actions/condition";
  10855. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10856. /**
  10857. * This defines an action responsible to toggle a boolean once triggered.
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10859. */
  10860. export class SwitchBooleanAction extends Action {
  10861. /**
  10862. * The path to the boolean property in the target object
  10863. */
  10864. propertyPath: string;
  10865. private _target;
  10866. private _effectiveTarget;
  10867. private _property;
  10868. /**
  10869. * Instantiate the action
  10870. * @param triggerOptions defines the trigger options
  10871. * @param target defines the object containing the boolean
  10872. * @param propertyPath defines the path to the boolean property in the target object
  10873. * @param condition defines the trigger related conditions
  10874. */
  10875. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10876. /** @hidden */
  10877. _prepare(): void;
  10878. /**
  10879. * Execute the action toggle the boolean value.
  10880. */
  10881. execute(): void;
  10882. /**
  10883. * Serializes the actions and its related information.
  10884. * @param parent defines the object to serialize in
  10885. * @returns the serialized object
  10886. */
  10887. serialize(parent: any): any;
  10888. }
  10889. /**
  10890. * This defines an action responsible to set a the state field of the target
  10891. * to a desired value once triggered.
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10893. */
  10894. export class SetStateAction extends Action {
  10895. /**
  10896. * The value to store in the state field.
  10897. */
  10898. value: string;
  10899. private _target;
  10900. /**
  10901. * Instantiate the action
  10902. * @param triggerOptions defines the trigger options
  10903. * @param target defines the object containing the state property
  10904. * @param value defines the value to store in the state field
  10905. * @param condition defines the trigger related conditions
  10906. */
  10907. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10908. /**
  10909. * Execute the action and store the value on the target state property.
  10910. */
  10911. execute(): void;
  10912. /**
  10913. * Serializes the actions and its related information.
  10914. * @param parent defines the object to serialize in
  10915. * @returns the serialized object
  10916. */
  10917. serialize(parent: any): any;
  10918. }
  10919. /**
  10920. * This defines an action responsible to set a property of the target
  10921. * to a desired value once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class SetValueAction extends Action {
  10925. /**
  10926. * The path of the property to set in the target.
  10927. */
  10928. propertyPath: string;
  10929. /**
  10930. * The value to set in the property
  10931. */
  10932. value: any;
  10933. private _target;
  10934. private _effectiveTarget;
  10935. private _property;
  10936. /**
  10937. * Instantiate the action
  10938. * @param triggerOptions defines the trigger options
  10939. * @param target defines the object containing the property
  10940. * @param propertyPath defines the path of the property to set in the target
  10941. * @param value defines the value to set in the property
  10942. * @param condition defines the trigger related conditions
  10943. */
  10944. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10945. /** @hidden */
  10946. _prepare(): void;
  10947. /**
  10948. * Execute the action and set the targetted property to the desired value.
  10949. */
  10950. execute(): void;
  10951. /**
  10952. * Serializes the actions and its related information.
  10953. * @param parent defines the object to serialize in
  10954. * @returns the serialized object
  10955. */
  10956. serialize(parent: any): any;
  10957. }
  10958. /**
  10959. * This defines an action responsible to increment the target value
  10960. * to a desired value once triggered.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class IncrementValueAction extends Action {
  10964. /**
  10965. * The path of the property to increment in the target.
  10966. */
  10967. propertyPath: string;
  10968. /**
  10969. * The value we should increment the property by.
  10970. */
  10971. value: any;
  10972. private _target;
  10973. private _effectiveTarget;
  10974. private _property;
  10975. /**
  10976. * Instantiate the action
  10977. * @param triggerOptions defines the trigger options
  10978. * @param target defines the object containing the property
  10979. * @param propertyPath defines the path of the property to increment in the target
  10980. * @param value defines the value value we should increment the property by
  10981. * @param condition defines the trigger related conditions
  10982. */
  10983. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10984. /** @hidden */
  10985. _prepare(): void;
  10986. /**
  10987. * Execute the action and increment the target of the value amount.
  10988. */
  10989. execute(): void;
  10990. /**
  10991. * Serializes the actions and its related information.
  10992. * @param parent defines the object to serialize in
  10993. * @returns the serialized object
  10994. */
  10995. serialize(parent: any): any;
  10996. }
  10997. /**
  10998. * This defines an action responsible to start an animation once triggered.
  10999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11000. */
  11001. export class PlayAnimationAction extends Action {
  11002. /**
  11003. * Where the animation should start (animation frame)
  11004. */
  11005. from: number;
  11006. /**
  11007. * Where the animation should stop (animation frame)
  11008. */
  11009. to: number;
  11010. /**
  11011. * Define if the animation should loop or stop after the first play.
  11012. */
  11013. loop?: boolean;
  11014. private _target;
  11015. /**
  11016. * Instantiate the action
  11017. * @param triggerOptions defines the trigger options
  11018. * @param target defines the target animation or animation name
  11019. * @param from defines from where the animation should start (animation frame)
  11020. * @param end defines where the animation should stop (animation frame)
  11021. * @param loop defines if the animation should loop or stop after the first play
  11022. * @param condition defines the trigger related conditions
  11023. */
  11024. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11025. /** @hidden */
  11026. _prepare(): void;
  11027. /**
  11028. * Execute the action and play the animation.
  11029. */
  11030. execute(): void;
  11031. /**
  11032. * Serializes the actions and its related information.
  11033. * @param parent defines the object to serialize in
  11034. * @returns the serialized object
  11035. */
  11036. serialize(parent: any): any;
  11037. }
  11038. /**
  11039. * This defines an action responsible to stop an animation once triggered.
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11041. */
  11042. export class StopAnimationAction extends Action {
  11043. private _target;
  11044. /**
  11045. * Instantiate the action
  11046. * @param triggerOptions defines the trigger options
  11047. * @param target defines the target animation or animation name
  11048. * @param condition defines the trigger related conditions
  11049. */
  11050. constructor(triggerOptions: any, target: any, condition?: Condition);
  11051. /** @hidden */
  11052. _prepare(): void;
  11053. /**
  11054. * Execute the action and stop the animation.
  11055. */
  11056. execute(): void;
  11057. /**
  11058. * Serializes the actions and its related information.
  11059. * @param parent defines the object to serialize in
  11060. * @returns the serialized object
  11061. */
  11062. serialize(parent: any): any;
  11063. }
  11064. /**
  11065. * This defines an action responsible that does nothing once triggered.
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11067. */
  11068. export class DoNothingAction extends Action {
  11069. /**
  11070. * Instantiate the action
  11071. * @param triggerOptions defines the trigger options
  11072. * @param condition defines the trigger related conditions
  11073. */
  11074. constructor(triggerOptions?: any, condition?: Condition);
  11075. /**
  11076. * Execute the action and do nothing.
  11077. */
  11078. execute(): void;
  11079. /**
  11080. * Serializes the actions and its related information.
  11081. * @param parent defines the object to serialize in
  11082. * @returns the serialized object
  11083. */
  11084. serialize(parent: any): any;
  11085. }
  11086. /**
  11087. * This defines an action responsible to trigger several actions once triggered.
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11089. */
  11090. export class CombineAction extends Action {
  11091. /**
  11092. * The list of aggregated animations to run.
  11093. */
  11094. children: Action[];
  11095. /**
  11096. * Instantiate the action
  11097. * @param triggerOptions defines the trigger options
  11098. * @param children defines the list of aggregated animations to run
  11099. * @param condition defines the trigger related conditions
  11100. */
  11101. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11102. /** @hidden */
  11103. _prepare(): void;
  11104. /**
  11105. * Execute the action and executes all the aggregated actions.
  11106. */
  11107. execute(evt: ActionEvent): void;
  11108. /**
  11109. * Serializes the actions and its related information.
  11110. * @param parent defines the object to serialize in
  11111. * @returns the serialized object
  11112. */
  11113. serialize(parent: any): any;
  11114. }
  11115. /**
  11116. * This defines an action responsible to run code (external event) once triggered.
  11117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11118. */
  11119. export class ExecuteCodeAction extends Action {
  11120. /**
  11121. * The callback function to run.
  11122. */
  11123. func: (evt: ActionEvent) => void;
  11124. /**
  11125. * Instantiate the action
  11126. * @param triggerOptions defines the trigger options
  11127. * @param func defines the callback function to run
  11128. * @param condition defines the trigger related conditions
  11129. */
  11130. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11131. /**
  11132. * Execute the action and run the attached code.
  11133. */
  11134. execute(evt: ActionEvent): void;
  11135. }
  11136. /**
  11137. * This defines an action responsible to set the parent property of the target once triggered.
  11138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11139. */
  11140. export class SetParentAction extends Action {
  11141. private _parent;
  11142. private _target;
  11143. /**
  11144. * Instantiate the action
  11145. * @param triggerOptions defines the trigger options
  11146. * @param target defines the target containing the parent property
  11147. * @param parent defines from where the animation should start (animation frame)
  11148. * @param condition defines the trigger related conditions
  11149. */
  11150. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11151. /** @hidden */
  11152. _prepare(): void;
  11153. /**
  11154. * Execute the action and set the parent property.
  11155. */
  11156. execute(): void;
  11157. /**
  11158. * Serializes the actions and its related information.
  11159. * @param parent defines the object to serialize in
  11160. * @returns the serialized object
  11161. */
  11162. serialize(parent: any): any;
  11163. }
  11164. }
  11165. declare module "babylonjs/Actions/actionManager" {
  11166. import { Nullable } from "babylonjs/types";
  11167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11168. import { Scene } from "babylonjs/scene";
  11169. import { IAction } from "babylonjs/Actions/action";
  11170. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11171. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11172. /**
  11173. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11174. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11176. */
  11177. export class ActionManager extends AbstractActionManager {
  11178. /**
  11179. * Nothing
  11180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11181. */
  11182. static readonly NothingTrigger: number;
  11183. /**
  11184. * On pick
  11185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11186. */
  11187. static readonly OnPickTrigger: number;
  11188. /**
  11189. * On left pick
  11190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11191. */
  11192. static readonly OnLeftPickTrigger: number;
  11193. /**
  11194. * On right pick
  11195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11196. */
  11197. static readonly OnRightPickTrigger: number;
  11198. /**
  11199. * On center pick
  11200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11201. */
  11202. static readonly OnCenterPickTrigger: number;
  11203. /**
  11204. * On pick down
  11205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11206. */
  11207. static readonly OnPickDownTrigger: number;
  11208. /**
  11209. * On double pick
  11210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11211. */
  11212. static readonly OnDoublePickTrigger: number;
  11213. /**
  11214. * On pick up
  11215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11216. */
  11217. static readonly OnPickUpTrigger: number;
  11218. /**
  11219. * On pick out.
  11220. * This trigger will only be raised if you also declared a OnPickDown
  11221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11222. */
  11223. static readonly OnPickOutTrigger: number;
  11224. /**
  11225. * On long press
  11226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11227. */
  11228. static readonly OnLongPressTrigger: number;
  11229. /**
  11230. * On pointer over
  11231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11232. */
  11233. static readonly OnPointerOverTrigger: number;
  11234. /**
  11235. * On pointer out
  11236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11237. */
  11238. static readonly OnPointerOutTrigger: number;
  11239. /**
  11240. * On every frame
  11241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11242. */
  11243. static readonly OnEveryFrameTrigger: number;
  11244. /**
  11245. * On intersection enter
  11246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11247. */
  11248. static readonly OnIntersectionEnterTrigger: number;
  11249. /**
  11250. * On intersection exit
  11251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11252. */
  11253. static readonly OnIntersectionExitTrigger: number;
  11254. /**
  11255. * On key down
  11256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11257. */
  11258. static readonly OnKeyDownTrigger: number;
  11259. /**
  11260. * On key up
  11261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11262. */
  11263. static readonly OnKeyUpTrigger: number;
  11264. private _scene;
  11265. /**
  11266. * Creates a new action manager
  11267. * @param scene defines the hosting scene
  11268. */
  11269. constructor(scene: Scene);
  11270. /**
  11271. * Releases all associated resources
  11272. */
  11273. dispose(): void;
  11274. /**
  11275. * Gets hosting scene
  11276. * @returns the hosting scene
  11277. */
  11278. getScene(): Scene;
  11279. /**
  11280. * Does this action manager handles actions of any of the given triggers
  11281. * @param triggers defines the triggers to be tested
  11282. * @return a boolean indicating whether one (or more) of the triggers is handled
  11283. */
  11284. hasSpecificTriggers(triggers: number[]): boolean;
  11285. /**
  11286. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11287. * speed.
  11288. * @param triggerA defines the trigger to be tested
  11289. * @param triggerB defines the trigger to be tested
  11290. * @return a boolean indicating whether one (or more) of the triggers is handled
  11291. */
  11292. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11293. /**
  11294. * Does this action manager handles actions of a given trigger
  11295. * @param trigger defines the trigger to be tested
  11296. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11297. * @return whether the trigger is handled
  11298. */
  11299. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11300. /**
  11301. * Does this action manager has pointer triggers
  11302. */
  11303. readonly hasPointerTriggers: boolean;
  11304. /**
  11305. * Does this action manager has pick triggers
  11306. */
  11307. readonly hasPickTriggers: boolean;
  11308. /**
  11309. * Registers an action to this action manager
  11310. * @param action defines the action to be registered
  11311. * @return the action amended (prepared) after registration
  11312. */
  11313. registerAction(action: IAction): Nullable<IAction>;
  11314. /**
  11315. * Unregisters an action to this action manager
  11316. * @param action defines the action to be unregistered
  11317. * @return a boolean indicating whether the action has been unregistered
  11318. */
  11319. unregisterAction(action: IAction): Boolean;
  11320. /**
  11321. * Process a specific trigger
  11322. * @param trigger defines the trigger to process
  11323. * @param evt defines the event details to be processed
  11324. */
  11325. processTrigger(trigger: number, evt?: IActionEvent): void;
  11326. /** @hidden */
  11327. _getEffectiveTarget(target: any, propertyPath: string): any;
  11328. /** @hidden */
  11329. _getProperty(propertyPath: string): string;
  11330. /**
  11331. * Serialize this manager to a JSON object
  11332. * @param name defines the property name to store this manager
  11333. * @returns a JSON representation of this manager
  11334. */
  11335. serialize(name: string): any;
  11336. /**
  11337. * Creates a new ActionManager from a JSON data
  11338. * @param parsedActions defines the JSON data to read from
  11339. * @param object defines the hosting mesh
  11340. * @param scene defines the hosting scene
  11341. */
  11342. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11343. /**
  11344. * Get a trigger name by index
  11345. * @param trigger defines the trigger index
  11346. * @returns a trigger name
  11347. */
  11348. static GetTriggerName(trigger: number): string;
  11349. }
  11350. }
  11351. declare module "babylonjs/Culling/ray" {
  11352. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11353. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11355. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11356. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11357. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11358. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11359. /**
  11360. * Class representing a ray with position and direction
  11361. */
  11362. export class Ray {
  11363. /** origin point */
  11364. origin: Vector3;
  11365. /** direction */
  11366. direction: Vector3;
  11367. /** length of the ray */
  11368. length: number;
  11369. private static readonly TmpVector3;
  11370. private _tmpRay;
  11371. /**
  11372. * Creates a new ray
  11373. * @param origin origin point
  11374. * @param direction direction
  11375. * @param length length of the ray
  11376. */
  11377. constructor(
  11378. /** origin point */
  11379. origin: Vector3,
  11380. /** direction */
  11381. direction: Vector3,
  11382. /** length of the ray */
  11383. length?: number);
  11384. /**
  11385. * Checks if the ray intersects a box
  11386. * @param minimum bound of the box
  11387. * @param maximum bound of the box
  11388. * @param intersectionTreshold extra extend to be added to the box in all direction
  11389. * @returns if the box was hit
  11390. */
  11391. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11392. /**
  11393. * Checks if the ray intersects a box
  11394. * @param box the bounding box to check
  11395. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11396. * @returns if the box was hit
  11397. */
  11398. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11399. /**
  11400. * If the ray hits a sphere
  11401. * @param sphere the bounding sphere to check
  11402. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11403. * @returns true if it hits the sphere
  11404. */
  11405. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11406. /**
  11407. * If the ray hits a triange
  11408. * @param vertex0 triangle vertex
  11409. * @param vertex1 triangle vertex
  11410. * @param vertex2 triangle vertex
  11411. * @returns intersection information if hit
  11412. */
  11413. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11414. /**
  11415. * Checks if ray intersects a plane
  11416. * @param plane the plane to check
  11417. * @returns the distance away it was hit
  11418. */
  11419. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11420. /**
  11421. * Checks if ray intersects a mesh
  11422. * @param mesh the mesh to check
  11423. * @param fastCheck if only the bounding box should checked
  11424. * @returns picking info of the intersecton
  11425. */
  11426. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11427. /**
  11428. * Checks if ray intersects a mesh
  11429. * @param meshes the meshes to check
  11430. * @param fastCheck if only the bounding box should checked
  11431. * @param results array to store result in
  11432. * @returns Array of picking infos
  11433. */
  11434. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11435. private _comparePickingInfo;
  11436. private static smallnum;
  11437. private static rayl;
  11438. /**
  11439. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11440. * @param sega the first point of the segment to test the intersection against
  11441. * @param segb the second point of the segment to test the intersection against
  11442. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11443. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11444. */
  11445. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11446. /**
  11447. * Update the ray from viewport position
  11448. * @param x position
  11449. * @param y y position
  11450. * @param viewportWidth viewport width
  11451. * @param viewportHeight viewport height
  11452. * @param world world matrix
  11453. * @param view view matrix
  11454. * @param projection projection matrix
  11455. * @returns this ray updated
  11456. */
  11457. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11458. /**
  11459. * Creates a ray with origin and direction of 0,0,0
  11460. * @returns the new ray
  11461. */
  11462. static Zero(): Ray;
  11463. /**
  11464. * Creates a new ray from screen space and viewport
  11465. * @param x position
  11466. * @param y y position
  11467. * @param viewportWidth viewport width
  11468. * @param viewportHeight viewport height
  11469. * @param world world matrix
  11470. * @param view view matrix
  11471. * @param projection projection matrix
  11472. * @returns new ray
  11473. */
  11474. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11475. /**
  11476. * 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
  11477. * transformed to the given world matrix.
  11478. * @param origin The origin point
  11479. * @param end The end point
  11480. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11481. * @returns the new ray
  11482. */
  11483. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11484. /**
  11485. * Transforms a ray by a matrix
  11486. * @param ray ray to transform
  11487. * @param matrix matrix to apply
  11488. * @returns the resulting new ray
  11489. */
  11490. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11491. /**
  11492. * Transforms a ray by a matrix
  11493. * @param ray ray to transform
  11494. * @param matrix matrix to apply
  11495. * @param result ray to store result in
  11496. */
  11497. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11498. /**
  11499. * Unproject a ray from screen space to object space
  11500. * @param sourceX defines the screen space x coordinate to use
  11501. * @param sourceY defines the screen space y coordinate to use
  11502. * @param viewportWidth defines the current width of the viewport
  11503. * @param viewportHeight defines the current height of the viewport
  11504. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11505. * @param view defines the view matrix to use
  11506. * @param projection defines the projection matrix to use
  11507. */
  11508. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11509. }
  11510. /**
  11511. * Type used to define predicate used to select faces when a mesh intersection is detected
  11512. */
  11513. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11514. module "babylonjs/scene" {
  11515. interface Scene {
  11516. /** @hidden */
  11517. _tempPickingRay: Nullable<Ray>;
  11518. /** @hidden */
  11519. _cachedRayForTransform: Ray;
  11520. /** @hidden */
  11521. _pickWithRayInverseMatrix: Matrix;
  11522. /** @hidden */
  11523. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11524. /** @hidden */
  11525. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11526. }
  11527. }
  11528. }
  11529. declare module "babylonjs/sceneComponent" {
  11530. import { Scene } from "babylonjs/scene";
  11531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11533. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11534. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11535. import { Nullable } from "babylonjs/types";
  11536. import { Camera } from "babylonjs/Cameras/camera";
  11537. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11538. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11539. import { AbstractScene } from "babylonjs/abstractScene";
  11540. /**
  11541. * Groups all the scene component constants in one place to ease maintenance.
  11542. * @hidden
  11543. */
  11544. export class SceneComponentConstants {
  11545. static readonly NAME_EFFECTLAYER: string;
  11546. static readonly NAME_LAYER: string;
  11547. static readonly NAME_LENSFLARESYSTEM: string;
  11548. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11549. static readonly NAME_PARTICLESYSTEM: string;
  11550. static readonly NAME_GAMEPAD: string;
  11551. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11552. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11553. static readonly NAME_DEPTHRENDERER: string;
  11554. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11555. static readonly NAME_SPRITE: string;
  11556. static readonly NAME_OUTLINERENDERER: string;
  11557. static readonly NAME_PROCEDURALTEXTURE: string;
  11558. static readonly NAME_SHADOWGENERATOR: string;
  11559. static readonly NAME_OCTREE: string;
  11560. static readonly NAME_PHYSICSENGINE: string;
  11561. static readonly NAME_AUDIO: string;
  11562. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11563. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11564. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11565. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11566. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11567. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11568. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11569. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11570. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11571. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11572. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11573. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11574. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11575. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11576. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11577. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11578. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11579. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11580. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11581. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11582. static readonly STEP_AFTERRENDER_AUDIO: number;
  11583. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11584. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11585. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11586. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11587. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11588. static readonly STEP_POINTERMOVE_SPRITE: number;
  11589. static readonly STEP_POINTERDOWN_SPRITE: number;
  11590. static readonly STEP_POINTERUP_SPRITE: number;
  11591. }
  11592. /**
  11593. * This represents a scene component.
  11594. *
  11595. * This is used to decouple the dependency the scene is having on the different workloads like
  11596. * layers, post processes...
  11597. */
  11598. export interface ISceneComponent {
  11599. /**
  11600. * The name of the component. Each component must have a unique name.
  11601. */
  11602. name: string;
  11603. /**
  11604. * The scene the component belongs to.
  11605. */
  11606. scene: Scene;
  11607. /**
  11608. * Register the component to one instance of a scene.
  11609. */
  11610. register(): void;
  11611. /**
  11612. * Rebuilds the elements related to this component in case of
  11613. * context lost for instance.
  11614. */
  11615. rebuild(): void;
  11616. /**
  11617. * Disposes the component and the associated ressources.
  11618. */
  11619. dispose(): void;
  11620. }
  11621. /**
  11622. * This represents a SERIALIZABLE scene component.
  11623. *
  11624. * This extends Scene Component to add Serialization methods on top.
  11625. */
  11626. export interface ISceneSerializableComponent extends ISceneComponent {
  11627. /**
  11628. * Adds all the element from the container to the scene
  11629. * @param container the container holding the elements
  11630. */
  11631. addFromContainer(container: AbstractScene): void;
  11632. /**
  11633. * Removes all the elements in the container from the scene
  11634. * @param container contains the elements to remove
  11635. * @param dispose if the removed element should be disposed (default: false)
  11636. */
  11637. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11638. /**
  11639. * Serializes the component data to the specified json object
  11640. * @param serializationObject The object to serialize to
  11641. */
  11642. serialize(serializationObject: any): void;
  11643. }
  11644. /**
  11645. * Strong typing of a Mesh related stage step action
  11646. */
  11647. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11648. /**
  11649. * Strong typing of a Evaluate Sub Mesh related stage step action
  11650. */
  11651. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11652. /**
  11653. * Strong typing of a Active Mesh related stage step action
  11654. */
  11655. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11656. /**
  11657. * Strong typing of a Camera related stage step action
  11658. */
  11659. export type CameraStageAction = (camera: Camera) => void;
  11660. /**
  11661. * Strong typing of a Render Target related stage step action
  11662. */
  11663. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11664. /**
  11665. * Strong typing of a RenderingGroup related stage step action
  11666. */
  11667. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11668. /**
  11669. * Strong typing of a Mesh Render related stage step action
  11670. */
  11671. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11672. /**
  11673. * Strong typing of a simple stage step action
  11674. */
  11675. export type SimpleStageAction = () => void;
  11676. /**
  11677. * Strong typing of a render target action.
  11678. */
  11679. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11680. /**
  11681. * Strong typing of a pointer move action.
  11682. */
  11683. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11684. /**
  11685. * Strong typing of a pointer up/down action.
  11686. */
  11687. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11688. /**
  11689. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11690. * @hidden
  11691. */
  11692. export class Stage<T extends Function> extends Array<{
  11693. index: number;
  11694. component: ISceneComponent;
  11695. action: T;
  11696. }> {
  11697. /**
  11698. * Hide ctor from the rest of the world.
  11699. * @param items The items to add.
  11700. */
  11701. private constructor();
  11702. /**
  11703. * Creates a new Stage.
  11704. * @returns A new instance of a Stage
  11705. */
  11706. static Create<T extends Function>(): Stage<T>;
  11707. /**
  11708. * Registers a step in an ordered way in the targeted stage.
  11709. * @param index Defines the position to register the step in
  11710. * @param component Defines the component attached to the step
  11711. * @param action Defines the action to launch during the step
  11712. */
  11713. registerStep(index: number, component: ISceneComponent, action: T): void;
  11714. /**
  11715. * Clears all the steps from the stage.
  11716. */
  11717. clear(): void;
  11718. }
  11719. }
  11720. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11721. import { Nullable } from "babylonjs/types";
  11722. import { Observable } from "babylonjs/Misc/observable";
  11723. import { Scene } from "babylonjs/scene";
  11724. import { Sprite } from "babylonjs/Sprites/sprite";
  11725. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11726. import { Ray } from "babylonjs/Culling/ray";
  11727. import { Camera } from "babylonjs/Cameras/camera";
  11728. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11729. import { ISceneComponent } from "babylonjs/sceneComponent";
  11730. module "babylonjs/scene" {
  11731. interface Scene {
  11732. /** @hidden */
  11733. _pointerOverSprite: Nullable<Sprite>;
  11734. /** @hidden */
  11735. _pickedDownSprite: Nullable<Sprite>;
  11736. /** @hidden */
  11737. _tempSpritePickingRay: Nullable<Ray>;
  11738. /**
  11739. * All of the sprite managers added to this scene
  11740. * @see http://doc.babylonjs.com/babylon101/sprites
  11741. */
  11742. spriteManagers: Array<ISpriteManager>;
  11743. /**
  11744. * An event triggered when sprites rendering is about to start
  11745. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11746. */
  11747. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11748. /**
  11749. * An event triggered when sprites rendering is done
  11750. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11751. */
  11752. onAfterSpritesRenderingObservable: Observable<Scene>;
  11753. /** @hidden */
  11754. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11755. /** Launch a ray to try to pick a sprite in the scene
  11756. * @param x position on screen
  11757. * @param y position on screen
  11758. * @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
  11759. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11760. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11761. * @returns a PickingInfo
  11762. */
  11763. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11764. /** Use the given ray to pick a sprite in the scene
  11765. * @param ray The ray (in world space) to use to pick meshes
  11766. * @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
  11767. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11768. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11769. * @returns a PickingInfo
  11770. */
  11771. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11772. /**
  11773. * Force the sprite under the pointer
  11774. * @param sprite defines the sprite to use
  11775. */
  11776. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11777. /**
  11778. * Gets the sprite under the pointer
  11779. * @returns a Sprite or null if no sprite is under the pointer
  11780. */
  11781. getPointerOverSprite(): Nullable<Sprite>;
  11782. }
  11783. }
  11784. /**
  11785. * Defines the sprite scene component responsible to manage sprites
  11786. * in a given scene.
  11787. */
  11788. export class SpriteSceneComponent implements ISceneComponent {
  11789. /**
  11790. * The component name helpfull to identify the component in the list of scene components.
  11791. */
  11792. readonly name: string;
  11793. /**
  11794. * The scene the component belongs to.
  11795. */
  11796. scene: Scene;
  11797. /** @hidden */
  11798. private _spritePredicate;
  11799. /**
  11800. * Creates a new instance of the component for the given scene
  11801. * @param scene Defines the scene to register the component in
  11802. */
  11803. constructor(scene: Scene);
  11804. /**
  11805. * Registers the component in a given scene
  11806. */
  11807. register(): void;
  11808. /**
  11809. * Rebuilds the elements related to this component in case of
  11810. * context lost for instance.
  11811. */
  11812. rebuild(): void;
  11813. /**
  11814. * Disposes the component and the associated ressources.
  11815. */
  11816. dispose(): void;
  11817. private _pickSpriteButKeepRay;
  11818. private _pointerMove;
  11819. private _pointerDown;
  11820. private _pointerUp;
  11821. }
  11822. }
  11823. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11824. /** @hidden */
  11825. export var fogFragmentDeclaration: {
  11826. name: string;
  11827. shader: string;
  11828. };
  11829. }
  11830. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11831. /** @hidden */
  11832. export var fogFragment: {
  11833. name: string;
  11834. shader: string;
  11835. };
  11836. }
  11837. declare module "babylonjs/Shaders/sprites.fragment" {
  11838. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11839. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11840. /** @hidden */
  11841. export var spritesPixelShader: {
  11842. name: string;
  11843. shader: string;
  11844. };
  11845. }
  11846. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11847. /** @hidden */
  11848. export var fogVertexDeclaration: {
  11849. name: string;
  11850. shader: string;
  11851. };
  11852. }
  11853. declare module "babylonjs/Shaders/sprites.vertex" {
  11854. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11855. /** @hidden */
  11856. export var spritesVertexShader: {
  11857. name: string;
  11858. shader: string;
  11859. };
  11860. }
  11861. declare module "babylonjs/Sprites/spriteManager" {
  11862. import { IDisposable, Scene } from "babylonjs/scene";
  11863. import { Nullable } from "babylonjs/types";
  11864. import { Observable } from "babylonjs/Misc/observable";
  11865. import { Sprite } from "babylonjs/Sprites/sprite";
  11866. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11867. import { Camera } from "babylonjs/Cameras/camera";
  11868. import { Texture } from "babylonjs/Materials/Textures/texture";
  11869. import "babylonjs/Shaders/sprites.fragment";
  11870. import "babylonjs/Shaders/sprites.vertex";
  11871. import { Ray } from "babylonjs/Culling/ray";
  11872. /**
  11873. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11874. */
  11875. export interface ISpriteManager extends IDisposable {
  11876. /**
  11877. * Restricts the camera to viewing objects with the same layerMask.
  11878. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11879. */
  11880. layerMask: number;
  11881. /**
  11882. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11883. */
  11884. isPickable: boolean;
  11885. /**
  11886. * Specifies the rendering group id for this mesh (0 by default)
  11887. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11888. */
  11889. renderingGroupId: number;
  11890. /**
  11891. * Defines the list of sprites managed by the manager.
  11892. */
  11893. sprites: Array<Sprite>;
  11894. /**
  11895. * Tests the intersection of a sprite with a specific ray.
  11896. * @param ray The ray we are sending to test the collision
  11897. * @param camera The camera space we are sending rays in
  11898. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11899. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11900. * @returns picking info or null.
  11901. */
  11902. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11903. /**
  11904. * Renders the list of sprites on screen.
  11905. */
  11906. render(): void;
  11907. }
  11908. /**
  11909. * Class used to manage multiple sprites on the same spritesheet
  11910. * @see http://doc.babylonjs.com/babylon101/sprites
  11911. */
  11912. export class SpriteManager implements ISpriteManager {
  11913. /** defines the manager's name */
  11914. name: string;
  11915. /** Gets the list of sprites */
  11916. sprites: Sprite[];
  11917. /** Gets or sets the rendering group id (0 by default) */
  11918. renderingGroupId: number;
  11919. /** Gets or sets camera layer mask */
  11920. layerMask: number;
  11921. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11922. fogEnabled: boolean;
  11923. /** Gets or sets a boolean indicating if the sprites are pickable */
  11924. isPickable: boolean;
  11925. /** Defines the default width of a cell in the spritesheet */
  11926. cellWidth: number;
  11927. /** Defines the default height of a cell in the spritesheet */
  11928. cellHeight: number;
  11929. /**
  11930. * An event triggered when the manager is disposed.
  11931. */
  11932. onDisposeObservable: Observable<SpriteManager>;
  11933. private _onDisposeObserver;
  11934. /**
  11935. * Callback called when the manager is disposed
  11936. */
  11937. onDispose: () => void;
  11938. private _capacity;
  11939. private _spriteTexture;
  11940. private _epsilon;
  11941. private _scene;
  11942. private _vertexData;
  11943. private _buffer;
  11944. private _vertexBuffers;
  11945. private _indexBuffer;
  11946. private _effectBase;
  11947. private _effectFog;
  11948. /**
  11949. * Gets or sets the spritesheet texture
  11950. */
  11951. texture: Texture;
  11952. /**
  11953. * Creates a new sprite manager
  11954. * @param name defines the manager's name
  11955. * @param imgUrl defines the sprite sheet url
  11956. * @param capacity defines the maximum allowed number of sprites
  11957. * @param cellSize defines the size of a sprite cell
  11958. * @param scene defines the hosting scene
  11959. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11960. * @param samplingMode defines the smapling mode to use with spritesheet
  11961. */
  11962. constructor(
  11963. /** defines the manager's name */
  11964. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11965. private _appendSpriteVertex;
  11966. /**
  11967. * Intersects the sprites with a ray
  11968. * @param ray defines the ray to intersect with
  11969. * @param camera defines the current active camera
  11970. * @param predicate defines a predicate used to select candidate sprites
  11971. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11972. * @returns null if no hit or a PickingInfo
  11973. */
  11974. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11975. /**
  11976. * Render all child sprites
  11977. */
  11978. render(): void;
  11979. /**
  11980. * Release associated resources
  11981. */
  11982. dispose(): void;
  11983. }
  11984. }
  11985. declare module "babylonjs/Sprites/sprite" {
  11986. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11987. import { Nullable } from "babylonjs/types";
  11988. import { ActionManager } from "babylonjs/Actions/actionManager";
  11989. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11990. /**
  11991. * Class used to represent a sprite
  11992. * @see http://doc.babylonjs.com/babylon101/sprites
  11993. */
  11994. export class Sprite {
  11995. /** defines the name */
  11996. name: string;
  11997. /** Gets or sets the current world position */
  11998. position: Vector3;
  11999. /** Gets or sets the main color */
  12000. color: Color4;
  12001. /** Gets or sets the width */
  12002. width: number;
  12003. /** Gets or sets the height */
  12004. height: number;
  12005. /** Gets or sets rotation angle */
  12006. angle: number;
  12007. /** Gets or sets the cell index in the sprite sheet */
  12008. cellIndex: number;
  12009. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12010. invertU: number;
  12011. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12012. invertV: number;
  12013. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12014. disposeWhenFinishedAnimating: boolean;
  12015. /** Gets the list of attached animations */
  12016. animations: Animation[];
  12017. /** Gets or sets a boolean indicating if the sprite can be picked */
  12018. isPickable: boolean;
  12019. /**
  12020. * Gets or sets the associated action manager
  12021. */
  12022. actionManager: Nullable<ActionManager>;
  12023. private _animationStarted;
  12024. private _loopAnimation;
  12025. private _fromIndex;
  12026. private _toIndex;
  12027. private _delay;
  12028. private _direction;
  12029. private _manager;
  12030. private _time;
  12031. private _onAnimationEnd;
  12032. /**
  12033. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12034. */
  12035. isVisible: boolean;
  12036. /**
  12037. * Gets or sets the sprite size
  12038. */
  12039. size: number;
  12040. /**
  12041. * Creates a new Sprite
  12042. * @param name defines the name
  12043. * @param manager defines the manager
  12044. */
  12045. constructor(
  12046. /** defines the name */
  12047. name: string, manager: ISpriteManager);
  12048. /**
  12049. * Starts an animation
  12050. * @param from defines the initial key
  12051. * @param to defines the end key
  12052. * @param loop defines if the animation must loop
  12053. * @param delay defines the start delay (in ms)
  12054. * @param onAnimationEnd defines a callback to call when animation ends
  12055. */
  12056. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12057. /** Stops current animation (if any) */
  12058. stopAnimation(): void;
  12059. /** @hidden */
  12060. _animate(deltaTime: number): void;
  12061. /** Release associated resources */
  12062. dispose(): void;
  12063. }
  12064. }
  12065. declare module "babylonjs/Collisions/pickingInfo" {
  12066. import { Nullable } from "babylonjs/types";
  12067. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12069. import { Sprite } from "babylonjs/Sprites/sprite";
  12070. import { Ray } from "babylonjs/Culling/ray";
  12071. /**
  12072. * Information about the result of picking within a scene
  12073. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12074. */
  12075. export class PickingInfo {
  12076. /** @hidden */
  12077. _pickingUnavailable: boolean;
  12078. /**
  12079. * If the pick collided with an object
  12080. */
  12081. hit: boolean;
  12082. /**
  12083. * Distance away where the pick collided
  12084. */
  12085. distance: number;
  12086. /**
  12087. * The location of pick collision
  12088. */
  12089. pickedPoint: Nullable<Vector3>;
  12090. /**
  12091. * The mesh corresponding the the pick collision
  12092. */
  12093. pickedMesh: Nullable<AbstractMesh>;
  12094. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12095. bu: number;
  12096. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12097. bv: number;
  12098. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12099. faceId: number;
  12100. /** Id of the the submesh that was picked */
  12101. subMeshId: number;
  12102. /** If a sprite was picked, this will be the sprite the pick collided with */
  12103. pickedSprite: Nullable<Sprite>;
  12104. /**
  12105. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12106. */
  12107. originMesh: Nullable<AbstractMesh>;
  12108. /**
  12109. * The ray that was used to perform the picking.
  12110. */
  12111. ray: Nullable<Ray>;
  12112. /**
  12113. * Gets the normal correspodning to the face the pick collided with
  12114. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12115. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12116. * @returns The normal correspodning to the face the pick collided with
  12117. */
  12118. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12119. /**
  12120. * Gets the texture coordinates of where the pick occured
  12121. * @returns the vector containing the coordnates of the texture
  12122. */
  12123. getTextureCoordinates(): Nullable<Vector2>;
  12124. }
  12125. }
  12126. declare module "babylonjs/Events/pointerEvents" {
  12127. import { Nullable } from "babylonjs/types";
  12128. import { Vector2 } from "babylonjs/Maths/math";
  12129. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12130. import { Ray } from "babylonjs/Culling/ray";
  12131. /**
  12132. * Gather the list of pointer event types as constants.
  12133. */
  12134. export class PointerEventTypes {
  12135. /**
  12136. * 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.
  12137. */
  12138. static readonly POINTERDOWN: number;
  12139. /**
  12140. * The pointerup event is fired when a pointer is no longer active.
  12141. */
  12142. static readonly POINTERUP: number;
  12143. /**
  12144. * The pointermove event is fired when a pointer changes coordinates.
  12145. */
  12146. static readonly POINTERMOVE: number;
  12147. /**
  12148. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12149. */
  12150. static readonly POINTERWHEEL: number;
  12151. /**
  12152. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12153. */
  12154. static readonly POINTERPICK: number;
  12155. /**
  12156. * The pointertap event is fired when a the object has been touched and released without drag.
  12157. */
  12158. static readonly POINTERTAP: number;
  12159. /**
  12160. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12161. */
  12162. static readonly POINTERDOUBLETAP: number;
  12163. }
  12164. /**
  12165. * Base class of pointer info types.
  12166. */
  12167. export class PointerInfoBase {
  12168. /**
  12169. * Defines the type of event (PointerEventTypes)
  12170. */
  12171. type: number;
  12172. /**
  12173. * Defines the related dom event
  12174. */
  12175. event: PointerEvent | MouseWheelEvent;
  12176. /**
  12177. * Instantiates the base class of pointers info.
  12178. * @param type Defines the type of event (PointerEventTypes)
  12179. * @param event Defines the related dom event
  12180. */
  12181. constructor(
  12182. /**
  12183. * Defines the type of event (PointerEventTypes)
  12184. */
  12185. type: number,
  12186. /**
  12187. * Defines the related dom event
  12188. */
  12189. event: PointerEvent | MouseWheelEvent);
  12190. }
  12191. /**
  12192. * This class is used to store pointer related info for the onPrePointerObservable event.
  12193. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12194. */
  12195. export class PointerInfoPre extends PointerInfoBase {
  12196. /**
  12197. * Ray from a pointer if availible (eg. 6dof controller)
  12198. */
  12199. ray: Nullable<Ray>;
  12200. /**
  12201. * Defines the local position of the pointer on the canvas.
  12202. */
  12203. localPosition: Vector2;
  12204. /**
  12205. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12206. */
  12207. skipOnPointerObservable: boolean;
  12208. /**
  12209. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12210. * @param type Defines the type of event (PointerEventTypes)
  12211. * @param event Defines the related dom event
  12212. * @param localX Defines the local x coordinates of the pointer when the event occured
  12213. * @param localY Defines the local y coordinates of the pointer when the event occured
  12214. */
  12215. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12216. }
  12217. /**
  12218. * This type contains all the data related to a pointer event in Babylon.js.
  12219. * 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.
  12220. */
  12221. export class PointerInfo extends PointerInfoBase {
  12222. /**
  12223. * Defines the picking info associated to the info (if any)\
  12224. */
  12225. pickInfo: Nullable<PickingInfo>;
  12226. /**
  12227. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12228. * @param type Defines the type of event (PointerEventTypes)
  12229. * @param event Defines the related dom event
  12230. * @param pickInfo Defines the picking info associated to the info (if any)\
  12231. */
  12232. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12233. /**
  12234. * Defines the picking info associated to the info (if any)\
  12235. */
  12236. pickInfo: Nullable<PickingInfo>);
  12237. }
  12238. /**
  12239. * Data relating to a touch event on the screen.
  12240. */
  12241. export interface PointerTouch {
  12242. /**
  12243. * X coordinate of touch.
  12244. */
  12245. x: number;
  12246. /**
  12247. * Y coordinate of touch.
  12248. */
  12249. y: number;
  12250. /**
  12251. * Id of touch. Unique for each finger.
  12252. */
  12253. pointerId: number;
  12254. /**
  12255. * Event type passed from DOM.
  12256. */
  12257. type: any;
  12258. }
  12259. }
  12260. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12261. import { Nullable } from "babylonjs/types";
  12262. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12263. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12264. /**
  12265. * Manage the mouse inputs to control the movement of a free camera.
  12266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12267. */
  12268. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12269. /**
  12270. * Define if touch is enabled in the mouse input
  12271. */
  12272. touchEnabled: boolean;
  12273. /**
  12274. * Defines the camera the input is attached to.
  12275. */
  12276. camera: FreeCamera;
  12277. /**
  12278. * Defines the buttons associated with the input to handle camera move.
  12279. */
  12280. buttons: number[];
  12281. /**
  12282. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12283. */
  12284. angularSensibility: number;
  12285. private _pointerInput;
  12286. private _onMouseMove;
  12287. private _observer;
  12288. private previousPosition;
  12289. /**
  12290. * Manage the mouse inputs to control the movement of a free camera.
  12291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12292. * @param touchEnabled Defines if touch is enabled or not
  12293. */
  12294. constructor(
  12295. /**
  12296. * Define if touch is enabled in the mouse input
  12297. */
  12298. touchEnabled?: boolean);
  12299. /**
  12300. * Attach the input controls to a specific dom element to get the input from.
  12301. * @param element Defines the element the controls should be listened from
  12302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12303. */
  12304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12305. /**
  12306. * Called on JS contextmenu event.
  12307. * Override this method to provide functionality.
  12308. */
  12309. protected onContextMenu(evt: PointerEvent): void;
  12310. /**
  12311. * Detach the current controls from the specified dom element.
  12312. * @param element Defines the element to stop listening the inputs from
  12313. */
  12314. detachControl(element: Nullable<HTMLElement>): void;
  12315. /**
  12316. * Gets the class name of the current intput.
  12317. * @returns the class name
  12318. */
  12319. getClassName(): string;
  12320. /**
  12321. * Get the friendly name associated with the input class.
  12322. * @returns the input friendly name
  12323. */
  12324. getSimpleName(): string;
  12325. }
  12326. }
  12327. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12328. import { Nullable } from "babylonjs/types";
  12329. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12330. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12331. /**
  12332. * Manage the touch inputs to control the movement of a free camera.
  12333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12334. */
  12335. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12336. /**
  12337. * Defines the camera the input is attached to.
  12338. */
  12339. camera: FreeCamera;
  12340. /**
  12341. * Defines the touch sensibility for rotation.
  12342. * The higher the faster.
  12343. */
  12344. touchAngularSensibility: number;
  12345. /**
  12346. * Defines the touch sensibility for move.
  12347. * The higher the faster.
  12348. */
  12349. touchMoveSensibility: number;
  12350. private _offsetX;
  12351. private _offsetY;
  12352. private _pointerPressed;
  12353. private _pointerInput;
  12354. private _observer;
  12355. private _onLostFocus;
  12356. /**
  12357. * Attach the input controls to a specific dom element to get the input from.
  12358. * @param element Defines the element the controls should be listened from
  12359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12360. */
  12361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12362. /**
  12363. * Detach the current controls from the specified dom element.
  12364. * @param element Defines the element to stop listening the inputs from
  12365. */
  12366. detachControl(element: Nullable<HTMLElement>): void;
  12367. /**
  12368. * Update the current camera state depending on the inputs that have been used this frame.
  12369. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12370. */
  12371. checkInputs(): void;
  12372. /**
  12373. * Gets the class name of the current intput.
  12374. * @returns the class name
  12375. */
  12376. getClassName(): string;
  12377. /**
  12378. * Get the friendly name associated with the input class.
  12379. * @returns the input friendly name
  12380. */
  12381. getSimpleName(): string;
  12382. }
  12383. }
  12384. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12385. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12386. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12387. /**
  12388. * Default Inputs manager for the FreeCamera.
  12389. * It groups all the default supported inputs for ease of use.
  12390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12391. */
  12392. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12393. /**
  12394. * Instantiates a new FreeCameraInputsManager.
  12395. * @param camera Defines the camera the inputs belong to
  12396. */
  12397. constructor(camera: FreeCamera);
  12398. /**
  12399. * Add keyboard input support to the input manager.
  12400. * @returns the current input manager
  12401. */
  12402. addKeyboard(): FreeCameraInputsManager;
  12403. /**
  12404. * Add mouse input support to the input manager.
  12405. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12406. * @returns the current input manager
  12407. */
  12408. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12409. /**
  12410. * Add touch input support to the input manager.
  12411. * @returns the current input manager
  12412. */
  12413. addTouch(): FreeCameraInputsManager;
  12414. }
  12415. }
  12416. declare module "babylonjs/Cameras/freeCamera" {
  12417. import { Vector3 } from "babylonjs/Maths/math";
  12418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12419. import { Scene } from "babylonjs/scene";
  12420. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12421. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12422. /**
  12423. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12424. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12425. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12426. */
  12427. export class FreeCamera extends TargetCamera {
  12428. /**
  12429. * Define the collision ellipsoid of the camera.
  12430. * This is helpful to simulate a camera body like the player body around the camera
  12431. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12432. */
  12433. ellipsoid: Vector3;
  12434. /**
  12435. * Define an offset for the position of the ellipsoid around the camera.
  12436. * This can be helpful to determine the center of the body near the gravity center of the body
  12437. * instead of its head.
  12438. */
  12439. ellipsoidOffset: Vector3;
  12440. /**
  12441. * Enable or disable collisions of the camera with the rest of the scene objects.
  12442. */
  12443. checkCollisions: boolean;
  12444. /**
  12445. * Enable or disable gravity on the camera.
  12446. */
  12447. applyGravity: boolean;
  12448. /**
  12449. * Define the input manager associated to the camera.
  12450. */
  12451. inputs: FreeCameraInputsManager;
  12452. /**
  12453. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12454. * Higher values reduce sensitivity.
  12455. */
  12456. /**
  12457. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12458. * Higher values reduce sensitivity.
  12459. */
  12460. angularSensibility: number;
  12461. /**
  12462. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12463. */
  12464. keysUp: number[];
  12465. /**
  12466. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12467. */
  12468. keysDown: number[];
  12469. /**
  12470. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12471. */
  12472. keysLeft: number[];
  12473. /**
  12474. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12475. */
  12476. keysRight: number[];
  12477. /**
  12478. * Event raised when the camera collide with a mesh in the scene.
  12479. */
  12480. onCollide: (collidedMesh: AbstractMesh) => void;
  12481. private _collider;
  12482. private _needMoveForGravity;
  12483. private _oldPosition;
  12484. private _diffPosition;
  12485. private _newPosition;
  12486. /** @hidden */
  12487. _localDirection: Vector3;
  12488. /** @hidden */
  12489. _transformedDirection: Vector3;
  12490. /**
  12491. * Instantiates a Free Camera.
  12492. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12493. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12494. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12495. * @param name Define the name of the camera in the scene
  12496. * @param position Define the start position of the camera in the scene
  12497. * @param scene Define the scene the camera belongs to
  12498. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12499. */
  12500. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12501. /**
  12502. * Attached controls to the current camera.
  12503. * @param element Defines the element the controls should be listened from
  12504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12505. */
  12506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12507. /**
  12508. * Detach the current controls from the camera.
  12509. * The camera will stop reacting to inputs.
  12510. * @param element Defines the element to stop listening the inputs from
  12511. */
  12512. detachControl(element: HTMLElement): void;
  12513. private _collisionMask;
  12514. /**
  12515. * Define a collision mask to limit the list of object the camera can collide with
  12516. */
  12517. collisionMask: number;
  12518. /** @hidden */
  12519. _collideWithWorld(displacement: Vector3): void;
  12520. private _onCollisionPositionChange;
  12521. /** @hidden */
  12522. _checkInputs(): void;
  12523. /** @hidden */
  12524. _decideIfNeedsToMove(): boolean;
  12525. /** @hidden */
  12526. _updatePosition(): void;
  12527. /**
  12528. * Destroy the camera and release the current resources hold by it.
  12529. */
  12530. dispose(): void;
  12531. /**
  12532. * Gets the current object class name.
  12533. * @return the class name
  12534. */
  12535. getClassName(): string;
  12536. }
  12537. }
  12538. declare module "babylonjs/Gamepads/gamepad" {
  12539. import { Observable } from "babylonjs/Misc/observable";
  12540. /**
  12541. * Represents a gamepad control stick position
  12542. */
  12543. export class StickValues {
  12544. /**
  12545. * The x component of the control stick
  12546. */
  12547. x: number;
  12548. /**
  12549. * The y component of the control stick
  12550. */
  12551. y: number;
  12552. /**
  12553. * Initializes the gamepad x and y control stick values
  12554. * @param x The x component of the gamepad control stick value
  12555. * @param y The y component of the gamepad control stick value
  12556. */
  12557. constructor(
  12558. /**
  12559. * The x component of the control stick
  12560. */
  12561. x: number,
  12562. /**
  12563. * The y component of the control stick
  12564. */
  12565. y: number);
  12566. }
  12567. /**
  12568. * An interface which manages callbacks for gamepad button changes
  12569. */
  12570. export interface GamepadButtonChanges {
  12571. /**
  12572. * Called when a gamepad has been changed
  12573. */
  12574. changed: boolean;
  12575. /**
  12576. * Called when a gamepad press event has been triggered
  12577. */
  12578. pressChanged: boolean;
  12579. /**
  12580. * Called when a touch event has been triggered
  12581. */
  12582. touchChanged: boolean;
  12583. /**
  12584. * Called when a value has changed
  12585. */
  12586. valueChanged: boolean;
  12587. }
  12588. /**
  12589. * Represents a gamepad
  12590. */
  12591. export class Gamepad {
  12592. /**
  12593. * The id of the gamepad
  12594. */
  12595. id: string;
  12596. /**
  12597. * The index of the gamepad
  12598. */
  12599. index: number;
  12600. /**
  12601. * The browser gamepad
  12602. */
  12603. browserGamepad: any;
  12604. /**
  12605. * Specifies what type of gamepad this represents
  12606. */
  12607. type: number;
  12608. private _leftStick;
  12609. private _rightStick;
  12610. /** @hidden */
  12611. _isConnected: boolean;
  12612. private _leftStickAxisX;
  12613. private _leftStickAxisY;
  12614. private _rightStickAxisX;
  12615. private _rightStickAxisY;
  12616. /**
  12617. * Triggered when the left control stick has been changed
  12618. */
  12619. private _onleftstickchanged;
  12620. /**
  12621. * Triggered when the right control stick has been changed
  12622. */
  12623. private _onrightstickchanged;
  12624. /**
  12625. * Represents a gamepad controller
  12626. */
  12627. static GAMEPAD: number;
  12628. /**
  12629. * Represents a generic controller
  12630. */
  12631. static GENERIC: number;
  12632. /**
  12633. * Represents an XBox controller
  12634. */
  12635. static XBOX: number;
  12636. /**
  12637. * Represents a pose-enabled controller
  12638. */
  12639. static POSE_ENABLED: number;
  12640. /**
  12641. * Specifies whether the left control stick should be Y-inverted
  12642. */
  12643. protected _invertLeftStickY: boolean;
  12644. /**
  12645. * Specifies if the gamepad has been connected
  12646. */
  12647. readonly isConnected: boolean;
  12648. /**
  12649. * Initializes the gamepad
  12650. * @param id The id of the gamepad
  12651. * @param index The index of the gamepad
  12652. * @param browserGamepad The browser gamepad
  12653. * @param leftStickX The x component of the left joystick
  12654. * @param leftStickY The y component of the left joystick
  12655. * @param rightStickX The x component of the right joystick
  12656. * @param rightStickY The y component of the right joystick
  12657. */
  12658. constructor(
  12659. /**
  12660. * The id of the gamepad
  12661. */
  12662. id: string,
  12663. /**
  12664. * The index of the gamepad
  12665. */
  12666. index: number,
  12667. /**
  12668. * The browser gamepad
  12669. */
  12670. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12671. /**
  12672. * Callback triggered when the left joystick has changed
  12673. * @param callback
  12674. */
  12675. onleftstickchanged(callback: (values: StickValues) => void): void;
  12676. /**
  12677. * Callback triggered when the right joystick has changed
  12678. * @param callback
  12679. */
  12680. onrightstickchanged(callback: (values: StickValues) => void): void;
  12681. /**
  12682. * Gets the left joystick
  12683. */
  12684. /**
  12685. * Sets the left joystick values
  12686. */
  12687. leftStick: StickValues;
  12688. /**
  12689. * Gets the right joystick
  12690. */
  12691. /**
  12692. * Sets the right joystick value
  12693. */
  12694. rightStick: StickValues;
  12695. /**
  12696. * Updates the gamepad joystick positions
  12697. */
  12698. update(): void;
  12699. /**
  12700. * Disposes the gamepad
  12701. */
  12702. dispose(): void;
  12703. }
  12704. /**
  12705. * Represents a generic gamepad
  12706. */
  12707. export class GenericPad extends Gamepad {
  12708. private _buttons;
  12709. private _onbuttondown;
  12710. private _onbuttonup;
  12711. /**
  12712. * Observable triggered when a button has been pressed
  12713. */
  12714. onButtonDownObservable: Observable<number>;
  12715. /**
  12716. * Observable triggered when a button has been released
  12717. */
  12718. onButtonUpObservable: Observable<number>;
  12719. /**
  12720. * Callback triggered when a button has been pressed
  12721. * @param callback Called when a button has been pressed
  12722. */
  12723. onbuttondown(callback: (buttonPressed: number) => void): void;
  12724. /**
  12725. * Callback triggered when a button has been released
  12726. * @param callback Called when a button has been released
  12727. */
  12728. onbuttonup(callback: (buttonReleased: number) => void): void;
  12729. /**
  12730. * Initializes the generic gamepad
  12731. * @param id The id of the generic gamepad
  12732. * @param index The index of the generic gamepad
  12733. * @param browserGamepad The browser gamepad
  12734. */
  12735. constructor(id: string, index: number, browserGamepad: any);
  12736. private _setButtonValue;
  12737. /**
  12738. * Updates the generic gamepad
  12739. */
  12740. update(): void;
  12741. /**
  12742. * Disposes the generic gamepad
  12743. */
  12744. dispose(): void;
  12745. }
  12746. }
  12747. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12748. import { Observable } from "babylonjs/Misc/observable";
  12749. import { Nullable } from "babylonjs/types";
  12750. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12751. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12753. import { Ray } from "babylonjs/Culling/ray";
  12754. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12755. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12756. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12757. /**
  12758. * Defines the types of pose enabled controllers that are supported
  12759. */
  12760. export enum PoseEnabledControllerType {
  12761. /**
  12762. * HTC Vive
  12763. */
  12764. VIVE = 0,
  12765. /**
  12766. * Oculus Rift
  12767. */
  12768. OCULUS = 1,
  12769. /**
  12770. * Windows mixed reality
  12771. */
  12772. WINDOWS = 2,
  12773. /**
  12774. * Samsung gear VR
  12775. */
  12776. GEAR_VR = 3,
  12777. /**
  12778. * Google Daydream
  12779. */
  12780. DAYDREAM = 4,
  12781. /**
  12782. * Generic
  12783. */
  12784. GENERIC = 5
  12785. }
  12786. /**
  12787. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12788. */
  12789. export interface MutableGamepadButton {
  12790. /**
  12791. * Value of the button/trigger
  12792. */
  12793. value: number;
  12794. /**
  12795. * If the button/trigger is currently touched
  12796. */
  12797. touched: boolean;
  12798. /**
  12799. * If the button/trigger is currently pressed
  12800. */
  12801. pressed: boolean;
  12802. }
  12803. /**
  12804. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12805. * @hidden
  12806. */
  12807. export interface ExtendedGamepadButton extends GamepadButton {
  12808. /**
  12809. * If the button/trigger is currently pressed
  12810. */
  12811. readonly pressed: boolean;
  12812. /**
  12813. * If the button/trigger is currently touched
  12814. */
  12815. readonly touched: boolean;
  12816. /**
  12817. * Value of the button/trigger
  12818. */
  12819. readonly value: number;
  12820. }
  12821. /** @hidden */
  12822. export interface _GamePadFactory {
  12823. /**
  12824. * Returns wether or not the current gamepad can be created for this type of controller.
  12825. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12826. * @returns true if it can be created, otherwise false
  12827. */
  12828. canCreate(gamepadInfo: any): boolean;
  12829. /**
  12830. * Creates a new instance of the Gamepad.
  12831. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12832. * @returns the new gamepad instance
  12833. */
  12834. create(gamepadInfo: any): Gamepad;
  12835. }
  12836. /**
  12837. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12838. */
  12839. export class PoseEnabledControllerHelper {
  12840. /** @hidden */
  12841. static _ControllerFactories: _GamePadFactory[];
  12842. /** @hidden */
  12843. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12844. /**
  12845. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12846. * @param vrGamepad the gamepad to initialized
  12847. * @returns a vr controller of the type the gamepad identified as
  12848. */
  12849. static InitiateController(vrGamepad: any): Gamepad;
  12850. }
  12851. /**
  12852. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12853. */
  12854. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12855. private _deviceRoomPosition;
  12856. private _deviceRoomRotationQuaternion;
  12857. /**
  12858. * The device position in babylon space
  12859. */
  12860. devicePosition: Vector3;
  12861. /**
  12862. * The device rotation in babylon space
  12863. */
  12864. deviceRotationQuaternion: Quaternion;
  12865. /**
  12866. * The scale factor of the device in babylon space
  12867. */
  12868. deviceScaleFactor: number;
  12869. /**
  12870. * (Likely devicePosition should be used instead) The device position in its room space
  12871. */
  12872. position: Vector3;
  12873. /**
  12874. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12875. */
  12876. rotationQuaternion: Quaternion;
  12877. /**
  12878. * The type of controller (Eg. Windows mixed reality)
  12879. */
  12880. controllerType: PoseEnabledControllerType;
  12881. protected _calculatedPosition: Vector3;
  12882. private _calculatedRotation;
  12883. /**
  12884. * The raw pose from the device
  12885. */
  12886. rawPose: DevicePose;
  12887. private _trackPosition;
  12888. private _maxRotationDistFromHeadset;
  12889. private _draggedRoomRotation;
  12890. /**
  12891. * @hidden
  12892. */
  12893. _disableTrackPosition(fixedPosition: Vector3): void;
  12894. /**
  12895. * Internal, the mesh attached to the controller
  12896. * @hidden
  12897. */
  12898. _mesh: Nullable<AbstractMesh>;
  12899. private _poseControlledCamera;
  12900. private _leftHandSystemQuaternion;
  12901. /**
  12902. * Internal, matrix used to convert room space to babylon space
  12903. * @hidden
  12904. */
  12905. _deviceToWorld: Matrix;
  12906. /**
  12907. * Node to be used when casting a ray from the controller
  12908. * @hidden
  12909. */
  12910. _pointingPoseNode: Nullable<TransformNode>;
  12911. /**
  12912. * Name of the child mesh that can be used to cast a ray from the controller
  12913. */
  12914. static readonly POINTING_POSE: string;
  12915. /**
  12916. * Creates a new PoseEnabledController from a gamepad
  12917. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12918. */
  12919. constructor(browserGamepad: any);
  12920. private _workingMatrix;
  12921. /**
  12922. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12923. */
  12924. update(): void;
  12925. /**
  12926. * Updates only the pose device and mesh without doing any button event checking
  12927. */
  12928. protected _updatePoseAndMesh(): void;
  12929. /**
  12930. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12931. * @param poseData raw pose fromthe device
  12932. */
  12933. updateFromDevice(poseData: DevicePose): void;
  12934. /**
  12935. * @hidden
  12936. */
  12937. _meshAttachedObservable: Observable<AbstractMesh>;
  12938. /**
  12939. * Attaches a mesh to the controller
  12940. * @param mesh the mesh to be attached
  12941. */
  12942. attachToMesh(mesh: AbstractMesh): void;
  12943. /**
  12944. * Attaches the controllers mesh to a camera
  12945. * @param camera the camera the mesh should be attached to
  12946. */
  12947. attachToPoseControlledCamera(camera: TargetCamera): void;
  12948. /**
  12949. * Disposes of the controller
  12950. */
  12951. dispose(): void;
  12952. /**
  12953. * The mesh that is attached to the controller
  12954. */
  12955. readonly mesh: Nullable<AbstractMesh>;
  12956. /**
  12957. * Gets the ray of the controller in the direction the controller is pointing
  12958. * @param length the length the resulting ray should be
  12959. * @returns a ray in the direction the controller is pointing
  12960. */
  12961. getForwardRay(length?: number): Ray;
  12962. }
  12963. }
  12964. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12965. import { Observable } from "babylonjs/Misc/observable";
  12966. import { Scene } from "babylonjs/scene";
  12967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12968. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12969. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12970. /**
  12971. * Defines the WebVRController object that represents controllers tracked in 3D space
  12972. */
  12973. export abstract class WebVRController extends PoseEnabledController {
  12974. /**
  12975. * Internal, the default controller model for the controller
  12976. */
  12977. protected _defaultModel: AbstractMesh;
  12978. /**
  12979. * Fired when the trigger state has changed
  12980. */
  12981. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12982. /**
  12983. * Fired when the main button state has changed
  12984. */
  12985. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12986. /**
  12987. * Fired when the secondary button state has changed
  12988. */
  12989. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12990. /**
  12991. * Fired when the pad state has changed
  12992. */
  12993. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12994. /**
  12995. * Fired when controllers stick values have changed
  12996. */
  12997. onPadValuesChangedObservable: Observable<StickValues>;
  12998. /**
  12999. * Array of button availible on the controller
  13000. */
  13001. protected _buttons: Array<MutableGamepadButton>;
  13002. private _onButtonStateChange;
  13003. /**
  13004. * Fired when a controller button's state has changed
  13005. * @param callback the callback containing the button that was modified
  13006. */
  13007. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13008. /**
  13009. * X and Y axis corrisponding to the controllers joystick
  13010. */
  13011. pad: StickValues;
  13012. /**
  13013. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13014. */
  13015. hand: string;
  13016. /**
  13017. * The default controller model for the controller
  13018. */
  13019. readonly defaultModel: AbstractMesh;
  13020. /**
  13021. * Creates a new WebVRController from a gamepad
  13022. * @param vrGamepad the gamepad that the WebVRController should be created from
  13023. */
  13024. constructor(vrGamepad: any);
  13025. /**
  13026. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13027. */
  13028. update(): void;
  13029. /**
  13030. * Function to be called when a button is modified
  13031. */
  13032. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13033. /**
  13034. * Loads a mesh and attaches it to the controller
  13035. * @param scene the scene the mesh should be added to
  13036. * @param meshLoaded callback for when the mesh has been loaded
  13037. */
  13038. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13039. private _setButtonValue;
  13040. private _changes;
  13041. private _checkChanges;
  13042. /**
  13043. * Disposes of th webVRCOntroller
  13044. */
  13045. dispose(): void;
  13046. }
  13047. }
  13048. declare module "babylonjs/Lights/hemisphericLight" {
  13049. import { Nullable } from "babylonjs/types";
  13050. import { Scene } from "babylonjs/scene";
  13051. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13052. import { Effect } from "babylonjs/Materials/effect";
  13053. import { Light } from "babylonjs/Lights/light";
  13054. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13055. /**
  13056. * The HemisphericLight simulates the ambient environment light,
  13057. * so the passed direction is the light reflection direction, not the incoming direction.
  13058. */
  13059. export class HemisphericLight extends Light {
  13060. /**
  13061. * The groundColor is the light in the opposite direction to the one specified during creation.
  13062. * 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.
  13063. */
  13064. groundColor: Color3;
  13065. /**
  13066. * The light reflection direction, not the incoming direction.
  13067. */
  13068. direction: Vector3;
  13069. /**
  13070. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13071. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13072. * The HemisphericLight can't cast shadows.
  13073. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13074. * @param name The friendly name of the light
  13075. * @param direction The direction of the light reflection
  13076. * @param scene The scene the light belongs to
  13077. */
  13078. constructor(name: string, direction: Vector3, scene: Scene);
  13079. protected _buildUniformLayout(): void;
  13080. /**
  13081. * Returns the string "HemisphericLight".
  13082. * @return The class name
  13083. */
  13084. getClassName(): string;
  13085. /**
  13086. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13087. * Returns the updated direction.
  13088. * @param target The target the direction should point to
  13089. * @return The computed direction
  13090. */
  13091. setDirectionToTarget(target: Vector3): Vector3;
  13092. /**
  13093. * Returns the shadow generator associated to the light.
  13094. * @returns Always null for hemispheric lights because it does not support shadows.
  13095. */
  13096. getShadowGenerator(): Nullable<IShadowGenerator>;
  13097. /**
  13098. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13099. * @param effect The effect to update
  13100. * @param lightIndex The index of the light in the effect to update
  13101. * @returns The hemispheric light
  13102. */
  13103. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13104. /**
  13105. * Computes the world matrix of the node
  13106. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13107. * @param useWasUpdatedFlag defines a reserved property
  13108. * @returns the world matrix
  13109. */
  13110. computeWorldMatrix(): Matrix;
  13111. /**
  13112. * Returns the integer 3.
  13113. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13114. */
  13115. getTypeID(): number;
  13116. /**
  13117. * Prepares the list of defines specific to the light type.
  13118. * @param defines the list of defines
  13119. * @param lightIndex defines the index of the light for the effect
  13120. */
  13121. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13122. }
  13123. }
  13124. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  13125. import { Matrix } from "babylonjs/Maths/math";
  13126. /**
  13127. * This represents all the required metrics to create a VR camera.
  13128. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  13129. */
  13130. export class VRCameraMetrics {
  13131. /**
  13132. * Define the horizontal resolution off the screen.
  13133. */
  13134. hResolution: number;
  13135. /**
  13136. * Define the vertical resolution off the screen.
  13137. */
  13138. vResolution: number;
  13139. /**
  13140. * Define the horizontal screen size.
  13141. */
  13142. hScreenSize: number;
  13143. /**
  13144. * Define the vertical screen size.
  13145. */
  13146. vScreenSize: number;
  13147. /**
  13148. * Define the vertical screen center position.
  13149. */
  13150. vScreenCenter: number;
  13151. /**
  13152. * Define the distance of the eyes to the screen.
  13153. */
  13154. eyeToScreenDistance: number;
  13155. /**
  13156. * Define the distance between both lenses
  13157. */
  13158. lensSeparationDistance: number;
  13159. /**
  13160. * Define the distance between both viewer's eyes.
  13161. */
  13162. interpupillaryDistance: number;
  13163. /**
  13164. * Define the distortion factor of the VR postprocess.
  13165. * Please, touch with care.
  13166. */
  13167. distortionK: number[];
  13168. /**
  13169. * Define the chromatic aberration correction factors for the VR post process.
  13170. */
  13171. chromaAbCorrection: number[];
  13172. /**
  13173. * Define the scale factor of the post process.
  13174. * The smaller the better but the slower.
  13175. */
  13176. postProcessScaleFactor: number;
  13177. /**
  13178. * Define an offset for the lens center.
  13179. */
  13180. lensCenterOffset: number;
  13181. /**
  13182. * Define if the current vr camera should compensate the distortion of the lense or not.
  13183. */
  13184. compensateDistortion: boolean;
  13185. /**
  13186. * Defines if multiview should be enabled when rendering (Default: false)
  13187. */
  13188. multiviewEnabled: boolean;
  13189. /**
  13190. * Gets the rendering aspect ratio based on the provided resolutions.
  13191. */
  13192. readonly aspectRatio: number;
  13193. /**
  13194. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  13195. */
  13196. readonly aspectRatioFov: number;
  13197. /**
  13198. * @hidden
  13199. */
  13200. readonly leftHMatrix: Matrix;
  13201. /**
  13202. * @hidden
  13203. */
  13204. readonly rightHMatrix: Matrix;
  13205. /**
  13206. * @hidden
  13207. */
  13208. readonly leftPreViewMatrix: Matrix;
  13209. /**
  13210. * @hidden
  13211. */
  13212. readonly rightPreViewMatrix: Matrix;
  13213. /**
  13214. * Get the default VRMetrics based on the most generic setup.
  13215. * @returns the default vr metrics
  13216. */
  13217. static GetDefault(): VRCameraMetrics;
  13218. }
  13219. }
  13220. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  13221. /** @hidden */
  13222. export var vrDistortionCorrectionPixelShader: {
  13223. name: string;
  13224. shader: string;
  13225. };
  13226. }
  13227. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  13228. import { Camera } from "babylonjs/Cameras/camera";
  13229. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  13230. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13231. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  13232. /**
  13233. * VRDistortionCorrectionPostProcess used for mobile VR
  13234. */
  13235. export class VRDistortionCorrectionPostProcess extends PostProcess {
  13236. private _isRightEye;
  13237. private _distortionFactors;
  13238. private _postProcessScaleFactor;
  13239. private _lensCenterOffset;
  13240. private _scaleIn;
  13241. private _scaleFactor;
  13242. private _lensCenter;
  13243. /**
  13244. * Initializes the VRDistortionCorrectionPostProcess
  13245. * @param name The name of the effect.
  13246. * @param camera The camera to apply the render pass to.
  13247. * @param isRightEye If this is for the right eye distortion
  13248. * @param vrMetrics All the required metrics for the VR camera
  13249. */
  13250. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  13251. }
  13252. /**
  13253. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13254. * This will not be used for webXR as it supports displaying texture arrays directly
  13255. */
  13256. export class VRMultiviewToSingleview extends PostProcess {
  13257. /**
  13258. * Initializes a VRMultiviewToSingleview
  13259. * @param name name of the post process
  13260. * @param camera camera to be applied to
  13261. * @param scaleFactor scaling factor to the size of the output texture
  13262. */
  13263. constructor(name: string, camera: Camera, scaleFactor: number);
  13264. }
  13265. }
  13266. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13267. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13268. import { Nullable } from "babylonjs/types";
  13269. import { Observable } from "babylonjs/Misc/observable";
  13270. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13271. import { Scene } from "babylonjs/scene";
  13272. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13273. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13274. import { Node } from "babylonjs/node";
  13275. import { Ray } from "babylonjs/Culling/ray";
  13276. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13277. /**
  13278. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13279. * IMPORTANT!! The data is right-hand data.
  13280. * @export
  13281. * @interface DevicePose
  13282. */
  13283. export interface DevicePose {
  13284. /**
  13285. * The position of the device, values in array are [x,y,z].
  13286. */
  13287. readonly position: Nullable<Float32Array>;
  13288. /**
  13289. * The linearVelocity of the device, values in array are [x,y,z].
  13290. */
  13291. readonly linearVelocity: Nullable<Float32Array>;
  13292. /**
  13293. * The linearAcceleration of the device, values in array are [x,y,z].
  13294. */
  13295. readonly linearAcceleration: Nullable<Float32Array>;
  13296. /**
  13297. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13298. */
  13299. readonly orientation: Nullable<Float32Array>;
  13300. /**
  13301. * The angularVelocity of the device, values in array are [x,y,z].
  13302. */
  13303. readonly angularVelocity: Nullable<Float32Array>;
  13304. /**
  13305. * The angularAcceleration of the device, values in array are [x,y,z].
  13306. */
  13307. readonly angularAcceleration: Nullable<Float32Array>;
  13308. }
  13309. /**
  13310. * Interface representing a pose controlled object in Babylon.
  13311. * A pose controlled object has both regular pose values as well as pose values
  13312. * from an external device such as a VR head mounted display
  13313. */
  13314. export interface PoseControlled {
  13315. /**
  13316. * The position of the object in babylon space.
  13317. */
  13318. position: Vector3;
  13319. /**
  13320. * The rotation quaternion of the object in babylon space.
  13321. */
  13322. rotationQuaternion: Quaternion;
  13323. /**
  13324. * The position of the device in babylon space.
  13325. */
  13326. devicePosition?: Vector3;
  13327. /**
  13328. * The rotation quaternion of the device in babylon space.
  13329. */
  13330. deviceRotationQuaternion: Quaternion;
  13331. /**
  13332. * The raw pose coming from the device.
  13333. */
  13334. rawPose: Nullable<DevicePose>;
  13335. /**
  13336. * The scale of the device to be used when translating from device space to babylon space.
  13337. */
  13338. deviceScaleFactor: number;
  13339. /**
  13340. * Updates the poseControlled values based on the input device pose.
  13341. * @param poseData the pose data to update the object with
  13342. */
  13343. updateFromDevice(poseData: DevicePose): void;
  13344. }
  13345. /**
  13346. * Set of options to customize the webVRCamera
  13347. */
  13348. export interface WebVROptions {
  13349. /**
  13350. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13351. */
  13352. trackPosition?: boolean;
  13353. /**
  13354. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13355. */
  13356. positionScale?: number;
  13357. /**
  13358. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13359. */
  13360. displayName?: string;
  13361. /**
  13362. * Should the native controller meshes be initialized. (default: true)
  13363. */
  13364. controllerMeshes?: boolean;
  13365. /**
  13366. * Creating a default HemiLight only on controllers. (default: true)
  13367. */
  13368. defaultLightingOnControllers?: boolean;
  13369. /**
  13370. * If you don't want to use the default VR button of the helper. (default: false)
  13371. */
  13372. useCustomVRButton?: boolean;
  13373. /**
  13374. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13375. */
  13376. customVRButton?: HTMLButtonElement;
  13377. /**
  13378. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13379. */
  13380. rayLength?: number;
  13381. /**
  13382. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13383. */
  13384. defaultHeight?: number;
  13385. /**
  13386. * If multiview should be used if availible (default: false)
  13387. */
  13388. useMultiview?: boolean;
  13389. }
  13390. /**
  13391. * This represents a WebVR camera.
  13392. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13393. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13394. */
  13395. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13396. private webVROptions;
  13397. /**
  13398. * @hidden
  13399. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13400. */
  13401. _vrDevice: any;
  13402. /**
  13403. * The rawPose of the vrDevice.
  13404. */
  13405. rawPose: Nullable<DevicePose>;
  13406. private _onVREnabled;
  13407. private _specsVersion;
  13408. private _attached;
  13409. private _frameData;
  13410. protected _descendants: Array<Node>;
  13411. private _deviceRoomPosition;
  13412. /** @hidden */
  13413. _deviceRoomRotationQuaternion: Quaternion;
  13414. private _standingMatrix;
  13415. /**
  13416. * Represents device position in babylon space.
  13417. */
  13418. devicePosition: Vector3;
  13419. /**
  13420. * Represents device rotation in babylon space.
  13421. */
  13422. deviceRotationQuaternion: Quaternion;
  13423. /**
  13424. * The scale of the device to be used when translating from device space to babylon space.
  13425. */
  13426. deviceScaleFactor: number;
  13427. private _deviceToWorld;
  13428. private _worldToDevice;
  13429. /**
  13430. * References to the webVR controllers for the vrDevice.
  13431. */
  13432. controllers: Array<WebVRController>;
  13433. /**
  13434. * Emits an event when a controller is attached.
  13435. */
  13436. onControllersAttachedObservable: Observable<WebVRController[]>;
  13437. /**
  13438. * Emits an event when a controller's mesh has been loaded;
  13439. */
  13440. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13441. /**
  13442. * Emits an event when the HMD's pose has been updated.
  13443. */
  13444. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13445. private _poseSet;
  13446. /**
  13447. * If the rig cameras be used as parent instead of this camera.
  13448. */
  13449. rigParenting: boolean;
  13450. private _lightOnControllers;
  13451. private _defaultHeight?;
  13452. /**
  13453. * Instantiates a WebVRFreeCamera.
  13454. * @param name The name of the WebVRFreeCamera
  13455. * @param position The starting anchor position for the camera
  13456. * @param scene The scene the camera belongs to
  13457. * @param webVROptions a set of customizable options for the webVRCamera
  13458. */
  13459. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13460. /**
  13461. * Gets the device distance from the ground in meters.
  13462. * @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.
  13463. */
  13464. deviceDistanceToRoomGround(): number;
  13465. /**
  13466. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13467. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13468. */
  13469. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13470. /**
  13471. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13472. * @returns A promise with a boolean set to if the standing matrix is supported.
  13473. */
  13474. useStandingMatrixAsync(): Promise<boolean>;
  13475. /**
  13476. * Disposes the camera
  13477. */
  13478. dispose(): void;
  13479. /**
  13480. * Gets a vrController by name.
  13481. * @param name The name of the controller to retreive
  13482. * @returns the controller matching the name specified or null if not found
  13483. */
  13484. getControllerByName(name: string): Nullable<WebVRController>;
  13485. private _leftController;
  13486. /**
  13487. * The controller corrisponding to the users left hand.
  13488. */
  13489. readonly leftController: Nullable<WebVRController>;
  13490. private _rightController;
  13491. /**
  13492. * The controller corrisponding to the users right hand.
  13493. */
  13494. readonly rightController: Nullable<WebVRController>;
  13495. /**
  13496. * Casts a ray forward from the vrCamera's gaze.
  13497. * @param length Length of the ray (default: 100)
  13498. * @returns the ray corrisponding to the gaze
  13499. */
  13500. getForwardRay(length?: number): Ray;
  13501. /**
  13502. * @hidden
  13503. * Updates the camera based on device's frame data
  13504. */
  13505. _checkInputs(): void;
  13506. /**
  13507. * Updates the poseControlled values based on the input device pose.
  13508. * @param poseData Pose coming from the device
  13509. */
  13510. updateFromDevice(poseData: DevicePose): void;
  13511. private _htmlElementAttached;
  13512. private _detachIfAttached;
  13513. /**
  13514. * WebVR's attach control will start broadcasting frames to the device.
  13515. * Note that in certain browsers (chrome for example) this function must be called
  13516. * within a user-interaction callback. Example:
  13517. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13518. *
  13519. * @param element html element to attach the vrDevice to
  13520. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13521. */
  13522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13523. /**
  13524. * Detaches the camera from the html element and disables VR
  13525. *
  13526. * @param element html element to detach from
  13527. */
  13528. detachControl(element: HTMLElement): void;
  13529. /**
  13530. * @returns the name of this class
  13531. */
  13532. getClassName(): string;
  13533. /**
  13534. * Calls resetPose on the vrDisplay
  13535. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13536. */
  13537. resetToCurrentRotation(): void;
  13538. /**
  13539. * @hidden
  13540. * Updates the rig cameras (left and right eye)
  13541. */
  13542. _updateRigCameras(): void;
  13543. private _workingVector;
  13544. private _oneVector;
  13545. private _workingMatrix;
  13546. private updateCacheCalled;
  13547. private _correctPositionIfNotTrackPosition;
  13548. /**
  13549. * @hidden
  13550. * Updates the cached values of the camera
  13551. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13552. */
  13553. _updateCache(ignoreParentClass?: boolean): void;
  13554. /**
  13555. * @hidden
  13556. * Get current device position in babylon world
  13557. */
  13558. _computeDevicePosition(): void;
  13559. /**
  13560. * Updates the current device position and rotation in the babylon world
  13561. */
  13562. update(): void;
  13563. /**
  13564. * @hidden
  13565. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13566. * @returns an identity matrix
  13567. */
  13568. _getViewMatrix(): Matrix;
  13569. private _tmpMatrix;
  13570. /**
  13571. * This function is called by the two RIG cameras.
  13572. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13573. * @hidden
  13574. */
  13575. _getWebVRViewMatrix(): Matrix;
  13576. /** @hidden */
  13577. _getWebVRProjectionMatrix(): Matrix;
  13578. private _onGamepadConnectedObserver;
  13579. private _onGamepadDisconnectedObserver;
  13580. private _updateCacheWhenTrackingDisabledObserver;
  13581. /**
  13582. * Initializes the controllers and their meshes
  13583. */
  13584. initControllers(): void;
  13585. }
  13586. }
  13587. declare module "babylonjs/PostProcesses/postProcess" {
  13588. import { Nullable } from "babylonjs/types";
  13589. import { SmartArray } from "babylonjs/Misc/smartArray";
  13590. import { Observable } from "babylonjs/Misc/observable";
  13591. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13592. import { Camera } from "babylonjs/Cameras/camera";
  13593. import { Effect } from "babylonjs/Materials/effect";
  13594. import "babylonjs/Shaders/postprocess.vertex";
  13595. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13596. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13597. import { Engine } from "babylonjs/Engines/engine";
  13598. /**
  13599. * Size options for a post process
  13600. */
  13601. export type PostProcessOptions = {
  13602. width: number;
  13603. height: number;
  13604. };
  13605. /**
  13606. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13607. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13608. */
  13609. export class PostProcess {
  13610. /** Name of the PostProcess. */
  13611. name: string;
  13612. /**
  13613. * Gets or sets the unique id of the post process
  13614. */
  13615. uniqueId: number;
  13616. /**
  13617. * Width of the texture to apply the post process on
  13618. */
  13619. width: number;
  13620. /**
  13621. * Height of the texture to apply the post process on
  13622. */
  13623. height: number;
  13624. /**
  13625. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13626. * @hidden
  13627. */
  13628. _outputTexture: Nullable<InternalTexture>;
  13629. /**
  13630. * Sampling mode used by the shader
  13631. * See https://doc.babylonjs.com/classes/3.1/texture
  13632. */
  13633. renderTargetSamplingMode: number;
  13634. /**
  13635. * Clear color to use when screen clearing
  13636. */
  13637. clearColor: Color4;
  13638. /**
  13639. * If the buffer needs to be cleared before applying the post process. (default: true)
  13640. * Should be set to false if shader will overwrite all previous pixels.
  13641. */
  13642. autoClear: boolean;
  13643. /**
  13644. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13645. */
  13646. alphaMode: number;
  13647. /**
  13648. * Sets the setAlphaBlendConstants of the babylon engine
  13649. */
  13650. alphaConstants: Color4;
  13651. /**
  13652. * Animations to be used for the post processing
  13653. */
  13654. animations: import("babylonjs/Animations/animation").Animation[];
  13655. /**
  13656. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13657. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13658. */
  13659. enablePixelPerfectMode: boolean;
  13660. /**
  13661. * Force the postprocess to be applied without taking in account viewport
  13662. */
  13663. forceFullscreenViewport: boolean;
  13664. /**
  13665. * List of inspectable custom properties (used by the Inspector)
  13666. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13667. */
  13668. inspectableCustomProperties: IInspectable[];
  13669. /**
  13670. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13671. *
  13672. * | Value | Type | Description |
  13673. * | ----- | ----------------------------------- | ----------- |
  13674. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13675. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13676. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13677. *
  13678. */
  13679. scaleMode: number;
  13680. /**
  13681. * Force textures to be a power of two (default: false)
  13682. */
  13683. alwaysForcePOT: boolean;
  13684. private _samples;
  13685. /**
  13686. * Number of sample textures (default: 1)
  13687. */
  13688. samples: number;
  13689. /**
  13690. * Modify the scale of the post process to be the same as the viewport (default: false)
  13691. */
  13692. adaptScaleToCurrentViewport: boolean;
  13693. private _camera;
  13694. private _scene;
  13695. private _engine;
  13696. private _options;
  13697. private _reusable;
  13698. private _textureType;
  13699. /**
  13700. * Smart array of input and output textures for the post process.
  13701. * @hidden
  13702. */
  13703. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13704. /**
  13705. * The index in _textures that corresponds to the output texture.
  13706. * @hidden
  13707. */
  13708. _currentRenderTextureInd: number;
  13709. private _effect;
  13710. private _samplers;
  13711. private _fragmentUrl;
  13712. private _vertexUrl;
  13713. private _parameters;
  13714. private _scaleRatio;
  13715. protected _indexParameters: any;
  13716. private _shareOutputWithPostProcess;
  13717. private _texelSize;
  13718. private _forcedOutputTexture;
  13719. /**
  13720. * Returns the fragment url or shader name used in the post process.
  13721. * @returns the fragment url or name in the shader store.
  13722. */
  13723. getEffectName(): string;
  13724. /**
  13725. * An event triggered when the postprocess is activated.
  13726. */
  13727. onActivateObservable: Observable<Camera>;
  13728. private _onActivateObserver;
  13729. /**
  13730. * A function that is added to the onActivateObservable
  13731. */
  13732. onActivate: Nullable<(camera: Camera) => void>;
  13733. /**
  13734. * An event triggered when the postprocess changes its size.
  13735. */
  13736. onSizeChangedObservable: Observable<PostProcess>;
  13737. private _onSizeChangedObserver;
  13738. /**
  13739. * A function that is added to the onSizeChangedObservable
  13740. */
  13741. onSizeChanged: (postProcess: PostProcess) => void;
  13742. /**
  13743. * An event triggered when the postprocess applies its effect.
  13744. */
  13745. onApplyObservable: Observable<Effect>;
  13746. private _onApplyObserver;
  13747. /**
  13748. * A function that is added to the onApplyObservable
  13749. */
  13750. onApply: (effect: Effect) => void;
  13751. /**
  13752. * An event triggered before rendering the postprocess
  13753. */
  13754. onBeforeRenderObservable: Observable<Effect>;
  13755. private _onBeforeRenderObserver;
  13756. /**
  13757. * A function that is added to the onBeforeRenderObservable
  13758. */
  13759. onBeforeRender: (effect: Effect) => void;
  13760. /**
  13761. * An event triggered after rendering the postprocess
  13762. */
  13763. onAfterRenderObservable: Observable<Effect>;
  13764. private _onAfterRenderObserver;
  13765. /**
  13766. * A function that is added to the onAfterRenderObservable
  13767. */
  13768. onAfterRender: (efect: Effect) => void;
  13769. /**
  13770. * 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
  13771. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13772. */
  13773. inputTexture: InternalTexture;
  13774. /**
  13775. * Gets the camera which post process is applied to.
  13776. * @returns The camera the post process is applied to.
  13777. */
  13778. getCamera(): Camera;
  13779. /**
  13780. * Gets the texel size of the postprocess.
  13781. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13782. */
  13783. readonly texelSize: Vector2;
  13784. /**
  13785. * Creates a new instance PostProcess
  13786. * @param name The name of the PostProcess.
  13787. * @param fragmentUrl The url of the fragment shader to be used.
  13788. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13789. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13790. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13791. * @param camera The camera to apply the render pass to.
  13792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13793. * @param engine The engine which the post process will be applied. (default: current engine)
  13794. * @param reusable If the post process can be reused on the same frame. (default: false)
  13795. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13796. * @param textureType Type of textures used when performing the post process. (default: 0)
  13797. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13798. * @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
  13799. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13800. */
  13801. constructor(
  13802. /** Name of the PostProcess. */
  13803. 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);
  13804. /**
  13805. * Gets a string idenfifying the name of the class
  13806. * @returns "PostProcess" string
  13807. */
  13808. getClassName(): string;
  13809. /**
  13810. * Gets the engine which this post process belongs to.
  13811. * @returns The engine the post process was enabled with.
  13812. */
  13813. getEngine(): Engine;
  13814. /**
  13815. * The effect that is created when initializing the post process.
  13816. * @returns The created effect corrisponding the the postprocess.
  13817. */
  13818. getEffect(): Effect;
  13819. /**
  13820. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13821. * @param postProcess The post process to share the output with.
  13822. * @returns This post process.
  13823. */
  13824. shareOutputWith(postProcess: PostProcess): PostProcess;
  13825. /**
  13826. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13827. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13828. */
  13829. useOwnOutput(): void;
  13830. /**
  13831. * Updates the effect with the current post process compile time values and recompiles the shader.
  13832. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13833. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13834. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13835. * @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
  13836. * @param onCompiled Called when the shader has been compiled.
  13837. * @param onError Called if there is an error when compiling a shader.
  13838. */
  13839. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13840. /**
  13841. * The post process is reusable if it can be used multiple times within one frame.
  13842. * @returns If the post process is reusable
  13843. */
  13844. isReusable(): boolean;
  13845. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13846. markTextureDirty(): void;
  13847. /**
  13848. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13849. * 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.
  13850. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13851. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13852. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13853. * @returns The target texture that was bound to be written to.
  13854. */
  13855. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13856. /**
  13857. * If the post process is supported.
  13858. */
  13859. readonly isSupported: boolean;
  13860. /**
  13861. * The aspect ratio of the output texture.
  13862. */
  13863. readonly aspectRatio: number;
  13864. /**
  13865. * Get a value indicating if the post-process is ready to be used
  13866. * @returns true if the post-process is ready (shader is compiled)
  13867. */
  13868. isReady(): boolean;
  13869. /**
  13870. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13871. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13872. */
  13873. apply(): Nullable<Effect>;
  13874. private _disposeTextures;
  13875. /**
  13876. * Disposes the post process.
  13877. * @param camera The camera to dispose the post process on.
  13878. */
  13879. dispose(camera?: Camera): void;
  13880. }
  13881. }
  13882. declare module "babylonjs/PostProcesses/postProcessManager" {
  13883. import { Nullable } from "babylonjs/types";
  13884. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13885. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13886. import { Scene } from "babylonjs/scene";
  13887. /**
  13888. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13889. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13890. */
  13891. export class PostProcessManager {
  13892. private _scene;
  13893. private _indexBuffer;
  13894. private _vertexBuffers;
  13895. /**
  13896. * Creates a new instance PostProcess
  13897. * @param scene The scene that the post process is associated with.
  13898. */
  13899. constructor(scene: Scene);
  13900. private _prepareBuffers;
  13901. private _buildIndexBuffer;
  13902. /**
  13903. * Rebuilds the vertex buffers of the manager.
  13904. * @hidden
  13905. */
  13906. _rebuild(): void;
  13907. /**
  13908. * Prepares a frame to be run through a post process.
  13909. * @param sourceTexture The input texture to the post procesess. (default: null)
  13910. * @param postProcesses An array of post processes to be run. (default: null)
  13911. * @returns True if the post processes were able to be run.
  13912. * @hidden
  13913. */
  13914. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13915. /**
  13916. * Manually render a set of post processes to a texture.
  13917. * @param postProcesses An array of post processes to be run.
  13918. * @param targetTexture The target texture to render to.
  13919. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13920. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13921. * @param lodLevel defines which lod of the texture to render to
  13922. */
  13923. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13924. /**
  13925. * Finalize the result of the output of the postprocesses.
  13926. * @param doNotPresent If true the result will not be displayed to the screen.
  13927. * @param targetTexture The target texture to render to.
  13928. * @param faceIndex The index of the face to bind the target texture to.
  13929. * @param postProcesses The array of post processes to render.
  13930. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13931. * @hidden
  13932. */
  13933. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13934. /**
  13935. * Disposes of the post process manager.
  13936. */
  13937. dispose(): void;
  13938. }
  13939. }
  13940. declare module "babylonjs/Layers/layerSceneComponent" {
  13941. import { Scene } from "babylonjs/scene";
  13942. import { ISceneComponent } from "babylonjs/sceneComponent";
  13943. import { Layer } from "babylonjs/Layers/layer";
  13944. module "babylonjs/abstractScene" {
  13945. interface AbstractScene {
  13946. /**
  13947. * The list of layers (background and foreground) of the scene
  13948. */
  13949. layers: Array<Layer>;
  13950. }
  13951. }
  13952. /**
  13953. * Defines the layer scene component responsible to manage any layers
  13954. * in a given scene.
  13955. */
  13956. export class LayerSceneComponent implements ISceneComponent {
  13957. /**
  13958. * The component name helpfull to identify the component in the list of scene components.
  13959. */
  13960. readonly name: string;
  13961. /**
  13962. * The scene the component belongs to.
  13963. */
  13964. scene: Scene;
  13965. private _engine;
  13966. /**
  13967. * Creates a new instance of the component for the given scene
  13968. * @param scene Defines the scene to register the component in
  13969. */
  13970. constructor(scene: Scene);
  13971. /**
  13972. * Registers the component in a given scene
  13973. */
  13974. register(): void;
  13975. /**
  13976. * Rebuilds the elements related to this component in case of
  13977. * context lost for instance.
  13978. */
  13979. rebuild(): void;
  13980. /**
  13981. * Disposes the component and the associated ressources.
  13982. */
  13983. dispose(): void;
  13984. private _draw;
  13985. private _drawCameraPredicate;
  13986. private _drawCameraBackground;
  13987. private _drawCameraForeground;
  13988. private _drawRenderTargetPredicate;
  13989. private _drawRenderTargetBackground;
  13990. private _drawRenderTargetForeground;
  13991. }
  13992. }
  13993. declare module "babylonjs/Shaders/layer.fragment" {
  13994. /** @hidden */
  13995. export var layerPixelShader: {
  13996. name: string;
  13997. shader: string;
  13998. };
  13999. }
  14000. declare module "babylonjs/Shaders/layer.vertex" {
  14001. /** @hidden */
  14002. export var layerVertexShader: {
  14003. name: string;
  14004. shader: string;
  14005. };
  14006. }
  14007. declare module "babylonjs/Layers/layer" {
  14008. import { Observable } from "babylonjs/Misc/observable";
  14009. import { Nullable } from "babylonjs/types";
  14010. import { Scene } from "babylonjs/scene";
  14011. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14012. import { Texture } from "babylonjs/Materials/Textures/texture";
  14013. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14014. import "babylonjs/Shaders/layer.fragment";
  14015. import "babylonjs/Shaders/layer.vertex";
  14016. /**
  14017. * This represents a full screen 2d layer.
  14018. * This can be useful to display a picture in the background of your scene for instance.
  14019. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14020. */
  14021. export class Layer {
  14022. /**
  14023. * Define the name of the layer.
  14024. */
  14025. name: string;
  14026. /**
  14027. * Define the texture the layer should display.
  14028. */
  14029. texture: Nullable<Texture>;
  14030. /**
  14031. * Is the layer in background or foreground.
  14032. */
  14033. isBackground: boolean;
  14034. /**
  14035. * Define the color of the layer (instead of texture).
  14036. */
  14037. color: Color4;
  14038. /**
  14039. * Define the scale of the layer in order to zoom in out of the texture.
  14040. */
  14041. scale: Vector2;
  14042. /**
  14043. * Define an offset for the layer in order to shift the texture.
  14044. */
  14045. offset: Vector2;
  14046. /**
  14047. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14048. */
  14049. alphaBlendingMode: number;
  14050. /**
  14051. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14052. * Alpha test will not mix with the background color in case of transparency.
  14053. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14054. */
  14055. alphaTest: boolean;
  14056. /**
  14057. * Define a mask to restrict the layer to only some of the scene cameras.
  14058. */
  14059. layerMask: number;
  14060. /**
  14061. * Define the list of render target the layer is visible into.
  14062. */
  14063. renderTargetTextures: RenderTargetTexture[];
  14064. /**
  14065. * Define if the layer is only used in renderTarget or if it also
  14066. * renders in the main frame buffer of the canvas.
  14067. */
  14068. renderOnlyInRenderTargetTextures: boolean;
  14069. private _scene;
  14070. private _vertexBuffers;
  14071. private _indexBuffer;
  14072. private _effect;
  14073. private _alphaTestEffect;
  14074. /**
  14075. * An event triggered when the layer is disposed.
  14076. */
  14077. onDisposeObservable: Observable<Layer>;
  14078. private _onDisposeObserver;
  14079. /**
  14080. * Back compatibility with callback before the onDisposeObservable existed.
  14081. * The set callback will be triggered when the layer has been disposed.
  14082. */
  14083. onDispose: () => void;
  14084. /**
  14085. * An event triggered before rendering the scene
  14086. */
  14087. onBeforeRenderObservable: Observable<Layer>;
  14088. private _onBeforeRenderObserver;
  14089. /**
  14090. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14091. * The set callback will be triggered just before rendering the layer.
  14092. */
  14093. onBeforeRender: () => void;
  14094. /**
  14095. * An event triggered after rendering the scene
  14096. */
  14097. onAfterRenderObservable: Observable<Layer>;
  14098. private _onAfterRenderObserver;
  14099. /**
  14100. * Back compatibility with callback before the onAfterRenderObservable existed.
  14101. * The set callback will be triggered just after rendering the layer.
  14102. */
  14103. onAfterRender: () => void;
  14104. /**
  14105. * Instantiates a new layer.
  14106. * This represents a full screen 2d layer.
  14107. * This can be useful to display a picture in the background of your scene for instance.
  14108. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14109. * @param name Define the name of the layer in the scene
  14110. * @param imgUrl Define the url of the texture to display in the layer
  14111. * @param scene Define the scene the layer belongs to
  14112. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14113. * @param color Defines a color for the layer
  14114. */
  14115. constructor(
  14116. /**
  14117. * Define the name of the layer.
  14118. */
  14119. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14120. private _createIndexBuffer;
  14121. /** @hidden */
  14122. _rebuild(): void;
  14123. /**
  14124. * Renders the layer in the scene.
  14125. */
  14126. render(): void;
  14127. /**
  14128. * Disposes and releases the associated ressources.
  14129. */
  14130. dispose(): void;
  14131. }
  14132. }
  14133. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14134. import { Scene } from "babylonjs/scene";
  14135. import { ISceneComponent } from "babylonjs/sceneComponent";
  14136. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14137. module "babylonjs/abstractScene" {
  14138. interface AbstractScene {
  14139. /**
  14140. * The list of procedural textures added to the scene
  14141. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14142. */
  14143. proceduralTextures: Array<ProceduralTexture>;
  14144. }
  14145. }
  14146. /**
  14147. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14148. * in a given scene.
  14149. */
  14150. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14151. /**
  14152. * The component name helpfull to identify the component in the list of scene components.
  14153. */
  14154. readonly name: string;
  14155. /**
  14156. * The scene the component belongs to.
  14157. */
  14158. scene: Scene;
  14159. /**
  14160. * Creates a new instance of the component for the given scene
  14161. * @param scene Defines the scene to register the component in
  14162. */
  14163. constructor(scene: Scene);
  14164. /**
  14165. * Registers the component in a given scene
  14166. */
  14167. register(): void;
  14168. /**
  14169. * Rebuilds the elements related to this component in case of
  14170. * context lost for instance.
  14171. */
  14172. rebuild(): void;
  14173. /**
  14174. * Disposes the component and the associated ressources.
  14175. */
  14176. dispose(): void;
  14177. private _beforeClear;
  14178. }
  14179. }
  14180. declare module "babylonjs/Shaders/procedural.vertex" {
  14181. /** @hidden */
  14182. export var proceduralVertexShader: {
  14183. name: string;
  14184. shader: string;
  14185. };
  14186. }
  14187. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14188. import { Observable } from "babylonjs/Misc/observable";
  14189. import { Nullable } from "babylonjs/types";
  14190. import { Scene } from "babylonjs/scene";
  14191. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14192. import { Effect } from "babylonjs/Materials/effect";
  14193. import { Texture } from "babylonjs/Materials/Textures/texture";
  14194. import "babylonjs/Shaders/procedural.vertex";
  14195. /**
  14196. * 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.
  14197. * This is the base class of any Procedural texture and contains most of the shareable code.
  14198. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14199. */
  14200. export class ProceduralTexture extends Texture {
  14201. isCube: boolean;
  14202. /**
  14203. * Define if the texture is enabled or not (disabled texture will not render)
  14204. */
  14205. isEnabled: boolean;
  14206. /**
  14207. * Define if the texture must be cleared before rendering (default is true)
  14208. */
  14209. autoClear: boolean;
  14210. /**
  14211. * Callback called when the texture is generated
  14212. */
  14213. onGenerated: () => void;
  14214. /**
  14215. * Event raised when the texture is generated
  14216. */
  14217. onGeneratedObservable: Observable<ProceduralTexture>;
  14218. /** @hidden */
  14219. _generateMipMaps: boolean;
  14220. /** @hidden **/
  14221. _effect: Effect;
  14222. /** @hidden */
  14223. _textures: {
  14224. [key: string]: Texture;
  14225. };
  14226. private _size;
  14227. private _currentRefreshId;
  14228. private _refreshRate;
  14229. private _vertexBuffers;
  14230. private _indexBuffer;
  14231. private _uniforms;
  14232. private _samplers;
  14233. private _fragment;
  14234. private _floats;
  14235. private _ints;
  14236. private _floatsArrays;
  14237. private _colors3;
  14238. private _colors4;
  14239. private _vectors2;
  14240. private _vectors3;
  14241. private _matrices;
  14242. private _fallbackTexture;
  14243. private _fallbackTextureUsed;
  14244. private _engine;
  14245. private _cachedDefines;
  14246. private _contentUpdateId;
  14247. private _contentData;
  14248. /**
  14249. * Instantiates a new procedural texture.
  14250. * 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.
  14251. * This is the base class of any Procedural texture and contains most of the shareable code.
  14252. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14253. * @param name Define the name of the texture
  14254. * @param size Define the size of the texture to create
  14255. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14256. * @param scene Define the scene the texture belongs to
  14257. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14258. * @param generateMipMaps Define if the texture should creates mip maps or not
  14259. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14260. */
  14261. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14262. /**
  14263. * The effect that is created when initializing the post process.
  14264. * @returns The created effect corrisponding the the postprocess.
  14265. */
  14266. getEffect(): Effect;
  14267. /**
  14268. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14269. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14270. */
  14271. getContent(): Nullable<ArrayBufferView>;
  14272. private _createIndexBuffer;
  14273. /** @hidden */
  14274. _rebuild(): void;
  14275. /**
  14276. * Resets the texture in order to recreate its associated resources.
  14277. * This can be called in case of context loss
  14278. */
  14279. reset(): void;
  14280. protected _getDefines(): string;
  14281. /**
  14282. * Is the texture ready to be used ? (rendered at least once)
  14283. * @returns true if ready, otherwise, false.
  14284. */
  14285. isReady(): boolean;
  14286. /**
  14287. * Resets the refresh counter of the texture and start bak from scratch.
  14288. * Could be useful to regenerate the texture if it is setup to render only once.
  14289. */
  14290. resetRefreshCounter(): void;
  14291. /**
  14292. * Set the fragment shader to use in order to render the texture.
  14293. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14294. */
  14295. setFragment(fragment: any): void;
  14296. /**
  14297. * Define the refresh rate of the texture or the rendering frequency.
  14298. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14299. */
  14300. refreshRate: number;
  14301. /** @hidden */
  14302. _shouldRender(): boolean;
  14303. /**
  14304. * Get the size the texture is rendering at.
  14305. * @returns the size (texture is always squared)
  14306. */
  14307. getRenderSize(): number;
  14308. /**
  14309. * Resize the texture to new value.
  14310. * @param size Define the new size the texture should have
  14311. * @param generateMipMaps Define whether the new texture should create mip maps
  14312. */
  14313. resize(size: number, generateMipMaps: boolean): void;
  14314. private _checkUniform;
  14315. /**
  14316. * Set a texture in the shader program used to render.
  14317. * @param name Define the name of the uniform samplers as defined in the shader
  14318. * @param texture Define the texture to bind to this sampler
  14319. * @return the texture itself allowing "fluent" like uniform updates
  14320. */
  14321. setTexture(name: string, texture: Texture): ProceduralTexture;
  14322. /**
  14323. * Set a float in the shader.
  14324. * @param name Define the name of the uniform as defined in the shader
  14325. * @param value Define the value to give to the uniform
  14326. * @return the texture itself allowing "fluent" like uniform updates
  14327. */
  14328. setFloat(name: string, value: number): ProceduralTexture;
  14329. /**
  14330. * Set a int in the shader.
  14331. * @param name Define the name of the uniform as defined in the shader
  14332. * @param value Define the value to give to the uniform
  14333. * @return the texture itself allowing "fluent" like uniform updates
  14334. */
  14335. setInt(name: string, value: number): ProceduralTexture;
  14336. /**
  14337. * Set an array of floats in the shader.
  14338. * @param name Define the name of the uniform as defined in the shader
  14339. * @param value Define the value to give to the uniform
  14340. * @return the texture itself allowing "fluent" like uniform updates
  14341. */
  14342. setFloats(name: string, value: number[]): ProceduralTexture;
  14343. /**
  14344. * Set a vec3 in the shader from a Color3.
  14345. * @param name Define the name of the uniform as defined in the shader
  14346. * @param value Define the value to give to the uniform
  14347. * @return the texture itself allowing "fluent" like uniform updates
  14348. */
  14349. setColor3(name: string, value: Color3): ProceduralTexture;
  14350. /**
  14351. * Set a vec4 in the shader from a Color4.
  14352. * @param name Define the name of the uniform as defined in the shader
  14353. * @param value Define the value to give to the uniform
  14354. * @return the texture itself allowing "fluent" like uniform updates
  14355. */
  14356. setColor4(name: string, value: Color4): ProceduralTexture;
  14357. /**
  14358. * Set a vec2 in the shader from a Vector2.
  14359. * @param name Define the name of the uniform as defined in the shader
  14360. * @param value Define the value to give to the uniform
  14361. * @return the texture itself allowing "fluent" like uniform updates
  14362. */
  14363. setVector2(name: string, value: Vector2): ProceduralTexture;
  14364. /**
  14365. * Set a vec3 in the shader from a Vector3.
  14366. * @param name Define the name of the uniform as defined in the shader
  14367. * @param value Define the value to give to the uniform
  14368. * @return the texture itself allowing "fluent" like uniform updates
  14369. */
  14370. setVector3(name: string, value: Vector3): ProceduralTexture;
  14371. /**
  14372. * Set a mat4 in the shader from a MAtrix.
  14373. * @param name Define the name of the uniform as defined in the shader
  14374. * @param value Define the value to give to the uniform
  14375. * @return the texture itself allowing "fluent" like uniform updates
  14376. */
  14377. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14378. /**
  14379. * Render the texture to its associated render target.
  14380. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14381. */
  14382. render(useCameraPostProcess?: boolean): void;
  14383. /**
  14384. * Clone the texture.
  14385. * @returns the cloned texture
  14386. */
  14387. clone(): ProceduralTexture;
  14388. /**
  14389. * Dispose the texture and release its asoociated resources.
  14390. */
  14391. dispose(): void;
  14392. }
  14393. }
  14394. declare module "babylonjs/Particles/baseParticleSystem" {
  14395. import { Nullable } from "babylonjs/types";
  14396. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14398. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14399. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14400. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14401. import { Scene } from "babylonjs/scene";
  14402. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14403. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14404. import { Texture } from "babylonjs/Materials/Textures/texture";
  14405. import { Animation } from "babylonjs/Animations/animation";
  14406. /**
  14407. * This represents the base class for particle system in Babylon.
  14408. * 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.
  14409. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14410. * @example https://doc.babylonjs.com/babylon101/particles
  14411. */
  14412. export class BaseParticleSystem {
  14413. /**
  14414. * Source color is added to the destination color without alpha affecting the result
  14415. */
  14416. static BLENDMODE_ONEONE: number;
  14417. /**
  14418. * Blend current color and particle color using particle’s alpha
  14419. */
  14420. static BLENDMODE_STANDARD: number;
  14421. /**
  14422. * Add current color and particle color multiplied by particle’s alpha
  14423. */
  14424. static BLENDMODE_ADD: number;
  14425. /**
  14426. * Multiply current color with particle color
  14427. */
  14428. static BLENDMODE_MULTIPLY: number;
  14429. /**
  14430. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14431. */
  14432. static BLENDMODE_MULTIPLYADD: number;
  14433. /**
  14434. * List of animations used by the particle system.
  14435. */
  14436. animations: Animation[];
  14437. /**
  14438. * The id of the Particle system.
  14439. */
  14440. id: string;
  14441. /**
  14442. * The friendly name of the Particle system.
  14443. */
  14444. name: string;
  14445. /**
  14446. * The rendering group used by the Particle system to chose when to render.
  14447. */
  14448. renderingGroupId: number;
  14449. /**
  14450. * The emitter represents the Mesh or position we are attaching the particle system to.
  14451. */
  14452. emitter: Nullable<AbstractMesh | Vector3>;
  14453. /**
  14454. * The maximum number of particles to emit per frame
  14455. */
  14456. emitRate: number;
  14457. /**
  14458. * If you want to launch only a few particles at once, that can be done, as well.
  14459. */
  14460. manualEmitCount: number;
  14461. /**
  14462. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14463. */
  14464. updateSpeed: number;
  14465. /**
  14466. * The amount of time the particle system is running (depends of the overall update speed).
  14467. */
  14468. targetStopDuration: number;
  14469. /**
  14470. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14471. */
  14472. disposeOnStop: boolean;
  14473. /**
  14474. * Minimum power of emitting particles.
  14475. */
  14476. minEmitPower: number;
  14477. /**
  14478. * Maximum power of emitting particles.
  14479. */
  14480. maxEmitPower: number;
  14481. /**
  14482. * Minimum life time of emitting particles.
  14483. */
  14484. minLifeTime: number;
  14485. /**
  14486. * Maximum life time of emitting particles.
  14487. */
  14488. maxLifeTime: number;
  14489. /**
  14490. * Minimum Size of emitting particles.
  14491. */
  14492. minSize: number;
  14493. /**
  14494. * Maximum Size of emitting particles.
  14495. */
  14496. maxSize: number;
  14497. /**
  14498. * Minimum scale of emitting particles on X axis.
  14499. */
  14500. minScaleX: number;
  14501. /**
  14502. * Maximum scale of emitting particles on X axis.
  14503. */
  14504. maxScaleX: number;
  14505. /**
  14506. * Minimum scale of emitting particles on Y axis.
  14507. */
  14508. minScaleY: number;
  14509. /**
  14510. * Maximum scale of emitting particles on Y axis.
  14511. */
  14512. maxScaleY: number;
  14513. /**
  14514. * Gets or sets the minimal initial rotation in radians.
  14515. */
  14516. minInitialRotation: number;
  14517. /**
  14518. * Gets or sets the maximal initial rotation in radians.
  14519. */
  14520. maxInitialRotation: number;
  14521. /**
  14522. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14523. */
  14524. minAngularSpeed: number;
  14525. /**
  14526. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14527. */
  14528. maxAngularSpeed: number;
  14529. /**
  14530. * The texture used to render each particle. (this can be a spritesheet)
  14531. */
  14532. particleTexture: Nullable<Texture>;
  14533. /**
  14534. * The layer mask we are rendering the particles through.
  14535. */
  14536. layerMask: number;
  14537. /**
  14538. * This can help using your own shader to render the particle system.
  14539. * The according effect will be created
  14540. */
  14541. customShader: any;
  14542. /**
  14543. * By default particle system starts as soon as they are created. This prevents the
  14544. * automatic start to happen and let you decide when to start emitting particles.
  14545. */
  14546. preventAutoStart: boolean;
  14547. private _noiseTexture;
  14548. /**
  14549. * Gets or sets a texture used to add random noise to particle positions
  14550. */
  14551. noiseTexture: Nullable<ProceduralTexture>;
  14552. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14553. noiseStrength: Vector3;
  14554. /**
  14555. * Callback triggered when the particle animation is ending.
  14556. */
  14557. onAnimationEnd: Nullable<() => void>;
  14558. /**
  14559. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14560. */
  14561. blendMode: number;
  14562. /**
  14563. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14564. * to override the particles.
  14565. */
  14566. forceDepthWrite: boolean;
  14567. /** 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 */
  14568. preWarmCycles: number;
  14569. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14570. preWarmStepOffset: number;
  14571. /**
  14572. * 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)
  14573. */
  14574. spriteCellChangeSpeed: number;
  14575. /**
  14576. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14577. */
  14578. startSpriteCellID: number;
  14579. /**
  14580. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14581. */
  14582. endSpriteCellID: number;
  14583. /**
  14584. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14585. */
  14586. spriteCellWidth: number;
  14587. /**
  14588. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14589. */
  14590. spriteCellHeight: number;
  14591. /**
  14592. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14593. */
  14594. spriteRandomStartCell: boolean;
  14595. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14596. translationPivot: Vector2;
  14597. /** @hidden */
  14598. protected _isAnimationSheetEnabled: boolean;
  14599. /**
  14600. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14601. */
  14602. beginAnimationOnStart: boolean;
  14603. /**
  14604. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14605. */
  14606. beginAnimationFrom: number;
  14607. /**
  14608. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14609. */
  14610. beginAnimationTo: number;
  14611. /**
  14612. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14613. */
  14614. beginAnimationLoop: boolean;
  14615. /**
  14616. * Gets or sets a world offset applied to all particles
  14617. */
  14618. worldOffset: Vector3;
  14619. /**
  14620. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14621. */
  14622. isAnimationSheetEnabled: boolean;
  14623. /**
  14624. * Get hosting scene
  14625. * @returns the scene
  14626. */
  14627. getScene(): Scene;
  14628. /**
  14629. * You can use gravity if you want to give an orientation to your particles.
  14630. */
  14631. gravity: Vector3;
  14632. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14633. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14634. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14635. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14636. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14637. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14638. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14639. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14640. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14641. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14642. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14643. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14644. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14645. /**
  14646. * Defines the delay in milliseconds before starting the system (0 by default)
  14647. */
  14648. startDelay: number;
  14649. /**
  14650. * Gets the current list of drag gradients.
  14651. * You must use addDragGradient and removeDragGradient to udpate this list
  14652. * @returns the list of drag gradients
  14653. */
  14654. getDragGradients(): Nullable<Array<FactorGradient>>;
  14655. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14656. limitVelocityDamping: number;
  14657. /**
  14658. * Gets the current list of limit velocity gradients.
  14659. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14660. * @returns the list of limit velocity gradients
  14661. */
  14662. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14663. /**
  14664. * Gets the current list of color gradients.
  14665. * You must use addColorGradient and removeColorGradient to udpate this list
  14666. * @returns the list of color gradients
  14667. */
  14668. getColorGradients(): Nullable<Array<ColorGradient>>;
  14669. /**
  14670. * Gets the current list of size gradients.
  14671. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14672. * @returns the list of size gradients
  14673. */
  14674. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14675. /**
  14676. * Gets the current list of color remap gradients.
  14677. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14678. * @returns the list of color remap gradients
  14679. */
  14680. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14681. /**
  14682. * Gets the current list of alpha remap gradients.
  14683. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14684. * @returns the list of alpha remap gradients
  14685. */
  14686. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14687. /**
  14688. * Gets the current list of life time gradients.
  14689. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14690. * @returns the list of life time gradients
  14691. */
  14692. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14693. /**
  14694. * Gets the current list of angular speed gradients.
  14695. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14696. * @returns the list of angular speed gradients
  14697. */
  14698. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14699. /**
  14700. * Gets the current list of velocity gradients.
  14701. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14702. * @returns the list of velocity gradients
  14703. */
  14704. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14705. /**
  14706. * Gets the current list of start size gradients.
  14707. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14708. * @returns the list of start size gradients
  14709. */
  14710. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14711. /**
  14712. * Gets the current list of emit rate gradients.
  14713. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14714. * @returns the list of emit rate gradients
  14715. */
  14716. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14717. /**
  14718. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14719. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14720. */
  14721. direction1: Vector3;
  14722. /**
  14723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14724. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14725. */
  14726. direction2: Vector3;
  14727. /**
  14728. * 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.
  14729. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14730. */
  14731. minEmitBox: Vector3;
  14732. /**
  14733. * 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.
  14734. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14735. */
  14736. maxEmitBox: Vector3;
  14737. /**
  14738. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14739. */
  14740. color1: Color4;
  14741. /**
  14742. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14743. */
  14744. color2: Color4;
  14745. /**
  14746. * Color the particle will have at the end of its lifetime
  14747. */
  14748. colorDead: Color4;
  14749. /**
  14750. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14751. */
  14752. textureMask: Color4;
  14753. /**
  14754. * The particle emitter type defines the emitter used by the particle system.
  14755. * It can be for example box, sphere, or cone...
  14756. */
  14757. particleEmitterType: IParticleEmitterType;
  14758. /** @hidden */
  14759. _isSubEmitter: boolean;
  14760. /**
  14761. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14762. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14763. */
  14764. billboardMode: number;
  14765. protected _isBillboardBased: boolean;
  14766. /**
  14767. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14768. */
  14769. isBillboardBased: boolean;
  14770. /**
  14771. * The scene the particle system belongs to.
  14772. */
  14773. protected _scene: Scene;
  14774. /**
  14775. * Local cache of defines for image processing.
  14776. */
  14777. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14778. /**
  14779. * Default configuration related to image processing available in the standard Material.
  14780. */
  14781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14782. /**
  14783. * Gets the image processing configuration used either in this material.
  14784. */
  14785. /**
  14786. * Sets the Default image processing configuration used either in the this material.
  14787. *
  14788. * If sets to null, the scene one is in use.
  14789. */
  14790. imageProcessingConfiguration: ImageProcessingConfiguration;
  14791. /**
  14792. * Attaches a new image processing configuration to the Standard Material.
  14793. * @param configuration
  14794. */
  14795. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14796. /** @hidden */
  14797. protected _reset(): void;
  14798. /** @hidden */
  14799. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14800. /**
  14801. * Instantiates a particle system.
  14802. * 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.
  14803. * @param name The name of the particle system
  14804. */
  14805. constructor(name: string);
  14806. /**
  14807. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14810. * @returns the emitter
  14811. */
  14812. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14813. /**
  14814. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14815. * @param radius The radius of the hemisphere to emit from
  14816. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14817. * @returns the emitter
  14818. */
  14819. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14820. /**
  14821. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14822. * @param radius The radius of the sphere to emit from
  14823. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14824. * @returns the emitter
  14825. */
  14826. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14827. /**
  14828. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14829. * @param radius The radius of the sphere to emit from
  14830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14832. * @returns the emitter
  14833. */
  14834. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14835. /**
  14836. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14837. * @param radius The radius of the emission cylinder
  14838. * @param height The height of the emission cylinder
  14839. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14840. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14841. * @returns the emitter
  14842. */
  14843. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14844. /**
  14845. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14846. * @param radius The radius of the cylinder to emit from
  14847. * @param height The height of the emission cylinder
  14848. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14849. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14850. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14851. * @returns the emitter
  14852. */
  14853. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14854. /**
  14855. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14856. * @param radius The radius of the cone to emit from
  14857. * @param angle The base angle of the cone
  14858. * @returns the emitter
  14859. */
  14860. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14861. /**
  14862. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14863. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14864. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14865. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14866. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14867. * @returns the emitter
  14868. */
  14869. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14870. }
  14871. }
  14872. declare module "babylonjs/Particles/subEmitter" {
  14873. import { Scene } from "babylonjs/scene";
  14874. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14875. /**
  14876. * Type of sub emitter
  14877. */
  14878. export enum SubEmitterType {
  14879. /**
  14880. * Attached to the particle over it's lifetime
  14881. */
  14882. ATTACHED = 0,
  14883. /**
  14884. * Created when the particle dies
  14885. */
  14886. END = 1
  14887. }
  14888. /**
  14889. * Sub emitter class used to emit particles from an existing particle
  14890. */
  14891. export class SubEmitter {
  14892. /**
  14893. * the particle system to be used by the sub emitter
  14894. */
  14895. particleSystem: ParticleSystem;
  14896. /**
  14897. * Type of the submitter (Default: END)
  14898. */
  14899. type: SubEmitterType;
  14900. /**
  14901. * 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)
  14902. * Note: This only is supported when using an emitter of type Mesh
  14903. */
  14904. inheritDirection: boolean;
  14905. /**
  14906. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14907. */
  14908. inheritedVelocityAmount: number;
  14909. /**
  14910. * Creates a sub emitter
  14911. * @param particleSystem the particle system to be used by the sub emitter
  14912. */
  14913. constructor(
  14914. /**
  14915. * the particle system to be used by the sub emitter
  14916. */
  14917. particleSystem: ParticleSystem);
  14918. /**
  14919. * Clones the sub emitter
  14920. * @returns the cloned sub emitter
  14921. */
  14922. clone(): SubEmitter;
  14923. /**
  14924. * Serialize current object to a JSON object
  14925. * @returns the serialized object
  14926. */
  14927. serialize(): any;
  14928. /** @hidden */
  14929. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14930. /**
  14931. * Creates a new SubEmitter from a serialized JSON version
  14932. * @param serializationObject defines the JSON object to read from
  14933. * @param scene defines the hosting scene
  14934. * @param rootUrl defines the rootUrl for data loading
  14935. * @returns a new SubEmitter
  14936. */
  14937. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14938. /** Release associated resources */
  14939. dispose(): void;
  14940. }
  14941. }
  14942. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14943. /** @hidden */
  14944. export var clipPlaneFragmentDeclaration: {
  14945. name: string;
  14946. shader: string;
  14947. };
  14948. }
  14949. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14950. /** @hidden */
  14951. export var imageProcessingDeclaration: {
  14952. name: string;
  14953. shader: string;
  14954. };
  14955. }
  14956. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14957. /** @hidden */
  14958. export var imageProcessingFunctions: {
  14959. name: string;
  14960. shader: string;
  14961. };
  14962. }
  14963. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14964. /** @hidden */
  14965. export var clipPlaneFragment: {
  14966. name: string;
  14967. shader: string;
  14968. };
  14969. }
  14970. declare module "babylonjs/Shaders/particles.fragment" {
  14971. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14972. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14973. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14974. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14975. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14976. /** @hidden */
  14977. export var particlesPixelShader: {
  14978. name: string;
  14979. shader: string;
  14980. };
  14981. }
  14982. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14983. /** @hidden */
  14984. export var clipPlaneVertexDeclaration: {
  14985. name: string;
  14986. shader: string;
  14987. };
  14988. }
  14989. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14990. /** @hidden */
  14991. export var clipPlaneVertex: {
  14992. name: string;
  14993. shader: string;
  14994. };
  14995. }
  14996. declare module "babylonjs/Shaders/particles.vertex" {
  14997. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14998. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14999. /** @hidden */
  15000. export var particlesVertexShader: {
  15001. name: string;
  15002. shader: string;
  15003. };
  15004. }
  15005. declare module "babylonjs/Particles/particleSystem" {
  15006. import { Nullable } from "babylonjs/types";
  15007. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15008. import { Observable } from "babylonjs/Misc/observable";
  15009. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15010. import { Effect } from "babylonjs/Materials/effect";
  15011. import { Scene, IDisposable } from "babylonjs/scene";
  15012. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15013. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15014. import { Particle } from "babylonjs/Particles/particle";
  15015. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15016. import "babylonjs/Shaders/particles.fragment";
  15017. import "babylonjs/Shaders/particles.vertex";
  15018. /**
  15019. * This represents a particle system in Babylon.
  15020. * 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.
  15021. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15022. * @example https://doc.babylonjs.com/babylon101/particles
  15023. */
  15024. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15025. /**
  15026. * Billboard mode will only apply to Y axis
  15027. */
  15028. static readonly BILLBOARDMODE_Y: number;
  15029. /**
  15030. * Billboard mode will apply to all axes
  15031. */
  15032. static readonly BILLBOARDMODE_ALL: number;
  15033. /**
  15034. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15035. */
  15036. static readonly BILLBOARDMODE_STRETCHED: number;
  15037. /**
  15038. * This function can be defined to provide custom update for active particles.
  15039. * This function will be called instead of regular update (age, position, color, etc.).
  15040. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15041. */
  15042. updateFunction: (particles: Particle[]) => void;
  15043. private _emitterWorldMatrix;
  15044. /**
  15045. * This function can be defined to specify initial direction for every new particle.
  15046. * It by default use the emitterType defined function
  15047. */
  15048. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15049. /**
  15050. * This function can be defined to specify initial position for every new particle.
  15051. * It by default use the emitterType defined function
  15052. */
  15053. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15054. /**
  15055. * @hidden
  15056. */
  15057. _inheritedVelocityOffset: Vector3;
  15058. /**
  15059. * An event triggered when the system is disposed
  15060. */
  15061. onDisposeObservable: Observable<ParticleSystem>;
  15062. private _onDisposeObserver;
  15063. /**
  15064. * Sets a callback that will be triggered when the system is disposed
  15065. */
  15066. onDispose: () => void;
  15067. private _particles;
  15068. private _epsilon;
  15069. private _capacity;
  15070. private _stockParticles;
  15071. private _newPartsExcess;
  15072. private _vertexData;
  15073. private _vertexBuffer;
  15074. private _vertexBuffers;
  15075. private _spriteBuffer;
  15076. private _indexBuffer;
  15077. private _effect;
  15078. private _customEffect;
  15079. private _cachedDefines;
  15080. private _scaledColorStep;
  15081. private _colorDiff;
  15082. private _scaledDirection;
  15083. private _scaledGravity;
  15084. private _currentRenderId;
  15085. private _alive;
  15086. private _useInstancing;
  15087. private _started;
  15088. private _stopped;
  15089. private _actualFrame;
  15090. private _scaledUpdateSpeed;
  15091. private _vertexBufferSize;
  15092. /** @hidden */
  15093. _currentEmitRateGradient: Nullable<FactorGradient>;
  15094. /** @hidden */
  15095. _currentEmitRate1: number;
  15096. /** @hidden */
  15097. _currentEmitRate2: number;
  15098. /** @hidden */
  15099. _currentStartSizeGradient: Nullable<FactorGradient>;
  15100. /** @hidden */
  15101. _currentStartSize1: number;
  15102. /** @hidden */
  15103. _currentStartSize2: number;
  15104. private readonly _rawTextureWidth;
  15105. private _rampGradientsTexture;
  15106. private _useRampGradients;
  15107. /** Gets or sets a boolean indicating that ramp gradients must be used
  15108. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15109. */
  15110. useRampGradients: boolean;
  15111. /**
  15112. * 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.
  15113. * 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: [])
  15114. */
  15115. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15116. private _subEmitters;
  15117. /**
  15118. * @hidden
  15119. * If the particle systems emitter should be disposed when the particle system is disposed
  15120. */
  15121. _disposeEmitterOnDispose: boolean;
  15122. /**
  15123. * The current active Sub-systems, this property is used by the root particle system only.
  15124. */
  15125. activeSubSystems: Array<ParticleSystem>;
  15126. private _rootParticleSystem;
  15127. /**
  15128. * Gets the current list of active particles
  15129. */
  15130. readonly particles: Particle[];
  15131. /**
  15132. * Returns the string "ParticleSystem"
  15133. * @returns a string containing the class name
  15134. */
  15135. getClassName(): string;
  15136. /**
  15137. * Instantiates a particle system.
  15138. * 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.
  15139. * @param name The name of the particle system
  15140. * @param capacity The max number of particles alive at the same time
  15141. * @param scene The scene the particle system belongs to
  15142. * @param customEffect a custom effect used to change the way particles are rendered by default
  15143. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15144. * @param epsilon Offset used to render the particles
  15145. */
  15146. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15147. private _addFactorGradient;
  15148. private _removeFactorGradient;
  15149. /**
  15150. * Adds a new life time gradient
  15151. * @param gradient defines the gradient to use (between 0 and 1)
  15152. * @param factor defines the life time factor to affect to the specified gradient
  15153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15154. * @returns the current particle system
  15155. */
  15156. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15157. /**
  15158. * Remove a specific life time gradient
  15159. * @param gradient defines the gradient to remove
  15160. * @returns the current particle system
  15161. */
  15162. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15163. /**
  15164. * Adds a new size gradient
  15165. * @param gradient defines the gradient to use (between 0 and 1)
  15166. * @param factor defines the size factor to affect to the specified gradient
  15167. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15168. * @returns the current particle system
  15169. */
  15170. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15171. /**
  15172. * Remove a specific size gradient
  15173. * @param gradient defines the gradient to remove
  15174. * @returns the current particle system
  15175. */
  15176. removeSizeGradient(gradient: number): IParticleSystem;
  15177. /**
  15178. * Adds a new color remap gradient
  15179. * @param gradient defines the gradient to use (between 0 and 1)
  15180. * @param min defines the color remap minimal range
  15181. * @param max defines the color remap maximal range
  15182. * @returns the current particle system
  15183. */
  15184. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15185. /**
  15186. * Remove a specific color remap gradient
  15187. * @param gradient defines the gradient to remove
  15188. * @returns the current particle system
  15189. */
  15190. removeColorRemapGradient(gradient: number): IParticleSystem;
  15191. /**
  15192. * Adds a new alpha remap gradient
  15193. * @param gradient defines the gradient to use (between 0 and 1)
  15194. * @param min defines the alpha remap minimal range
  15195. * @param max defines the alpha remap maximal range
  15196. * @returns the current particle system
  15197. */
  15198. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15199. /**
  15200. * Remove a specific alpha remap gradient
  15201. * @param gradient defines the gradient to remove
  15202. * @returns the current particle system
  15203. */
  15204. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15205. /**
  15206. * Adds a new angular speed gradient
  15207. * @param gradient defines the gradient to use (between 0 and 1)
  15208. * @param factor defines the angular speed to affect to the specified gradient
  15209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15210. * @returns the current particle system
  15211. */
  15212. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15213. /**
  15214. * Remove a specific angular speed gradient
  15215. * @param gradient defines the gradient to remove
  15216. * @returns the current particle system
  15217. */
  15218. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15219. /**
  15220. * Adds a new velocity gradient
  15221. * @param gradient defines the gradient to use (between 0 and 1)
  15222. * @param factor defines the velocity to affect to the specified gradient
  15223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15224. * @returns the current particle system
  15225. */
  15226. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15227. /**
  15228. * Remove a specific velocity gradient
  15229. * @param gradient defines the gradient to remove
  15230. * @returns the current particle system
  15231. */
  15232. removeVelocityGradient(gradient: number): IParticleSystem;
  15233. /**
  15234. * Adds a new limit velocity gradient
  15235. * @param gradient defines the gradient to use (between 0 and 1)
  15236. * @param factor defines the limit velocity value to affect to the specified gradient
  15237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15238. * @returns the current particle system
  15239. */
  15240. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15241. /**
  15242. * Remove a specific limit velocity gradient
  15243. * @param gradient defines the gradient to remove
  15244. * @returns the current particle system
  15245. */
  15246. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15247. /**
  15248. * Adds a new drag gradient
  15249. * @param gradient defines the gradient to use (between 0 and 1)
  15250. * @param factor defines the drag value to affect to the specified gradient
  15251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15252. * @returns the current particle system
  15253. */
  15254. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15255. /**
  15256. * Remove a specific drag gradient
  15257. * @param gradient defines the gradient to remove
  15258. * @returns the current particle system
  15259. */
  15260. removeDragGradient(gradient: number): IParticleSystem;
  15261. /**
  15262. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15263. * @param gradient defines the gradient to use (between 0 and 1)
  15264. * @param factor defines the emit rate value to affect to the specified gradient
  15265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15266. * @returns the current particle system
  15267. */
  15268. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15269. /**
  15270. * Remove a specific emit rate gradient
  15271. * @param gradient defines the gradient to remove
  15272. * @returns the current particle system
  15273. */
  15274. removeEmitRateGradient(gradient: number): IParticleSystem;
  15275. /**
  15276. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15277. * @param gradient defines the gradient to use (between 0 and 1)
  15278. * @param factor defines the start size value to affect to the specified gradient
  15279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15280. * @returns the current particle system
  15281. */
  15282. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15283. /**
  15284. * Remove a specific start size gradient
  15285. * @param gradient defines the gradient to remove
  15286. * @returns the current particle system
  15287. */
  15288. removeStartSizeGradient(gradient: number): IParticleSystem;
  15289. private _createRampGradientTexture;
  15290. /**
  15291. * Gets the current list of ramp gradients.
  15292. * You must use addRampGradient and removeRampGradient to udpate this list
  15293. * @returns the list of ramp gradients
  15294. */
  15295. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15296. /**
  15297. * Adds a new ramp gradient used to remap particle colors
  15298. * @param gradient defines the gradient to use (between 0 and 1)
  15299. * @param color defines the color to affect to the specified gradient
  15300. * @returns the current particle system
  15301. */
  15302. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15303. /**
  15304. * Remove a specific ramp gradient
  15305. * @param gradient defines the gradient to remove
  15306. * @returns the current particle system
  15307. */
  15308. removeRampGradient(gradient: number): ParticleSystem;
  15309. /**
  15310. * Adds a new color gradient
  15311. * @param gradient defines the gradient to use (between 0 and 1)
  15312. * @param color1 defines the color to affect to the specified gradient
  15313. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15314. * @returns this particle system
  15315. */
  15316. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15317. /**
  15318. * Remove a specific color gradient
  15319. * @param gradient defines the gradient to remove
  15320. * @returns this particle system
  15321. */
  15322. removeColorGradient(gradient: number): IParticleSystem;
  15323. private _fetchR;
  15324. protected _reset(): void;
  15325. private _resetEffect;
  15326. private _createVertexBuffers;
  15327. private _createIndexBuffer;
  15328. /**
  15329. * Gets the maximum number of particles active at the same time.
  15330. * @returns The max number of active particles.
  15331. */
  15332. getCapacity(): number;
  15333. /**
  15334. * Gets whether there are still active particles in the system.
  15335. * @returns True if it is alive, otherwise false.
  15336. */
  15337. isAlive(): boolean;
  15338. /**
  15339. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15340. * @returns True if it has been started, otherwise false.
  15341. */
  15342. isStarted(): boolean;
  15343. private _prepareSubEmitterInternalArray;
  15344. /**
  15345. * Starts the particle system and begins to emit
  15346. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15347. */
  15348. start(delay?: number): void;
  15349. /**
  15350. * Stops the particle system.
  15351. * @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.
  15352. */
  15353. stop(stopSubEmitters?: boolean): void;
  15354. /**
  15355. * Remove all active particles
  15356. */
  15357. reset(): void;
  15358. /**
  15359. * @hidden (for internal use only)
  15360. */
  15361. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15362. /**
  15363. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15364. * Its lifetime will start back at 0.
  15365. */
  15366. recycleParticle: (particle: Particle) => void;
  15367. private _stopSubEmitters;
  15368. private _createParticle;
  15369. private _removeFromRoot;
  15370. private _emitFromParticle;
  15371. private _update;
  15372. /** @hidden */
  15373. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15374. /** @hidden */
  15375. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15376. /** @hidden */
  15377. private _getEffect;
  15378. /**
  15379. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15380. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15381. */
  15382. animate(preWarmOnly?: boolean): void;
  15383. private _appendParticleVertices;
  15384. /**
  15385. * Rebuilds the particle system.
  15386. */
  15387. rebuild(): void;
  15388. /**
  15389. * Is this system ready to be used/rendered
  15390. * @return true if the system is ready
  15391. */
  15392. isReady(): boolean;
  15393. private _render;
  15394. /**
  15395. * Renders the particle system in its current state.
  15396. * @returns the current number of particles
  15397. */
  15398. render(): number;
  15399. /**
  15400. * Disposes the particle system and free the associated resources
  15401. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15402. */
  15403. dispose(disposeTexture?: boolean): void;
  15404. /**
  15405. * Clones the particle system.
  15406. * @param name The name of the cloned object
  15407. * @param newEmitter The new emitter to use
  15408. * @returns the cloned particle system
  15409. */
  15410. clone(name: string, newEmitter: any): ParticleSystem;
  15411. /**
  15412. * Serializes the particle system to a JSON object.
  15413. * @returns the JSON object
  15414. */
  15415. serialize(): any;
  15416. /** @hidden */
  15417. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15418. /** @hidden */
  15419. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15420. /**
  15421. * Parses a JSON object to create a particle system.
  15422. * @param parsedParticleSystem The JSON object to parse
  15423. * @param scene The scene to create the particle system in
  15424. * @param rootUrl The root url to use to load external dependencies like texture
  15425. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15426. * @returns the Parsed particle system
  15427. */
  15428. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15429. }
  15430. }
  15431. declare module "babylonjs/Particles/particle" {
  15432. import { Nullable } from "babylonjs/types";
  15433. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15434. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15435. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15436. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15437. /**
  15438. * A particle represents one of the element emitted by a particle system.
  15439. * This is mainly define by its coordinates, direction, velocity and age.
  15440. */
  15441. export class Particle {
  15442. /**
  15443. * The particle system the particle belongs to.
  15444. */
  15445. particleSystem: ParticleSystem;
  15446. private static _Count;
  15447. /**
  15448. * Unique ID of the particle
  15449. */
  15450. id: number;
  15451. /**
  15452. * The world position of the particle in the scene.
  15453. */
  15454. position: Vector3;
  15455. /**
  15456. * The world direction of the particle in the scene.
  15457. */
  15458. direction: Vector3;
  15459. /**
  15460. * The color of the particle.
  15461. */
  15462. color: Color4;
  15463. /**
  15464. * The color change of the particle per step.
  15465. */
  15466. colorStep: Color4;
  15467. /**
  15468. * Defines how long will the life of the particle be.
  15469. */
  15470. lifeTime: number;
  15471. /**
  15472. * The current age of the particle.
  15473. */
  15474. age: number;
  15475. /**
  15476. * The current size of the particle.
  15477. */
  15478. size: number;
  15479. /**
  15480. * The current scale of the particle.
  15481. */
  15482. scale: Vector2;
  15483. /**
  15484. * The current angle of the particle.
  15485. */
  15486. angle: number;
  15487. /**
  15488. * Defines how fast is the angle changing.
  15489. */
  15490. angularSpeed: number;
  15491. /**
  15492. * Defines the cell index used by the particle to be rendered from a sprite.
  15493. */
  15494. cellIndex: number;
  15495. /**
  15496. * The information required to support color remapping
  15497. */
  15498. remapData: Vector4;
  15499. /** @hidden */
  15500. _randomCellOffset?: number;
  15501. /** @hidden */
  15502. _initialDirection: Nullable<Vector3>;
  15503. /** @hidden */
  15504. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15505. /** @hidden */
  15506. _initialStartSpriteCellID: number;
  15507. /** @hidden */
  15508. _initialEndSpriteCellID: number;
  15509. /** @hidden */
  15510. _currentColorGradient: Nullable<ColorGradient>;
  15511. /** @hidden */
  15512. _currentColor1: Color4;
  15513. /** @hidden */
  15514. _currentColor2: Color4;
  15515. /** @hidden */
  15516. _currentSizeGradient: Nullable<FactorGradient>;
  15517. /** @hidden */
  15518. _currentSize1: number;
  15519. /** @hidden */
  15520. _currentSize2: number;
  15521. /** @hidden */
  15522. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15523. /** @hidden */
  15524. _currentAngularSpeed1: number;
  15525. /** @hidden */
  15526. _currentAngularSpeed2: number;
  15527. /** @hidden */
  15528. _currentVelocityGradient: Nullable<FactorGradient>;
  15529. /** @hidden */
  15530. _currentVelocity1: number;
  15531. /** @hidden */
  15532. _currentVelocity2: number;
  15533. /** @hidden */
  15534. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15535. /** @hidden */
  15536. _currentLimitVelocity1: number;
  15537. /** @hidden */
  15538. _currentLimitVelocity2: number;
  15539. /** @hidden */
  15540. _currentDragGradient: Nullable<FactorGradient>;
  15541. /** @hidden */
  15542. _currentDrag1: number;
  15543. /** @hidden */
  15544. _currentDrag2: number;
  15545. /** @hidden */
  15546. _randomNoiseCoordinates1: Vector3;
  15547. /** @hidden */
  15548. _randomNoiseCoordinates2: Vector3;
  15549. /**
  15550. * Creates a new instance Particle
  15551. * @param particleSystem the particle system the particle belongs to
  15552. */
  15553. constructor(
  15554. /**
  15555. * The particle system the particle belongs to.
  15556. */
  15557. particleSystem: ParticleSystem);
  15558. private updateCellInfoFromSystem;
  15559. /**
  15560. * Defines how the sprite cell index is updated for the particle
  15561. */
  15562. updateCellIndex(): void;
  15563. /** @hidden */
  15564. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15565. /** @hidden */
  15566. _inheritParticleInfoToSubEmitters(): void;
  15567. /** @hidden */
  15568. _reset(): void;
  15569. /**
  15570. * Copy the properties of particle to another one.
  15571. * @param other the particle to copy the information to.
  15572. */
  15573. copyTo(other: Particle): void;
  15574. }
  15575. }
  15576. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15577. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15578. import { Effect } from "babylonjs/Materials/effect";
  15579. import { Particle } from "babylonjs/Particles/particle";
  15580. /**
  15581. * Particle emitter represents a volume emitting particles.
  15582. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15583. */
  15584. export interface IParticleEmitterType {
  15585. /**
  15586. * Called by the particle System when the direction is computed for the created particle.
  15587. * @param worldMatrix is the world matrix of the particle system
  15588. * @param directionToUpdate is the direction vector to update with the result
  15589. * @param particle is the particle we are computed the direction for
  15590. */
  15591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15592. /**
  15593. * Called by the particle System when the position is computed for the created particle.
  15594. * @param worldMatrix is the world matrix of the particle system
  15595. * @param positionToUpdate is the position vector to update with the result
  15596. * @param particle is the particle we are computed the position for
  15597. */
  15598. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15599. /**
  15600. * Clones the current emitter and returns a copy of it
  15601. * @returns the new emitter
  15602. */
  15603. clone(): IParticleEmitterType;
  15604. /**
  15605. * Called by the GPUParticleSystem to setup the update shader
  15606. * @param effect defines the update shader
  15607. */
  15608. applyToShader(effect: Effect): void;
  15609. /**
  15610. * Returns a string to use to update the GPU particles update shader
  15611. * @returns the effect defines string
  15612. */
  15613. getEffectDefines(): string;
  15614. /**
  15615. * Returns a string representing the class name
  15616. * @returns a string containing the class name
  15617. */
  15618. getClassName(): string;
  15619. /**
  15620. * Serializes the particle system to a JSON object.
  15621. * @returns the JSON object
  15622. */
  15623. serialize(): any;
  15624. /**
  15625. * Parse properties from a JSON object
  15626. * @param serializationObject defines the JSON object
  15627. */
  15628. parse(serializationObject: any): void;
  15629. }
  15630. }
  15631. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15632. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15633. import { Effect } from "babylonjs/Materials/effect";
  15634. import { Particle } from "babylonjs/Particles/particle";
  15635. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15636. /**
  15637. * Particle emitter emitting particles from the inside of a box.
  15638. * It emits the particles randomly between 2 given directions.
  15639. */
  15640. export class BoxParticleEmitter implements IParticleEmitterType {
  15641. /**
  15642. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15643. */
  15644. direction1: Vector3;
  15645. /**
  15646. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15647. */
  15648. direction2: Vector3;
  15649. /**
  15650. * 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.
  15651. */
  15652. minEmitBox: Vector3;
  15653. /**
  15654. * 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.
  15655. */
  15656. maxEmitBox: Vector3;
  15657. /**
  15658. * Creates a new instance BoxParticleEmitter
  15659. */
  15660. constructor();
  15661. /**
  15662. * Called by the particle System when the direction is computed for the created particle.
  15663. * @param worldMatrix is the world matrix of the particle system
  15664. * @param directionToUpdate is the direction vector to update with the result
  15665. * @param particle is the particle we are computed the direction for
  15666. */
  15667. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15668. /**
  15669. * Called by the particle System when the position is computed for the created particle.
  15670. * @param worldMatrix is the world matrix of the particle system
  15671. * @param positionToUpdate is the position vector to update with the result
  15672. * @param particle is the particle we are computed the position for
  15673. */
  15674. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15675. /**
  15676. * Clones the current emitter and returns a copy of it
  15677. * @returns the new emitter
  15678. */
  15679. clone(): BoxParticleEmitter;
  15680. /**
  15681. * Called by the GPUParticleSystem to setup the update shader
  15682. * @param effect defines the update shader
  15683. */
  15684. applyToShader(effect: Effect): void;
  15685. /**
  15686. * Returns a string to use to update the GPU particles update shader
  15687. * @returns a string containng the defines string
  15688. */
  15689. getEffectDefines(): string;
  15690. /**
  15691. * Returns the string "BoxParticleEmitter"
  15692. * @returns a string containing the class name
  15693. */
  15694. getClassName(): string;
  15695. /**
  15696. * Serializes the particle system to a JSON object.
  15697. * @returns the JSON object
  15698. */
  15699. serialize(): any;
  15700. /**
  15701. * Parse properties from a JSON object
  15702. * @param serializationObject defines the JSON object
  15703. */
  15704. parse(serializationObject: any): void;
  15705. }
  15706. }
  15707. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15708. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15709. import { Effect } from "babylonjs/Materials/effect";
  15710. import { Particle } from "babylonjs/Particles/particle";
  15711. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15712. /**
  15713. * Particle emitter emitting particles from the inside of a cone.
  15714. * It emits the particles alongside the cone volume from the base to the particle.
  15715. * The emission direction might be randomized.
  15716. */
  15717. export class ConeParticleEmitter implements IParticleEmitterType {
  15718. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15719. directionRandomizer: number;
  15720. private _radius;
  15721. private _angle;
  15722. private _height;
  15723. /**
  15724. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15725. */
  15726. radiusRange: number;
  15727. /**
  15728. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15729. */
  15730. heightRange: number;
  15731. /**
  15732. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15733. */
  15734. emitFromSpawnPointOnly: boolean;
  15735. /**
  15736. * Gets or sets the radius of the emission cone
  15737. */
  15738. radius: number;
  15739. /**
  15740. * Gets or sets the angle of the emission cone
  15741. */
  15742. angle: number;
  15743. private _buildHeight;
  15744. /**
  15745. * Creates a new instance ConeParticleEmitter
  15746. * @param radius the radius of the emission cone (1 by default)
  15747. * @param angle the cone base angle (PI by default)
  15748. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15749. */
  15750. constructor(radius?: number, angle?: number,
  15751. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15752. directionRandomizer?: number);
  15753. /**
  15754. * Called by the particle System when the direction is computed for the created particle.
  15755. * @param worldMatrix is the world matrix of the particle system
  15756. * @param directionToUpdate is the direction vector to update with the result
  15757. * @param particle is the particle we are computed the direction for
  15758. */
  15759. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15760. /**
  15761. * Called by the particle System when the position is computed for the created particle.
  15762. * @param worldMatrix is the world matrix of the particle system
  15763. * @param positionToUpdate is the position vector to update with the result
  15764. * @param particle is the particle we are computed the position for
  15765. */
  15766. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15767. /**
  15768. * Clones the current emitter and returns a copy of it
  15769. * @returns the new emitter
  15770. */
  15771. clone(): ConeParticleEmitter;
  15772. /**
  15773. * Called by the GPUParticleSystem to setup the update shader
  15774. * @param effect defines the update shader
  15775. */
  15776. applyToShader(effect: Effect): void;
  15777. /**
  15778. * Returns a string to use to update the GPU particles update shader
  15779. * @returns a string containng the defines string
  15780. */
  15781. getEffectDefines(): string;
  15782. /**
  15783. * Returns the string "ConeParticleEmitter"
  15784. * @returns a string containing the class name
  15785. */
  15786. getClassName(): string;
  15787. /**
  15788. * Serializes the particle system to a JSON object.
  15789. * @returns the JSON object
  15790. */
  15791. serialize(): any;
  15792. /**
  15793. * Parse properties from a JSON object
  15794. * @param serializationObject defines the JSON object
  15795. */
  15796. parse(serializationObject: any): void;
  15797. }
  15798. }
  15799. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15800. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15801. import { Effect } from "babylonjs/Materials/effect";
  15802. import { Particle } from "babylonjs/Particles/particle";
  15803. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15804. /**
  15805. * Particle emitter emitting particles from the inside of a cylinder.
  15806. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15807. */
  15808. export class CylinderParticleEmitter implements IParticleEmitterType {
  15809. /**
  15810. * The radius of the emission cylinder.
  15811. */
  15812. radius: number;
  15813. /**
  15814. * The height of the emission cylinder.
  15815. */
  15816. height: number;
  15817. /**
  15818. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15819. */
  15820. radiusRange: number;
  15821. /**
  15822. * How much to randomize the particle direction [0-1].
  15823. */
  15824. directionRandomizer: number;
  15825. /**
  15826. * Creates a new instance CylinderParticleEmitter
  15827. * @param radius the radius of the emission cylinder (1 by default)
  15828. * @param height the height of the emission cylinder (1 by default)
  15829. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15830. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15831. */
  15832. constructor(
  15833. /**
  15834. * The radius of the emission cylinder.
  15835. */
  15836. radius?: number,
  15837. /**
  15838. * The height of the emission cylinder.
  15839. */
  15840. height?: number,
  15841. /**
  15842. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15843. */
  15844. radiusRange?: number,
  15845. /**
  15846. * How much to randomize the particle direction [0-1].
  15847. */
  15848. directionRandomizer?: number);
  15849. /**
  15850. * Called by the particle System when the direction is computed for the created particle.
  15851. * @param worldMatrix is the world matrix of the particle system
  15852. * @param directionToUpdate is the direction vector to update with the result
  15853. * @param particle is the particle we are computed the direction for
  15854. */
  15855. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15856. /**
  15857. * Called by the particle System when the position is computed for the created particle.
  15858. * @param worldMatrix is the world matrix of the particle system
  15859. * @param positionToUpdate is the position vector to update with the result
  15860. * @param particle is the particle we are computed the position for
  15861. */
  15862. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15863. /**
  15864. * Clones the current emitter and returns a copy of it
  15865. * @returns the new emitter
  15866. */
  15867. clone(): CylinderParticleEmitter;
  15868. /**
  15869. * Called by the GPUParticleSystem to setup the update shader
  15870. * @param effect defines the update shader
  15871. */
  15872. applyToShader(effect: Effect): void;
  15873. /**
  15874. * Returns a string to use to update the GPU particles update shader
  15875. * @returns a string containng the defines string
  15876. */
  15877. getEffectDefines(): string;
  15878. /**
  15879. * Returns the string "CylinderParticleEmitter"
  15880. * @returns a string containing the class name
  15881. */
  15882. getClassName(): string;
  15883. /**
  15884. * Serializes the particle system to a JSON object.
  15885. * @returns the JSON object
  15886. */
  15887. serialize(): any;
  15888. /**
  15889. * Parse properties from a JSON object
  15890. * @param serializationObject defines the JSON object
  15891. */
  15892. parse(serializationObject: any): void;
  15893. }
  15894. /**
  15895. * Particle emitter emitting particles from the inside of a cylinder.
  15896. * It emits the particles randomly between two vectors.
  15897. */
  15898. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15899. /**
  15900. * The min limit of the emission direction.
  15901. */
  15902. direction1: Vector3;
  15903. /**
  15904. * The max limit of the emission direction.
  15905. */
  15906. direction2: Vector3;
  15907. /**
  15908. * Creates a new instance CylinderDirectedParticleEmitter
  15909. * @param radius the radius of the emission cylinder (1 by default)
  15910. * @param height the height of the emission cylinder (1 by default)
  15911. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15912. * @param direction1 the min limit of the emission direction (up vector by default)
  15913. * @param direction2 the max limit of the emission direction (up vector by default)
  15914. */
  15915. constructor(radius?: number, height?: number, radiusRange?: number,
  15916. /**
  15917. * The min limit of the emission direction.
  15918. */
  15919. direction1?: Vector3,
  15920. /**
  15921. * The max limit of the emission direction.
  15922. */
  15923. direction2?: Vector3);
  15924. /**
  15925. * Called by the particle System when the direction is computed for the created particle.
  15926. * @param worldMatrix is the world matrix of the particle system
  15927. * @param directionToUpdate is the direction vector to update with the result
  15928. * @param particle is the particle we are computed the direction for
  15929. */
  15930. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15931. /**
  15932. * Clones the current emitter and returns a copy of it
  15933. * @returns the new emitter
  15934. */
  15935. clone(): CylinderDirectedParticleEmitter;
  15936. /**
  15937. * Called by the GPUParticleSystem to setup the update shader
  15938. * @param effect defines the update shader
  15939. */
  15940. applyToShader(effect: Effect): void;
  15941. /**
  15942. * Returns a string to use to update the GPU particles update shader
  15943. * @returns a string containng the defines string
  15944. */
  15945. getEffectDefines(): string;
  15946. /**
  15947. * Returns the string "CylinderDirectedParticleEmitter"
  15948. * @returns a string containing the class name
  15949. */
  15950. getClassName(): string;
  15951. /**
  15952. * Serializes the particle system to a JSON object.
  15953. * @returns the JSON object
  15954. */
  15955. serialize(): any;
  15956. /**
  15957. * Parse properties from a JSON object
  15958. * @param serializationObject defines the JSON object
  15959. */
  15960. parse(serializationObject: any): void;
  15961. }
  15962. }
  15963. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15964. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15965. import { Effect } from "babylonjs/Materials/effect";
  15966. import { Particle } from "babylonjs/Particles/particle";
  15967. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15968. /**
  15969. * Particle emitter emitting particles from the inside of a hemisphere.
  15970. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15971. */
  15972. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15973. /**
  15974. * The radius of the emission hemisphere.
  15975. */
  15976. radius: number;
  15977. /**
  15978. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15979. */
  15980. radiusRange: number;
  15981. /**
  15982. * How much to randomize the particle direction [0-1].
  15983. */
  15984. directionRandomizer: number;
  15985. /**
  15986. * Creates a new instance HemisphericParticleEmitter
  15987. * @param radius the radius of the emission hemisphere (1 by default)
  15988. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15989. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15990. */
  15991. constructor(
  15992. /**
  15993. * The radius of the emission hemisphere.
  15994. */
  15995. radius?: number,
  15996. /**
  15997. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15998. */
  15999. radiusRange?: number,
  16000. /**
  16001. * How much to randomize the particle direction [0-1].
  16002. */
  16003. directionRandomizer?: number);
  16004. /**
  16005. * Called by the particle System when the direction is computed for the created particle.
  16006. * @param worldMatrix is the world matrix of the particle system
  16007. * @param directionToUpdate is the direction vector to update with the result
  16008. * @param particle is the particle we are computed the direction for
  16009. */
  16010. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16011. /**
  16012. * Called by the particle System when the position is computed for the created particle.
  16013. * @param worldMatrix is the world matrix of the particle system
  16014. * @param positionToUpdate is the position vector to update with the result
  16015. * @param particle is the particle we are computed the position for
  16016. */
  16017. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16018. /**
  16019. * Clones the current emitter and returns a copy of it
  16020. * @returns the new emitter
  16021. */
  16022. clone(): HemisphericParticleEmitter;
  16023. /**
  16024. * Called by the GPUParticleSystem to setup the update shader
  16025. * @param effect defines the update shader
  16026. */
  16027. applyToShader(effect: Effect): void;
  16028. /**
  16029. * Returns a string to use to update the GPU particles update shader
  16030. * @returns a string containng the defines string
  16031. */
  16032. getEffectDefines(): string;
  16033. /**
  16034. * Returns the string "HemisphericParticleEmitter"
  16035. * @returns a string containing the class name
  16036. */
  16037. getClassName(): string;
  16038. /**
  16039. * Serializes the particle system to a JSON object.
  16040. * @returns the JSON object
  16041. */
  16042. serialize(): any;
  16043. /**
  16044. * Parse properties from a JSON object
  16045. * @param serializationObject defines the JSON object
  16046. */
  16047. parse(serializationObject: any): void;
  16048. }
  16049. }
  16050. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16051. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16052. import { Effect } from "babylonjs/Materials/effect";
  16053. import { Particle } from "babylonjs/Particles/particle";
  16054. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16055. /**
  16056. * Particle emitter emitting particles from a point.
  16057. * It emits the particles randomly between 2 given directions.
  16058. */
  16059. export class PointParticleEmitter implements IParticleEmitterType {
  16060. /**
  16061. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16062. */
  16063. direction1: Vector3;
  16064. /**
  16065. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16066. */
  16067. direction2: Vector3;
  16068. /**
  16069. * Creates a new instance PointParticleEmitter
  16070. */
  16071. constructor();
  16072. /**
  16073. * Called by the particle System when the direction is computed for the created particle.
  16074. * @param worldMatrix is the world matrix of the particle system
  16075. * @param directionToUpdate is the direction vector to update with the result
  16076. * @param particle is the particle we are computed the direction for
  16077. */
  16078. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16079. /**
  16080. * Called by the particle System when the position is computed for the created particle.
  16081. * @param worldMatrix is the world matrix of the particle system
  16082. * @param positionToUpdate is the position vector to update with the result
  16083. * @param particle is the particle we are computed the position for
  16084. */
  16085. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16086. /**
  16087. * Clones the current emitter and returns a copy of it
  16088. * @returns the new emitter
  16089. */
  16090. clone(): PointParticleEmitter;
  16091. /**
  16092. * Called by the GPUParticleSystem to setup the update shader
  16093. * @param effect defines the update shader
  16094. */
  16095. applyToShader(effect: Effect): void;
  16096. /**
  16097. * Returns a string to use to update the GPU particles update shader
  16098. * @returns a string containng the defines string
  16099. */
  16100. getEffectDefines(): string;
  16101. /**
  16102. * Returns the string "PointParticleEmitter"
  16103. * @returns a string containing the class name
  16104. */
  16105. getClassName(): string;
  16106. /**
  16107. * Serializes the particle system to a JSON object.
  16108. * @returns the JSON object
  16109. */
  16110. serialize(): any;
  16111. /**
  16112. * Parse properties from a JSON object
  16113. * @param serializationObject defines the JSON object
  16114. */
  16115. parse(serializationObject: any): void;
  16116. }
  16117. }
  16118. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16119. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16120. import { Effect } from "babylonjs/Materials/effect";
  16121. import { Particle } from "babylonjs/Particles/particle";
  16122. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16123. /**
  16124. * Particle emitter emitting particles from the inside of a sphere.
  16125. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16126. */
  16127. export class SphereParticleEmitter implements IParticleEmitterType {
  16128. /**
  16129. * The radius of the emission sphere.
  16130. */
  16131. radius: number;
  16132. /**
  16133. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16134. */
  16135. radiusRange: number;
  16136. /**
  16137. * How much to randomize the particle direction [0-1].
  16138. */
  16139. directionRandomizer: number;
  16140. /**
  16141. * Creates a new instance SphereParticleEmitter
  16142. * @param radius the radius of the emission sphere (1 by default)
  16143. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16144. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16145. */
  16146. constructor(
  16147. /**
  16148. * The radius of the emission sphere.
  16149. */
  16150. radius?: number,
  16151. /**
  16152. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16153. */
  16154. radiusRange?: number,
  16155. /**
  16156. * How much to randomize the particle direction [0-1].
  16157. */
  16158. directionRandomizer?: number);
  16159. /**
  16160. * Called by the particle System when the direction is computed for the created particle.
  16161. * @param worldMatrix is the world matrix of the particle system
  16162. * @param directionToUpdate is the direction vector to update with the result
  16163. * @param particle is the particle we are computed the direction for
  16164. */
  16165. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16166. /**
  16167. * Called by the particle System when the position is computed for the created particle.
  16168. * @param worldMatrix is the world matrix of the particle system
  16169. * @param positionToUpdate is the position vector to update with the result
  16170. * @param particle is the particle we are computed the position for
  16171. */
  16172. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16173. /**
  16174. * Clones the current emitter and returns a copy of it
  16175. * @returns the new emitter
  16176. */
  16177. clone(): SphereParticleEmitter;
  16178. /**
  16179. * Called by the GPUParticleSystem to setup the update shader
  16180. * @param effect defines the update shader
  16181. */
  16182. applyToShader(effect: Effect): void;
  16183. /**
  16184. * Returns a string to use to update the GPU particles update shader
  16185. * @returns a string containng the defines string
  16186. */
  16187. getEffectDefines(): string;
  16188. /**
  16189. * Returns the string "SphereParticleEmitter"
  16190. * @returns a string containing the class name
  16191. */
  16192. getClassName(): string;
  16193. /**
  16194. * Serializes the particle system to a JSON object.
  16195. * @returns the JSON object
  16196. */
  16197. serialize(): any;
  16198. /**
  16199. * Parse properties from a JSON object
  16200. * @param serializationObject defines the JSON object
  16201. */
  16202. parse(serializationObject: any): void;
  16203. }
  16204. /**
  16205. * Particle emitter emitting particles from the inside of a sphere.
  16206. * It emits the particles randomly between two vectors.
  16207. */
  16208. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16209. /**
  16210. * The min limit of the emission direction.
  16211. */
  16212. direction1: Vector3;
  16213. /**
  16214. * The max limit of the emission direction.
  16215. */
  16216. direction2: Vector3;
  16217. /**
  16218. * Creates a new instance SphereDirectedParticleEmitter
  16219. * @param radius the radius of the emission sphere (1 by default)
  16220. * @param direction1 the min limit of the emission direction (up vector by default)
  16221. * @param direction2 the max limit of the emission direction (up vector by default)
  16222. */
  16223. constructor(radius?: number,
  16224. /**
  16225. * The min limit of the emission direction.
  16226. */
  16227. direction1?: Vector3,
  16228. /**
  16229. * The max limit of the emission direction.
  16230. */
  16231. direction2?: Vector3);
  16232. /**
  16233. * Called by the particle System when the direction is computed for the created particle.
  16234. * @param worldMatrix is the world matrix of the particle system
  16235. * @param directionToUpdate is the direction vector to update with the result
  16236. * @param particle is the particle we are computed the direction for
  16237. */
  16238. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16239. /**
  16240. * Clones the current emitter and returns a copy of it
  16241. * @returns the new emitter
  16242. */
  16243. clone(): SphereDirectedParticleEmitter;
  16244. /**
  16245. * Called by the GPUParticleSystem to setup the update shader
  16246. * @param effect defines the update shader
  16247. */
  16248. applyToShader(effect: Effect): void;
  16249. /**
  16250. * Returns a string to use to update the GPU particles update shader
  16251. * @returns a string containng the defines string
  16252. */
  16253. getEffectDefines(): string;
  16254. /**
  16255. * Returns the string "SphereDirectedParticleEmitter"
  16256. * @returns a string containing the class name
  16257. */
  16258. getClassName(): string;
  16259. /**
  16260. * Serializes the particle system to a JSON object.
  16261. * @returns the JSON object
  16262. */
  16263. serialize(): any;
  16264. /**
  16265. * Parse properties from a JSON object
  16266. * @param serializationObject defines the JSON object
  16267. */
  16268. parse(serializationObject: any): void;
  16269. }
  16270. }
  16271. declare module "babylonjs/Particles/EmitterTypes/index" {
  16272. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16273. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16274. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16275. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16276. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16277. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16278. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16279. }
  16280. declare module "babylonjs/Particles/IParticleSystem" {
  16281. import { Nullable } from "babylonjs/types";
  16282. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16284. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16285. import { Texture } from "babylonjs/Materials/Textures/texture";
  16286. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16287. import { Scene } from "babylonjs/scene";
  16288. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16289. import { Animation } from "babylonjs/Animations/animation";
  16290. /**
  16291. * Interface representing a particle system in Babylon.js.
  16292. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16293. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16294. */
  16295. export interface IParticleSystem {
  16296. /**
  16297. * List of animations used by the particle system.
  16298. */
  16299. animations: Animation[];
  16300. /**
  16301. * The id of the Particle system.
  16302. */
  16303. id: string;
  16304. /**
  16305. * The name of the Particle system.
  16306. */
  16307. name: string;
  16308. /**
  16309. * The emitter represents the Mesh or position we are attaching the particle system to.
  16310. */
  16311. emitter: Nullable<AbstractMesh | Vector3>;
  16312. /**
  16313. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16314. */
  16315. isBillboardBased: boolean;
  16316. /**
  16317. * The rendering group used by the Particle system to chose when to render.
  16318. */
  16319. renderingGroupId: number;
  16320. /**
  16321. * The layer mask we are rendering the particles through.
  16322. */
  16323. layerMask: number;
  16324. /**
  16325. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16326. */
  16327. updateSpeed: number;
  16328. /**
  16329. * The amount of time the particle system is running (depends of the overall update speed).
  16330. */
  16331. targetStopDuration: number;
  16332. /**
  16333. * The texture used to render each particle. (this can be a spritesheet)
  16334. */
  16335. particleTexture: Nullable<Texture>;
  16336. /**
  16337. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16338. */
  16339. blendMode: number;
  16340. /**
  16341. * Minimum life time of emitting particles.
  16342. */
  16343. minLifeTime: number;
  16344. /**
  16345. * Maximum life time of emitting particles.
  16346. */
  16347. maxLifeTime: number;
  16348. /**
  16349. * Minimum Size of emitting particles.
  16350. */
  16351. minSize: number;
  16352. /**
  16353. * Maximum Size of emitting particles.
  16354. */
  16355. maxSize: number;
  16356. /**
  16357. * Minimum scale of emitting particles on X axis.
  16358. */
  16359. minScaleX: number;
  16360. /**
  16361. * Maximum scale of emitting particles on X axis.
  16362. */
  16363. maxScaleX: number;
  16364. /**
  16365. * Minimum scale of emitting particles on Y axis.
  16366. */
  16367. minScaleY: number;
  16368. /**
  16369. * Maximum scale of emitting particles on Y axis.
  16370. */
  16371. maxScaleY: number;
  16372. /**
  16373. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16374. */
  16375. color1: Color4;
  16376. /**
  16377. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16378. */
  16379. color2: Color4;
  16380. /**
  16381. * Color the particle will have at the end of its lifetime.
  16382. */
  16383. colorDead: Color4;
  16384. /**
  16385. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16386. */
  16387. emitRate: number;
  16388. /**
  16389. * You can use gravity if you want to give an orientation to your particles.
  16390. */
  16391. gravity: Vector3;
  16392. /**
  16393. * Minimum power of emitting particles.
  16394. */
  16395. minEmitPower: number;
  16396. /**
  16397. * Maximum power of emitting particles.
  16398. */
  16399. maxEmitPower: number;
  16400. /**
  16401. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16402. */
  16403. minAngularSpeed: number;
  16404. /**
  16405. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16406. */
  16407. maxAngularSpeed: number;
  16408. /**
  16409. * Gets or sets the minimal initial rotation in radians.
  16410. */
  16411. minInitialRotation: number;
  16412. /**
  16413. * Gets or sets the maximal initial rotation in radians.
  16414. */
  16415. maxInitialRotation: number;
  16416. /**
  16417. * The particle emitter type defines the emitter used by the particle system.
  16418. * It can be for example box, sphere, or cone...
  16419. */
  16420. particleEmitterType: Nullable<IParticleEmitterType>;
  16421. /**
  16422. * Defines the delay in milliseconds before starting the system (0 by default)
  16423. */
  16424. startDelay: number;
  16425. /**
  16426. * 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
  16427. */
  16428. preWarmCycles: number;
  16429. /**
  16430. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16431. */
  16432. preWarmStepOffset: number;
  16433. /**
  16434. * 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)
  16435. */
  16436. spriteCellChangeSpeed: number;
  16437. /**
  16438. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16439. */
  16440. startSpriteCellID: number;
  16441. /**
  16442. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16443. */
  16444. endSpriteCellID: number;
  16445. /**
  16446. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16447. */
  16448. spriteCellWidth: number;
  16449. /**
  16450. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16451. */
  16452. spriteCellHeight: number;
  16453. /**
  16454. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16455. */
  16456. spriteRandomStartCell: boolean;
  16457. /**
  16458. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16459. */
  16460. isAnimationSheetEnabled: boolean;
  16461. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16462. translationPivot: Vector2;
  16463. /**
  16464. * Gets or sets a texture used to add random noise to particle positions
  16465. */
  16466. noiseTexture: Nullable<BaseTexture>;
  16467. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16468. noiseStrength: Vector3;
  16469. /**
  16470. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16471. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16472. */
  16473. billboardMode: number;
  16474. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16475. limitVelocityDamping: number;
  16476. /**
  16477. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16478. */
  16479. beginAnimationOnStart: boolean;
  16480. /**
  16481. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16482. */
  16483. beginAnimationFrom: number;
  16484. /**
  16485. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16486. */
  16487. beginAnimationTo: number;
  16488. /**
  16489. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16490. */
  16491. beginAnimationLoop: boolean;
  16492. /**
  16493. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16494. */
  16495. disposeOnStop: boolean;
  16496. /**
  16497. * Gets the maximum number of particles active at the same time.
  16498. * @returns The max number of active particles.
  16499. */
  16500. getCapacity(): number;
  16501. /**
  16502. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16503. * @returns True if it has been started, otherwise false.
  16504. */
  16505. isStarted(): boolean;
  16506. /**
  16507. * Animates the particle system for this frame.
  16508. */
  16509. animate(): void;
  16510. /**
  16511. * Renders the particle system in its current state.
  16512. * @returns the current number of particles
  16513. */
  16514. render(): number;
  16515. /**
  16516. * Dispose the particle system and frees its associated resources.
  16517. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16518. */
  16519. dispose(disposeTexture?: boolean): void;
  16520. /**
  16521. * Clones the particle system.
  16522. * @param name The name of the cloned object
  16523. * @param newEmitter The new emitter to use
  16524. * @returns the cloned particle system
  16525. */
  16526. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16527. /**
  16528. * Serializes the particle system to a JSON object.
  16529. * @returns the JSON object
  16530. */
  16531. serialize(): any;
  16532. /**
  16533. * Rebuild the particle system
  16534. */
  16535. rebuild(): void;
  16536. /**
  16537. * Starts the particle system and begins to emit
  16538. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16539. */
  16540. start(delay?: number): void;
  16541. /**
  16542. * Stops the particle system.
  16543. */
  16544. stop(): void;
  16545. /**
  16546. * Remove all active particles
  16547. */
  16548. reset(): void;
  16549. /**
  16550. * Is this system ready to be used/rendered
  16551. * @return true if the system is ready
  16552. */
  16553. isReady(): boolean;
  16554. /**
  16555. * Adds a new color gradient
  16556. * @param gradient defines the gradient to use (between 0 and 1)
  16557. * @param color1 defines the color to affect to the specified gradient
  16558. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16559. * @returns the current particle system
  16560. */
  16561. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16562. /**
  16563. * Remove a specific color gradient
  16564. * @param gradient defines the gradient to remove
  16565. * @returns the current particle system
  16566. */
  16567. removeColorGradient(gradient: number): IParticleSystem;
  16568. /**
  16569. * Adds a new size gradient
  16570. * @param gradient defines the gradient to use (between 0 and 1)
  16571. * @param factor defines the size factor to affect to the specified gradient
  16572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16573. * @returns the current particle system
  16574. */
  16575. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16576. /**
  16577. * Remove a specific size gradient
  16578. * @param gradient defines the gradient to remove
  16579. * @returns the current particle system
  16580. */
  16581. removeSizeGradient(gradient: number): IParticleSystem;
  16582. /**
  16583. * Gets the current list of color gradients.
  16584. * You must use addColorGradient and removeColorGradient to udpate this list
  16585. * @returns the list of color gradients
  16586. */
  16587. getColorGradients(): Nullable<Array<ColorGradient>>;
  16588. /**
  16589. * Gets the current list of size gradients.
  16590. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16591. * @returns the list of size gradients
  16592. */
  16593. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16594. /**
  16595. * Gets the current list of angular speed gradients.
  16596. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16597. * @returns the list of angular speed gradients
  16598. */
  16599. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16600. /**
  16601. * Adds a new angular speed gradient
  16602. * @param gradient defines the gradient to use (between 0 and 1)
  16603. * @param factor defines the angular speed to affect to the specified gradient
  16604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16605. * @returns the current particle system
  16606. */
  16607. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16608. /**
  16609. * Remove a specific angular speed gradient
  16610. * @param gradient defines the gradient to remove
  16611. * @returns the current particle system
  16612. */
  16613. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16614. /**
  16615. * Gets the current list of velocity gradients.
  16616. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16617. * @returns the list of velocity gradients
  16618. */
  16619. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16620. /**
  16621. * Adds a new velocity gradient
  16622. * @param gradient defines the gradient to use (between 0 and 1)
  16623. * @param factor defines the velocity to affect to the specified gradient
  16624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16625. * @returns the current particle system
  16626. */
  16627. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16628. /**
  16629. * Remove a specific velocity gradient
  16630. * @param gradient defines the gradient to remove
  16631. * @returns the current particle system
  16632. */
  16633. removeVelocityGradient(gradient: number): IParticleSystem;
  16634. /**
  16635. * Gets the current list of limit velocity gradients.
  16636. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16637. * @returns the list of limit velocity gradients
  16638. */
  16639. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16640. /**
  16641. * Adds a new limit velocity gradient
  16642. * @param gradient defines the gradient to use (between 0 and 1)
  16643. * @param factor defines the limit velocity to affect to the specified gradient
  16644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16645. * @returns the current particle system
  16646. */
  16647. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16648. /**
  16649. * Remove a specific limit velocity gradient
  16650. * @param gradient defines the gradient to remove
  16651. * @returns the current particle system
  16652. */
  16653. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16654. /**
  16655. * Adds a new drag gradient
  16656. * @param gradient defines the gradient to use (between 0 and 1)
  16657. * @param factor defines the drag to affect to the specified gradient
  16658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16659. * @returns the current particle system
  16660. */
  16661. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16662. /**
  16663. * Remove a specific drag gradient
  16664. * @param gradient defines the gradient to remove
  16665. * @returns the current particle system
  16666. */
  16667. removeDragGradient(gradient: number): IParticleSystem;
  16668. /**
  16669. * Gets the current list of drag gradients.
  16670. * You must use addDragGradient and removeDragGradient to udpate this list
  16671. * @returns the list of drag gradients
  16672. */
  16673. getDragGradients(): Nullable<Array<FactorGradient>>;
  16674. /**
  16675. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16676. * @param gradient defines the gradient to use (between 0 and 1)
  16677. * @param factor defines the emit rate to affect to the specified gradient
  16678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16679. * @returns the current particle system
  16680. */
  16681. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16682. /**
  16683. * Remove a specific emit rate gradient
  16684. * @param gradient defines the gradient to remove
  16685. * @returns the current particle system
  16686. */
  16687. removeEmitRateGradient(gradient: number): IParticleSystem;
  16688. /**
  16689. * Gets the current list of emit rate gradients.
  16690. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16691. * @returns the list of emit rate gradients
  16692. */
  16693. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16694. /**
  16695. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16696. * @param gradient defines the gradient to use (between 0 and 1)
  16697. * @param factor defines the start size to affect to the specified gradient
  16698. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16699. * @returns the current particle system
  16700. */
  16701. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16702. /**
  16703. * Remove a specific start size gradient
  16704. * @param gradient defines the gradient to remove
  16705. * @returns the current particle system
  16706. */
  16707. removeStartSizeGradient(gradient: number): IParticleSystem;
  16708. /**
  16709. * Gets the current list of start size gradients.
  16710. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16711. * @returns the list of start size gradients
  16712. */
  16713. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16714. /**
  16715. * Adds a new life time gradient
  16716. * @param gradient defines the gradient to use (between 0 and 1)
  16717. * @param factor defines the life time factor to affect to the specified gradient
  16718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16719. * @returns the current particle system
  16720. */
  16721. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16722. /**
  16723. * Remove a specific life time gradient
  16724. * @param gradient defines the gradient to remove
  16725. * @returns the current particle system
  16726. */
  16727. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16728. /**
  16729. * Gets the current list of life time gradients.
  16730. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16731. * @returns the list of life time gradients
  16732. */
  16733. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16734. /**
  16735. * Gets the current list of color gradients.
  16736. * You must use addColorGradient and removeColorGradient to udpate this list
  16737. * @returns the list of color gradients
  16738. */
  16739. getColorGradients(): Nullable<Array<ColorGradient>>;
  16740. /**
  16741. * Adds a new ramp gradient used to remap particle colors
  16742. * @param gradient defines the gradient to use (between 0 and 1)
  16743. * @param color defines the color to affect to the specified gradient
  16744. * @returns the current particle system
  16745. */
  16746. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16747. /**
  16748. * Gets the current list of ramp gradients.
  16749. * You must use addRampGradient and removeRampGradient to udpate this list
  16750. * @returns the list of ramp gradients
  16751. */
  16752. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16753. /** Gets or sets a boolean indicating that ramp gradients must be used
  16754. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16755. */
  16756. useRampGradients: boolean;
  16757. /**
  16758. * Adds a new color remap gradient
  16759. * @param gradient defines the gradient to use (between 0 and 1)
  16760. * @param min defines the color remap minimal range
  16761. * @param max defines the color remap maximal range
  16762. * @returns the current particle system
  16763. */
  16764. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16765. /**
  16766. * Gets the current list of color remap gradients.
  16767. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16768. * @returns the list of color remap gradients
  16769. */
  16770. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16771. /**
  16772. * Adds a new alpha remap gradient
  16773. * @param gradient defines the gradient to use (between 0 and 1)
  16774. * @param min defines the alpha remap minimal range
  16775. * @param max defines the alpha remap maximal range
  16776. * @returns the current particle system
  16777. */
  16778. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16779. /**
  16780. * Gets the current list of alpha remap gradients.
  16781. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16782. * @returns the list of alpha remap gradients
  16783. */
  16784. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16785. /**
  16786. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16787. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16788. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16789. * @returns the emitter
  16790. */
  16791. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16792. /**
  16793. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16794. * @param radius The radius of the hemisphere to emit from
  16795. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16796. * @returns the emitter
  16797. */
  16798. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16799. /**
  16800. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16801. * @param radius The radius of the sphere to emit from
  16802. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16803. * @returns the emitter
  16804. */
  16805. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16806. /**
  16807. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16808. * @param radius The radius of the sphere to emit from
  16809. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16810. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16811. * @returns the emitter
  16812. */
  16813. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16814. /**
  16815. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16816. * @param radius The radius of the emission cylinder
  16817. * @param height The height of the emission cylinder
  16818. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16819. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16820. * @returns the emitter
  16821. */
  16822. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16823. /**
  16824. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16825. * @param radius The radius of the cylinder to emit from
  16826. * @param height The height of the emission cylinder
  16827. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16828. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16829. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16830. * @returns the emitter
  16831. */
  16832. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16833. /**
  16834. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16835. * @param radius The radius of the cone to emit from
  16836. * @param angle The base angle of the cone
  16837. * @returns the emitter
  16838. */
  16839. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16840. /**
  16841. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16842. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16843. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16844. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16845. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16846. * @returns the emitter
  16847. */
  16848. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16849. /**
  16850. * Get hosting scene
  16851. * @returns the scene
  16852. */
  16853. getScene(): Scene;
  16854. }
  16855. }
  16856. declare module "babylonjs/Meshes/instancedMesh" {
  16857. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16858. import { Vector3 } from "babylonjs/Maths/math";
  16859. import { Camera } from "babylonjs/Cameras/camera";
  16860. import { Node } from "babylonjs/node";
  16861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16862. import { Mesh } from "babylonjs/Meshes/mesh";
  16863. import { Material } from "babylonjs/Materials/material";
  16864. import { Skeleton } from "babylonjs/Bones/skeleton";
  16865. /**
  16866. * Creates an instance based on a source mesh.
  16867. */
  16868. export class InstancedMesh extends AbstractMesh {
  16869. private _sourceMesh;
  16870. private _currentLOD;
  16871. /** @hidden */
  16872. _indexInSourceMeshInstanceArray: number;
  16873. constructor(name: string, source: Mesh);
  16874. /**
  16875. * Returns the string "InstancedMesh".
  16876. */
  16877. getClassName(): string;
  16878. /**
  16879. * If the source mesh receives shadows
  16880. */
  16881. readonly receiveShadows: boolean;
  16882. /**
  16883. * The material of the source mesh
  16884. */
  16885. readonly material: Nullable<Material>;
  16886. /**
  16887. * Visibility of the source mesh
  16888. */
  16889. readonly visibility: number;
  16890. /**
  16891. * Skeleton of the source mesh
  16892. */
  16893. readonly skeleton: Nullable<Skeleton>;
  16894. /**
  16895. * Rendering ground id of the source mesh
  16896. */
  16897. renderingGroupId: number;
  16898. /**
  16899. * Returns the total number of vertices (integer).
  16900. */
  16901. getTotalVertices(): number;
  16902. /**
  16903. * Returns a positive integer : the total number of indices in this mesh geometry.
  16904. * @returns the numner of indices or zero if the mesh has no geometry.
  16905. */
  16906. getTotalIndices(): number;
  16907. /**
  16908. * The source mesh of the instance
  16909. */
  16910. readonly sourceMesh: Mesh;
  16911. /**
  16912. * Is this node ready to be used/rendered
  16913. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16914. * @return {boolean} is it ready
  16915. */
  16916. isReady(completeCheck?: boolean): boolean;
  16917. /**
  16918. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16919. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16920. * @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.
  16921. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16922. */
  16923. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16924. /**
  16925. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16926. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16927. * The `data` are either a numeric array either a Float32Array.
  16928. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16929. * 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).
  16930. * Note that a new underlying VertexBuffer object is created each call.
  16931. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16932. *
  16933. * Possible `kind` values :
  16934. * - VertexBuffer.PositionKind
  16935. * - VertexBuffer.UVKind
  16936. * - VertexBuffer.UV2Kind
  16937. * - VertexBuffer.UV3Kind
  16938. * - VertexBuffer.UV4Kind
  16939. * - VertexBuffer.UV5Kind
  16940. * - VertexBuffer.UV6Kind
  16941. * - VertexBuffer.ColorKind
  16942. * - VertexBuffer.MatricesIndicesKind
  16943. * - VertexBuffer.MatricesIndicesExtraKind
  16944. * - VertexBuffer.MatricesWeightsKind
  16945. * - VertexBuffer.MatricesWeightsExtraKind
  16946. *
  16947. * Returns the Mesh.
  16948. */
  16949. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16950. /**
  16951. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16952. * If the mesh has no geometry, it is simply returned as it is.
  16953. * The `data` are either a numeric array either a Float32Array.
  16954. * No new underlying VertexBuffer object is created.
  16955. * 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.
  16956. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16957. *
  16958. * Possible `kind` values :
  16959. * - VertexBuffer.PositionKind
  16960. * - VertexBuffer.UVKind
  16961. * - VertexBuffer.UV2Kind
  16962. * - VertexBuffer.UV3Kind
  16963. * - VertexBuffer.UV4Kind
  16964. * - VertexBuffer.UV5Kind
  16965. * - VertexBuffer.UV6Kind
  16966. * - VertexBuffer.ColorKind
  16967. * - VertexBuffer.MatricesIndicesKind
  16968. * - VertexBuffer.MatricesIndicesExtraKind
  16969. * - VertexBuffer.MatricesWeightsKind
  16970. * - VertexBuffer.MatricesWeightsExtraKind
  16971. *
  16972. * Returns the Mesh.
  16973. */
  16974. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16975. /**
  16976. * Sets the mesh indices.
  16977. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16978. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16979. * This method creates a new index buffer each call.
  16980. * Returns the Mesh.
  16981. */
  16982. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16983. /**
  16984. * Boolean : True if the mesh owns the requested kind of data.
  16985. */
  16986. isVerticesDataPresent(kind: string): boolean;
  16987. /**
  16988. * Returns an array of indices (IndicesArray).
  16989. */
  16990. getIndices(): Nullable<IndicesArray>;
  16991. readonly _positions: Nullable<Vector3[]>;
  16992. /**
  16993. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16994. * This means the mesh underlying bounding box and sphere are recomputed.
  16995. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16996. * @returns the current mesh
  16997. */
  16998. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16999. /** @hidden */
  17000. _preActivate(): InstancedMesh;
  17001. /** @hidden */
  17002. _activate(renderId: number): InstancedMesh;
  17003. /**
  17004. * Returns the current associated LOD AbstractMesh.
  17005. */
  17006. getLOD(camera: Camera): AbstractMesh;
  17007. /** @hidden */
  17008. _syncSubMeshes(): InstancedMesh;
  17009. /** @hidden */
  17010. _generatePointsArray(): boolean;
  17011. /**
  17012. * Creates a new InstancedMesh from the current mesh.
  17013. * - name (string) : the cloned mesh name
  17014. * - newParent (optional Node) : the optional Node to parent the clone to.
  17015. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17016. *
  17017. * Returns the clone.
  17018. */
  17019. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17020. /**
  17021. * Disposes the InstancedMesh.
  17022. * Returns nothing.
  17023. */
  17024. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17025. }
  17026. }
  17027. declare module "babylonjs/Materials/shaderMaterial" {
  17028. import { Scene } from "babylonjs/scene";
  17029. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17031. import { Mesh } from "babylonjs/Meshes/mesh";
  17032. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17033. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17034. import { Texture } from "babylonjs/Materials/Textures/texture";
  17035. import { Material } from "babylonjs/Materials/material";
  17036. /**
  17037. * Defines the options associated with the creation of a shader material.
  17038. */
  17039. export interface IShaderMaterialOptions {
  17040. /**
  17041. * Does the material work in alpha blend mode
  17042. */
  17043. needAlphaBlending: boolean;
  17044. /**
  17045. * Does the material work in alpha test mode
  17046. */
  17047. needAlphaTesting: boolean;
  17048. /**
  17049. * The list of attribute names used in the shader
  17050. */
  17051. attributes: string[];
  17052. /**
  17053. * The list of unifrom names used in the shader
  17054. */
  17055. uniforms: string[];
  17056. /**
  17057. * The list of UBO names used in the shader
  17058. */
  17059. uniformBuffers: string[];
  17060. /**
  17061. * The list of sampler names used in the shader
  17062. */
  17063. samplers: string[];
  17064. /**
  17065. * The list of defines used in the shader
  17066. */
  17067. defines: string[];
  17068. }
  17069. /**
  17070. * 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.
  17071. *
  17072. * This returned material effects how the mesh will look based on the code in the shaders.
  17073. *
  17074. * @see http://doc.babylonjs.com/how_to/shader_material
  17075. */
  17076. export class ShaderMaterial extends Material {
  17077. private _shaderPath;
  17078. private _options;
  17079. private _textures;
  17080. private _textureArrays;
  17081. private _floats;
  17082. private _ints;
  17083. private _floatsArrays;
  17084. private _colors3;
  17085. private _colors3Arrays;
  17086. private _colors4;
  17087. private _vectors2;
  17088. private _vectors3;
  17089. private _vectors4;
  17090. private _matrices;
  17091. private _matrices3x3;
  17092. private _matrices2x2;
  17093. private _vectors2Arrays;
  17094. private _vectors3Arrays;
  17095. private _cachedWorldViewMatrix;
  17096. private _renderId;
  17097. /**
  17098. * Instantiate a new shader material.
  17099. * 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.
  17100. * This returned material effects how the mesh will look based on the code in the shaders.
  17101. * @see http://doc.babylonjs.com/how_to/shader_material
  17102. * @param name Define the name of the material in the scene
  17103. * @param scene Define the scene the material belongs to
  17104. * @param shaderPath Defines the route to the shader code in one of three ways:
  17105. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17106. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17107. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17108. * @param options Define the options used to create the shader
  17109. */
  17110. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17111. /**
  17112. * Gets the options used to compile the shader.
  17113. * They can be modified to trigger a new compilation
  17114. */
  17115. readonly options: IShaderMaterialOptions;
  17116. /**
  17117. * Gets the current class name of the material e.g. "ShaderMaterial"
  17118. * Mainly use in serialization.
  17119. * @returns the class name
  17120. */
  17121. getClassName(): string;
  17122. /**
  17123. * Specifies if the material will require alpha blending
  17124. * @returns a boolean specifying if alpha blending is needed
  17125. */
  17126. needAlphaBlending(): boolean;
  17127. /**
  17128. * Specifies if this material should be rendered in alpha test mode
  17129. * @returns a boolean specifying if an alpha test is needed.
  17130. */
  17131. needAlphaTesting(): boolean;
  17132. private _checkUniform;
  17133. /**
  17134. * Set a texture in the shader.
  17135. * @param name Define the name of the uniform samplers as defined in the shader
  17136. * @param texture Define the texture to bind to this sampler
  17137. * @return the material itself allowing "fluent" like uniform updates
  17138. */
  17139. setTexture(name: string, texture: Texture): ShaderMaterial;
  17140. /**
  17141. * Set a texture array in the shader.
  17142. * @param name Define the name of the uniform sampler array as defined in the shader
  17143. * @param textures Define the list of textures to bind to this sampler
  17144. * @return the material itself allowing "fluent" like uniform updates
  17145. */
  17146. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17147. /**
  17148. * Set a float in the shader.
  17149. * @param name Define the name of the uniform as defined in the shader
  17150. * @param value Define the value to give to the uniform
  17151. * @return the material itself allowing "fluent" like uniform updates
  17152. */
  17153. setFloat(name: string, value: number): ShaderMaterial;
  17154. /**
  17155. * Set a int in the shader.
  17156. * @param name Define the name of the uniform as defined in the shader
  17157. * @param value Define the value to give to the uniform
  17158. * @return the material itself allowing "fluent" like uniform updates
  17159. */
  17160. setInt(name: string, value: number): ShaderMaterial;
  17161. /**
  17162. * Set an array of floats in the shader.
  17163. * @param name Define the name of the uniform as defined in the shader
  17164. * @param value Define the value to give to the uniform
  17165. * @return the material itself allowing "fluent" like uniform updates
  17166. */
  17167. setFloats(name: string, value: number[]): ShaderMaterial;
  17168. /**
  17169. * Set a vec3 in the shader from a Color3.
  17170. * @param name Define the name of the uniform as defined in the shader
  17171. * @param value Define the value to give to the uniform
  17172. * @return the material itself allowing "fluent" like uniform updates
  17173. */
  17174. setColor3(name: string, value: Color3): ShaderMaterial;
  17175. /**
  17176. * Set a vec3 array in the shader from a Color3 array.
  17177. * @param name Define the name of the uniform as defined in the shader
  17178. * @param value Define the value to give to the uniform
  17179. * @return the material itself allowing "fluent" like uniform updates
  17180. */
  17181. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17182. /**
  17183. * Set a vec4 in the shader from a Color4.
  17184. * @param name Define the name of the uniform as defined in the shader
  17185. * @param value Define the value to give to the uniform
  17186. * @return the material itself allowing "fluent" like uniform updates
  17187. */
  17188. setColor4(name: string, value: Color4): ShaderMaterial;
  17189. /**
  17190. * Set a vec2 in the shader from a Vector2.
  17191. * @param name Define the name of the uniform as defined in the shader
  17192. * @param value Define the value to give to the uniform
  17193. * @return the material itself allowing "fluent" like uniform updates
  17194. */
  17195. setVector2(name: string, value: Vector2): ShaderMaterial;
  17196. /**
  17197. * Set a vec3 in the shader from a Vector3.
  17198. * @param name Define the name of the uniform as defined in the shader
  17199. * @param value Define the value to give to the uniform
  17200. * @return the material itself allowing "fluent" like uniform updates
  17201. */
  17202. setVector3(name: string, value: Vector3): ShaderMaterial;
  17203. /**
  17204. * Set a vec4 in the shader from a Vector4.
  17205. * @param name Define the name of the uniform as defined in the shader
  17206. * @param value Define the value to give to the uniform
  17207. * @return the material itself allowing "fluent" like uniform updates
  17208. */
  17209. setVector4(name: string, value: Vector4): ShaderMaterial;
  17210. /**
  17211. * Set a mat4 in the shader from a Matrix.
  17212. * @param name Define the name of the uniform as defined in the shader
  17213. * @param value Define the value to give to the uniform
  17214. * @return the material itself allowing "fluent" like uniform updates
  17215. */
  17216. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17217. /**
  17218. * Set a mat3 in the shader from a Float32Array.
  17219. * @param name Define the name of the uniform as defined in the shader
  17220. * @param value Define the value to give to the uniform
  17221. * @return the material itself allowing "fluent" like uniform updates
  17222. */
  17223. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17224. /**
  17225. * Set a mat2 in the shader from a Float32Array.
  17226. * @param name Define the name of the uniform as defined in the shader
  17227. * @param value Define the value to give to the uniform
  17228. * @return the material itself allowing "fluent" like uniform updates
  17229. */
  17230. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17231. /**
  17232. * Set a vec2 array in the shader from a number array.
  17233. * @param name Define the name of the uniform as defined in the shader
  17234. * @param value Define the value to give to the uniform
  17235. * @return the material itself allowing "fluent" like uniform updates
  17236. */
  17237. setArray2(name: string, value: number[]): ShaderMaterial;
  17238. /**
  17239. * Set a vec3 array in the shader from a number array.
  17240. * @param name Define the name of the uniform as defined in the shader
  17241. * @param value Define the value to give to the uniform
  17242. * @return the material itself allowing "fluent" like uniform updates
  17243. */
  17244. setArray3(name: string, value: number[]): ShaderMaterial;
  17245. private _checkCache;
  17246. /**
  17247. * Specifies that the submesh is ready to be used
  17248. * @param mesh defines the mesh to check
  17249. * @param subMesh defines which submesh to check
  17250. * @param useInstances specifies that instances should be used
  17251. * @returns a boolean indicating that the submesh is ready or not
  17252. */
  17253. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17254. /**
  17255. * Checks if the material is ready to render the requested mesh
  17256. * @param mesh Define the mesh to render
  17257. * @param useInstances Define whether or not the material is used with instances
  17258. * @returns true if ready, otherwise false
  17259. */
  17260. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17261. /**
  17262. * Binds the world matrix to the material
  17263. * @param world defines the world transformation matrix
  17264. */
  17265. bindOnlyWorldMatrix(world: Matrix): void;
  17266. /**
  17267. * Binds the material to the mesh
  17268. * @param world defines the world transformation matrix
  17269. * @param mesh defines the mesh to bind the material to
  17270. */
  17271. bind(world: Matrix, mesh?: Mesh): void;
  17272. /**
  17273. * Gets the active textures from the material
  17274. * @returns an array of textures
  17275. */
  17276. getActiveTextures(): BaseTexture[];
  17277. /**
  17278. * Specifies if the material uses a texture
  17279. * @param texture defines the texture to check against the material
  17280. * @returns a boolean specifying if the material uses the texture
  17281. */
  17282. hasTexture(texture: BaseTexture): boolean;
  17283. /**
  17284. * Makes a duplicate of the material, and gives it a new name
  17285. * @param name defines the new name for the duplicated material
  17286. * @returns the cloned material
  17287. */
  17288. clone(name: string): ShaderMaterial;
  17289. /**
  17290. * Disposes the material
  17291. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17292. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17293. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17294. */
  17295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17296. /**
  17297. * Serializes this material in a JSON representation
  17298. * @returns the serialized material object
  17299. */
  17300. serialize(): any;
  17301. /**
  17302. * Creates a shader material from parsed shader material data
  17303. * @param source defines the JSON represnetation of the material
  17304. * @param scene defines the hosting scene
  17305. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17306. * @returns a new material
  17307. */
  17308. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17309. }
  17310. }
  17311. declare module "babylonjs/Shaders/color.fragment" {
  17312. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17313. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17314. /** @hidden */
  17315. export var colorPixelShader: {
  17316. name: string;
  17317. shader: string;
  17318. };
  17319. }
  17320. declare module "babylonjs/Shaders/color.vertex" {
  17321. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17322. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17323. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17324. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17325. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17326. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17327. /** @hidden */
  17328. export var colorVertexShader: {
  17329. name: string;
  17330. shader: string;
  17331. };
  17332. }
  17333. declare module "babylonjs/Meshes/linesMesh" {
  17334. import { Nullable } from "babylonjs/types";
  17335. import { Scene } from "babylonjs/scene";
  17336. import { Color3 } from "babylonjs/Maths/math";
  17337. import { Node } from "babylonjs/node";
  17338. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17339. import { Mesh } from "babylonjs/Meshes/mesh";
  17340. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17341. import { Effect } from "babylonjs/Materials/effect";
  17342. import { Material } from "babylonjs/Materials/material";
  17343. import "babylonjs/Shaders/color.fragment";
  17344. import "babylonjs/Shaders/color.vertex";
  17345. /**
  17346. * Line mesh
  17347. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17348. */
  17349. export class LinesMesh extends Mesh {
  17350. /**
  17351. * If vertex color should be applied to the mesh
  17352. */
  17353. useVertexColor?: boolean | undefined;
  17354. /**
  17355. * If vertex alpha should be applied to the mesh
  17356. */
  17357. useVertexAlpha?: boolean | undefined;
  17358. /**
  17359. * Color of the line (Default: White)
  17360. */
  17361. color: Color3;
  17362. /**
  17363. * Alpha of the line (Default: 1)
  17364. */
  17365. alpha: number;
  17366. /**
  17367. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17368. * This margin is expressed in world space coordinates, so its value may vary.
  17369. * Default value is 0.1
  17370. */
  17371. intersectionThreshold: number;
  17372. private _colorShader;
  17373. /**
  17374. * Creates a new LinesMesh
  17375. * @param name defines the name
  17376. * @param scene defines the hosting scene
  17377. * @param parent defines the parent mesh if any
  17378. * @param source defines the optional source LinesMesh used to clone data from
  17379. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17380. * When false, achieved by calling a clone(), also passing False.
  17381. * This will make creation of children, recursive.
  17382. * @param useVertexColor defines if this LinesMesh supports vertex color
  17383. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17384. */
  17385. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17386. /**
  17387. * If vertex color should be applied to the mesh
  17388. */
  17389. useVertexColor?: boolean | undefined,
  17390. /**
  17391. * If vertex alpha should be applied to the mesh
  17392. */
  17393. useVertexAlpha?: boolean | undefined);
  17394. private _addClipPlaneDefine;
  17395. private _removeClipPlaneDefine;
  17396. isReady(): boolean;
  17397. /**
  17398. * Returns the string "LineMesh"
  17399. */
  17400. getClassName(): string;
  17401. /**
  17402. * @hidden
  17403. */
  17404. /**
  17405. * @hidden
  17406. */
  17407. material: Material;
  17408. /**
  17409. * @hidden
  17410. */
  17411. readonly checkCollisions: boolean;
  17412. /** @hidden */
  17413. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17414. /** @hidden */
  17415. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17416. /**
  17417. * Disposes of the line mesh
  17418. * @param doNotRecurse If children should be disposed
  17419. */
  17420. dispose(doNotRecurse?: boolean): void;
  17421. /**
  17422. * Returns a new LineMesh object cloned from the current one.
  17423. */
  17424. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17425. /**
  17426. * Creates a new InstancedLinesMesh object from the mesh model.
  17427. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17428. * @param name defines the name of the new instance
  17429. * @returns a new InstancedLinesMesh
  17430. */
  17431. createInstance(name: string): InstancedLinesMesh;
  17432. }
  17433. /**
  17434. * Creates an instance based on a source LinesMesh
  17435. */
  17436. export class InstancedLinesMesh extends InstancedMesh {
  17437. /**
  17438. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17439. * This margin is expressed in world space coordinates, so its value may vary.
  17440. * Initilized with the intersectionThreshold value of the source LinesMesh
  17441. */
  17442. intersectionThreshold: number;
  17443. constructor(name: string, source: LinesMesh);
  17444. /**
  17445. * Returns the string "InstancedLinesMesh".
  17446. */
  17447. getClassName(): string;
  17448. }
  17449. }
  17450. declare module "babylonjs/Shaders/line.fragment" {
  17451. /** @hidden */
  17452. export var linePixelShader: {
  17453. name: string;
  17454. shader: string;
  17455. };
  17456. }
  17457. declare module "babylonjs/Shaders/line.vertex" {
  17458. /** @hidden */
  17459. export var lineVertexShader: {
  17460. name: string;
  17461. shader: string;
  17462. };
  17463. }
  17464. declare module "babylonjs/Rendering/edgesRenderer" {
  17465. import { Nullable } from "babylonjs/types";
  17466. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17468. import { Vector3 } from "babylonjs/Maths/math";
  17469. import { IDisposable } from "babylonjs/scene";
  17470. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17471. import "babylonjs/Shaders/line.fragment";
  17472. import "babylonjs/Shaders/line.vertex";
  17473. module "babylonjs/Meshes/abstractMesh" {
  17474. interface AbstractMesh {
  17475. /**
  17476. * Disables the mesh edge rendering mode
  17477. * @returns the currentAbstractMesh
  17478. */
  17479. disableEdgesRendering(): AbstractMesh;
  17480. /**
  17481. * Enables the edge rendering mode on the mesh.
  17482. * This mode makes the mesh edges visible
  17483. * @param epsilon defines the maximal distance between two angles to detect a face
  17484. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17485. * @returns the currentAbstractMesh
  17486. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17487. */
  17488. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17489. /**
  17490. * Gets the edgesRenderer associated with the mesh
  17491. */
  17492. edgesRenderer: Nullable<EdgesRenderer>;
  17493. }
  17494. }
  17495. module "babylonjs/Meshes/linesMesh" {
  17496. interface LinesMesh {
  17497. /**
  17498. * Enables the edge rendering mode on the mesh.
  17499. * This mode makes the mesh edges visible
  17500. * @param epsilon defines the maximal distance between two angles to detect a face
  17501. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17502. * @returns the currentAbstractMesh
  17503. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17504. */
  17505. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17506. }
  17507. }
  17508. module "babylonjs/Meshes/linesMesh" {
  17509. interface InstancedLinesMesh {
  17510. /**
  17511. * Enables the edge rendering mode on the mesh.
  17512. * This mode makes the mesh edges visible
  17513. * @param epsilon defines the maximal distance between two angles to detect a face
  17514. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17515. * @returns the current InstancedLinesMesh
  17516. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17517. */
  17518. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17519. }
  17520. }
  17521. /**
  17522. * Defines the minimum contract an Edges renderer should follow.
  17523. */
  17524. export interface IEdgesRenderer extends IDisposable {
  17525. /**
  17526. * Gets or sets a boolean indicating if the edgesRenderer is active
  17527. */
  17528. isEnabled: boolean;
  17529. /**
  17530. * Renders the edges of the attached mesh,
  17531. */
  17532. render(): void;
  17533. /**
  17534. * Checks wether or not the edges renderer is ready to render.
  17535. * @return true if ready, otherwise false.
  17536. */
  17537. isReady(): boolean;
  17538. }
  17539. /**
  17540. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17541. */
  17542. export class EdgesRenderer implements IEdgesRenderer {
  17543. /**
  17544. * Define the size of the edges with an orthographic camera
  17545. */
  17546. edgesWidthScalerForOrthographic: number;
  17547. /**
  17548. * Define the size of the edges with a perspective camera
  17549. */
  17550. edgesWidthScalerForPerspective: number;
  17551. protected _source: AbstractMesh;
  17552. protected _linesPositions: number[];
  17553. protected _linesNormals: number[];
  17554. protected _linesIndices: number[];
  17555. protected _epsilon: number;
  17556. protected _indicesCount: number;
  17557. protected _lineShader: ShaderMaterial;
  17558. protected _ib: WebGLBuffer;
  17559. protected _buffers: {
  17560. [key: string]: Nullable<VertexBuffer>;
  17561. };
  17562. protected _checkVerticesInsteadOfIndices: boolean;
  17563. private _meshRebuildObserver;
  17564. private _meshDisposeObserver;
  17565. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17566. isEnabled: boolean;
  17567. /**
  17568. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17569. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17570. * @param source Mesh used to create edges
  17571. * @param epsilon sum of angles in adjacency to check for edge
  17572. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17573. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17574. */
  17575. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17576. protected _prepareRessources(): void;
  17577. /** @hidden */
  17578. _rebuild(): void;
  17579. /**
  17580. * Releases the required resources for the edges renderer
  17581. */
  17582. dispose(): void;
  17583. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17584. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17585. /**
  17586. * Checks if the pair of p0 and p1 is en edge
  17587. * @param faceIndex
  17588. * @param edge
  17589. * @param faceNormals
  17590. * @param p0
  17591. * @param p1
  17592. * @private
  17593. */
  17594. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17595. /**
  17596. * push line into the position, normal and index buffer
  17597. * @protected
  17598. */
  17599. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17600. /**
  17601. * Generates lines edges from adjacencjes
  17602. * @private
  17603. */
  17604. _generateEdgesLines(): void;
  17605. /**
  17606. * Checks wether or not the edges renderer is ready to render.
  17607. * @return true if ready, otherwise false.
  17608. */
  17609. isReady(): boolean;
  17610. /**
  17611. * Renders the edges of the attached mesh,
  17612. */
  17613. render(): void;
  17614. }
  17615. /**
  17616. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17617. */
  17618. export class LineEdgesRenderer extends EdgesRenderer {
  17619. /**
  17620. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17621. * @param source LineMesh used to generate edges
  17622. * @param epsilon not important (specified angle for edge detection)
  17623. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17624. */
  17625. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17626. /**
  17627. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17628. */
  17629. _generateEdgesLines(): void;
  17630. }
  17631. }
  17632. declare module "babylonjs/Rendering/renderingGroup" {
  17633. import { SmartArray } from "babylonjs/Misc/smartArray";
  17634. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17636. import { Nullable } from "babylonjs/types";
  17637. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17638. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17639. import { Material } from "babylonjs/Materials/material";
  17640. import { Scene } from "babylonjs/scene";
  17641. /**
  17642. * This represents the object necessary to create a rendering group.
  17643. * This is exclusively used and created by the rendering manager.
  17644. * To modify the behavior, you use the available helpers in your scene or meshes.
  17645. * @hidden
  17646. */
  17647. export class RenderingGroup {
  17648. index: number;
  17649. private _scene;
  17650. private _opaqueSubMeshes;
  17651. private _transparentSubMeshes;
  17652. private _alphaTestSubMeshes;
  17653. private _depthOnlySubMeshes;
  17654. private _particleSystems;
  17655. private _spriteManagers;
  17656. private _opaqueSortCompareFn;
  17657. private _alphaTestSortCompareFn;
  17658. private _transparentSortCompareFn;
  17659. private _renderOpaque;
  17660. private _renderAlphaTest;
  17661. private _renderTransparent;
  17662. private _edgesRenderers;
  17663. onBeforeTransparentRendering: () => void;
  17664. /**
  17665. * Set the opaque sort comparison function.
  17666. * If null the sub meshes will be render in the order they were created
  17667. */
  17668. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17669. /**
  17670. * Set the alpha test sort comparison function.
  17671. * If null the sub meshes will be render in the order they were created
  17672. */
  17673. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17674. /**
  17675. * Set the transparent sort comparison function.
  17676. * If null the sub meshes will be render in the order they were created
  17677. */
  17678. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17679. /**
  17680. * Creates a new rendering group.
  17681. * @param index The rendering group index
  17682. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17683. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17684. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17685. */
  17686. 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>);
  17687. /**
  17688. * Render all the sub meshes contained in the group.
  17689. * @param customRenderFunction Used to override the default render behaviour of the group.
  17690. * @returns true if rendered some submeshes.
  17691. */
  17692. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17693. /**
  17694. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17695. * @param subMeshes The submeshes to render
  17696. */
  17697. private renderOpaqueSorted;
  17698. /**
  17699. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17700. * @param subMeshes The submeshes to render
  17701. */
  17702. private renderAlphaTestSorted;
  17703. /**
  17704. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17705. * @param subMeshes The submeshes to render
  17706. */
  17707. private renderTransparentSorted;
  17708. /**
  17709. * Renders the submeshes in a specified order.
  17710. * @param subMeshes The submeshes to sort before render
  17711. * @param sortCompareFn The comparison function use to sort
  17712. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17713. * @param transparent Specifies to activate blending if true
  17714. */
  17715. private static renderSorted;
  17716. /**
  17717. * Renders the submeshes in the order they were dispatched (no sort applied).
  17718. * @param subMeshes The submeshes to render
  17719. */
  17720. private static renderUnsorted;
  17721. /**
  17722. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17723. * are rendered back to front if in the same alpha index.
  17724. *
  17725. * @param a The first submesh
  17726. * @param b The second submesh
  17727. * @returns The result of the comparison
  17728. */
  17729. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17730. /**
  17731. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17732. * are rendered back to front.
  17733. *
  17734. * @param a The first submesh
  17735. * @param b The second submesh
  17736. * @returns The result of the comparison
  17737. */
  17738. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17739. /**
  17740. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17741. * are rendered front to back (prevent overdraw).
  17742. *
  17743. * @param a The first submesh
  17744. * @param b The second submesh
  17745. * @returns The result of the comparison
  17746. */
  17747. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17748. /**
  17749. * Resets the different lists of submeshes to prepare a new frame.
  17750. */
  17751. prepare(): void;
  17752. dispose(): void;
  17753. /**
  17754. * Inserts the submesh in its correct queue depending on its material.
  17755. * @param subMesh The submesh to dispatch
  17756. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17757. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17758. */
  17759. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17760. dispatchSprites(spriteManager: ISpriteManager): void;
  17761. dispatchParticles(particleSystem: IParticleSystem): void;
  17762. private _renderParticles;
  17763. private _renderSprites;
  17764. }
  17765. }
  17766. declare module "babylonjs/Rendering/renderingManager" {
  17767. import { Nullable } from "babylonjs/types";
  17768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17769. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17770. import { SmartArray } from "babylonjs/Misc/smartArray";
  17771. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17772. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17773. import { Material } from "babylonjs/Materials/material";
  17774. import { Scene } from "babylonjs/scene";
  17775. import { Camera } from "babylonjs/Cameras/camera";
  17776. /**
  17777. * Interface describing the different options available in the rendering manager
  17778. * regarding Auto Clear between groups.
  17779. */
  17780. export interface IRenderingManagerAutoClearSetup {
  17781. /**
  17782. * Defines whether or not autoclear is enable.
  17783. */
  17784. autoClear: boolean;
  17785. /**
  17786. * Defines whether or not to autoclear the depth buffer.
  17787. */
  17788. depth: boolean;
  17789. /**
  17790. * Defines whether or not to autoclear the stencil buffer.
  17791. */
  17792. stencil: boolean;
  17793. }
  17794. /**
  17795. * This class is used by the onRenderingGroupObservable
  17796. */
  17797. export class RenderingGroupInfo {
  17798. /**
  17799. * The Scene that being rendered
  17800. */
  17801. scene: Scene;
  17802. /**
  17803. * The camera currently used for the rendering pass
  17804. */
  17805. camera: Nullable<Camera>;
  17806. /**
  17807. * The ID of the renderingGroup being processed
  17808. */
  17809. renderingGroupId: number;
  17810. }
  17811. /**
  17812. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17813. * It is enable to manage the different groups as well as the different necessary sort functions.
  17814. * This should not be used directly aside of the few static configurations
  17815. */
  17816. export class RenderingManager {
  17817. /**
  17818. * The max id used for rendering groups (not included)
  17819. */
  17820. static MAX_RENDERINGGROUPS: number;
  17821. /**
  17822. * The min id used for rendering groups (included)
  17823. */
  17824. static MIN_RENDERINGGROUPS: number;
  17825. /**
  17826. * Used to globally prevent autoclearing scenes.
  17827. */
  17828. static AUTOCLEAR: boolean;
  17829. /**
  17830. * @hidden
  17831. */
  17832. _useSceneAutoClearSetup: boolean;
  17833. private _scene;
  17834. private _renderingGroups;
  17835. private _depthStencilBufferAlreadyCleaned;
  17836. private _autoClearDepthStencil;
  17837. private _customOpaqueSortCompareFn;
  17838. private _customAlphaTestSortCompareFn;
  17839. private _customTransparentSortCompareFn;
  17840. private _renderingGroupInfo;
  17841. /**
  17842. * Instantiates a new rendering group for a particular scene
  17843. * @param scene Defines the scene the groups belongs to
  17844. */
  17845. constructor(scene: Scene);
  17846. private _clearDepthStencilBuffer;
  17847. /**
  17848. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17849. * @hidden
  17850. */
  17851. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17852. /**
  17853. * Resets the different information of the group to prepare a new frame
  17854. * @hidden
  17855. */
  17856. reset(): void;
  17857. /**
  17858. * Dispose and release the group and its associated resources.
  17859. * @hidden
  17860. */
  17861. dispose(): void;
  17862. /**
  17863. * Clear the info related to rendering groups preventing retention points during dispose.
  17864. */
  17865. freeRenderingGroups(): void;
  17866. private _prepareRenderingGroup;
  17867. /**
  17868. * Add a sprite manager to the rendering manager in order to render it this frame.
  17869. * @param spriteManager Define the sprite manager to render
  17870. */
  17871. dispatchSprites(spriteManager: ISpriteManager): void;
  17872. /**
  17873. * Add a particle system to the rendering manager in order to render it this frame.
  17874. * @param particleSystem Define the particle system to render
  17875. */
  17876. dispatchParticles(particleSystem: IParticleSystem): void;
  17877. /**
  17878. * Add a submesh to the manager in order to render it this frame
  17879. * @param subMesh The submesh to dispatch
  17880. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17881. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17882. */
  17883. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17884. /**
  17885. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17886. * This allowed control for front to back rendering or reversly depending of the special needs.
  17887. *
  17888. * @param renderingGroupId The rendering group id corresponding to its index
  17889. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17890. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17891. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17892. */
  17893. 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;
  17894. /**
  17895. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17896. *
  17897. * @param renderingGroupId The rendering group id corresponding to its index
  17898. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17899. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17900. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17901. */
  17902. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17903. /**
  17904. * Gets the current auto clear configuration for one rendering group of the rendering
  17905. * manager.
  17906. * @param index the rendering group index to get the information for
  17907. * @returns The auto clear setup for the requested rendering group
  17908. */
  17909. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17910. }
  17911. }
  17912. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17913. import { Observable } from "babylonjs/Misc/observable";
  17914. import { SmartArray } from "babylonjs/Misc/smartArray";
  17915. import { Nullable } from "babylonjs/types";
  17916. import { Camera } from "babylonjs/Cameras/camera";
  17917. import { Scene } from "babylonjs/scene";
  17918. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17919. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17921. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17922. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17923. import { Texture } from "babylonjs/Materials/Textures/texture";
  17924. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17925. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17926. import { Engine } from "babylonjs/Engines/engine";
  17927. /**
  17928. * This Helps creating a texture that will be created from a camera in your scene.
  17929. * It is basically a dynamic texture that could be used to create special effects for instance.
  17930. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17931. */
  17932. export class RenderTargetTexture extends Texture {
  17933. isCube: boolean;
  17934. /**
  17935. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17936. */
  17937. static readonly REFRESHRATE_RENDER_ONCE: number;
  17938. /**
  17939. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17940. */
  17941. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17942. /**
  17943. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17944. * the central point of your effect and can save a lot of performances.
  17945. */
  17946. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17947. /**
  17948. * Use this predicate to dynamically define the list of mesh you want to render.
  17949. * If set, the renderList property will be overwritten.
  17950. */
  17951. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17952. private _renderList;
  17953. /**
  17954. * Use this list to define the list of mesh you want to render.
  17955. */
  17956. renderList: Nullable<Array<AbstractMesh>>;
  17957. private _hookArray;
  17958. /**
  17959. * Define if particles should be rendered in your texture.
  17960. */
  17961. renderParticles: boolean;
  17962. /**
  17963. * Define if sprites should be rendered in your texture.
  17964. */
  17965. renderSprites: boolean;
  17966. /**
  17967. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17968. */
  17969. coordinatesMode: number;
  17970. /**
  17971. * Define the camera used to render the texture.
  17972. */
  17973. activeCamera: Nullable<Camera>;
  17974. /**
  17975. * Override the render function of the texture with your own one.
  17976. */
  17977. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17978. /**
  17979. * Define if camera post processes should be use while rendering the texture.
  17980. */
  17981. useCameraPostProcesses: boolean;
  17982. /**
  17983. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17984. */
  17985. ignoreCameraViewport: boolean;
  17986. private _postProcessManager;
  17987. private _postProcesses;
  17988. private _resizeObserver;
  17989. /**
  17990. * An event triggered when the texture is unbind.
  17991. */
  17992. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17993. /**
  17994. * An event triggered when the texture is unbind.
  17995. */
  17996. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17997. private _onAfterUnbindObserver;
  17998. /**
  17999. * Set a after unbind callback in the texture.
  18000. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18001. */
  18002. onAfterUnbind: () => void;
  18003. /**
  18004. * An event triggered before rendering the texture
  18005. */
  18006. onBeforeRenderObservable: Observable<number>;
  18007. private _onBeforeRenderObserver;
  18008. /**
  18009. * Set a before render callback in the texture.
  18010. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18011. */
  18012. onBeforeRender: (faceIndex: number) => void;
  18013. /**
  18014. * An event triggered after rendering the texture
  18015. */
  18016. onAfterRenderObservable: Observable<number>;
  18017. private _onAfterRenderObserver;
  18018. /**
  18019. * Set a after render callback in the texture.
  18020. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18021. */
  18022. onAfterRender: (faceIndex: number) => void;
  18023. /**
  18024. * An event triggered after the texture clear
  18025. */
  18026. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18027. private _onClearObserver;
  18028. /**
  18029. * Set a clear callback in the texture.
  18030. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18031. */
  18032. onClear: (Engine: Engine) => void;
  18033. /**
  18034. * Define the clear color of the Render Target if it should be different from the scene.
  18035. */
  18036. clearColor: Color4;
  18037. protected _size: number | {
  18038. width: number;
  18039. height: number;
  18040. };
  18041. protected _initialSizeParameter: number | {
  18042. width: number;
  18043. height: number;
  18044. } | {
  18045. ratio: number;
  18046. };
  18047. protected _sizeRatio: Nullable<number>;
  18048. /** @hidden */
  18049. _generateMipMaps: boolean;
  18050. protected _renderingManager: RenderingManager;
  18051. /** @hidden */
  18052. _waitingRenderList: string[];
  18053. protected _doNotChangeAspectRatio: boolean;
  18054. protected _currentRefreshId: number;
  18055. protected _refreshRate: number;
  18056. protected _textureMatrix: Matrix;
  18057. protected _samples: number;
  18058. protected _renderTargetOptions: RenderTargetCreationOptions;
  18059. /**
  18060. * Gets render target creation options that were used.
  18061. */
  18062. readonly renderTargetOptions: RenderTargetCreationOptions;
  18063. protected _engine: Engine;
  18064. protected _onRatioRescale(): void;
  18065. /**
  18066. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18067. * It must define where the camera used to render the texture is set
  18068. */
  18069. boundingBoxPosition: Vector3;
  18070. private _boundingBoxSize;
  18071. /**
  18072. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18073. * When defined, the cubemap will switch to local mode
  18074. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18075. * @example https://www.babylonjs-playground.com/#RNASML
  18076. */
  18077. boundingBoxSize: Vector3;
  18078. /**
  18079. * In case the RTT has been created with a depth texture, get the associated
  18080. * depth texture.
  18081. * Otherwise, return null.
  18082. */
  18083. depthStencilTexture: Nullable<InternalTexture>;
  18084. /**
  18085. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18086. * or used a shadow, depth texture...
  18087. * @param name The friendly name of the texture
  18088. * @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)
  18089. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18090. * @param generateMipMaps True if mip maps need to be generated after render.
  18091. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18092. * @param type The type of the buffer in the RTT (int, half float, float...)
  18093. * @param isCube True if a cube texture needs to be created
  18094. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18095. * @param generateDepthBuffer True to generate a depth buffer
  18096. * @param generateStencilBuffer True to generate a stencil buffer
  18097. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18098. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18099. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18100. */
  18101. constructor(name: string, size: number | {
  18102. width: number;
  18103. height: number;
  18104. } | {
  18105. ratio: number;
  18106. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18107. /**
  18108. * Creates a depth stencil texture.
  18109. * This is only available in WebGL 2 or with the depth texture extension available.
  18110. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18111. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18112. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18113. */
  18114. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18115. private _processSizeParameter;
  18116. /**
  18117. * Define the number of samples to use in case of MSAA.
  18118. * It defaults to one meaning no MSAA has been enabled.
  18119. */
  18120. samples: number;
  18121. /**
  18122. * Resets the refresh counter of the texture and start bak from scratch.
  18123. * Could be useful to regenerate the texture if it is setup to render only once.
  18124. */
  18125. resetRefreshCounter(): void;
  18126. /**
  18127. * Define the refresh rate of the texture or the rendering frequency.
  18128. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18129. */
  18130. refreshRate: number;
  18131. /**
  18132. * Adds a post process to the render target rendering passes.
  18133. * @param postProcess define the post process to add
  18134. */
  18135. addPostProcess(postProcess: PostProcess): void;
  18136. /**
  18137. * Clear all the post processes attached to the render target
  18138. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18139. */
  18140. clearPostProcesses(dispose?: boolean): void;
  18141. /**
  18142. * Remove one of the post process from the list of attached post processes to the texture
  18143. * @param postProcess define the post process to remove from the list
  18144. */
  18145. removePostProcess(postProcess: PostProcess): void;
  18146. /** @hidden */
  18147. _shouldRender(): boolean;
  18148. /**
  18149. * Gets the actual render size of the texture.
  18150. * @returns the width of the render size
  18151. */
  18152. getRenderSize(): number;
  18153. /**
  18154. * Gets the actual render width of the texture.
  18155. * @returns the width of the render size
  18156. */
  18157. getRenderWidth(): number;
  18158. /**
  18159. * Gets the actual render height of the texture.
  18160. * @returns the height of the render size
  18161. */
  18162. getRenderHeight(): number;
  18163. /**
  18164. * Get if the texture can be rescaled or not.
  18165. */
  18166. readonly canRescale: boolean;
  18167. /**
  18168. * Resize the texture using a ratio.
  18169. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18170. */
  18171. scale(ratio: number): void;
  18172. /**
  18173. * Get the texture reflection matrix used to rotate/transform the reflection.
  18174. * @returns the reflection matrix
  18175. */
  18176. getReflectionTextureMatrix(): Matrix;
  18177. /**
  18178. * Resize the texture to a new desired size.
  18179. * Be carrefull as it will recreate all the data in the new texture.
  18180. * @param size Define the new size. It can be:
  18181. * - a number for squared texture,
  18182. * - an object containing { width: number, height: number }
  18183. * - or an object containing a ratio { ratio: number }
  18184. */
  18185. resize(size: number | {
  18186. width: number;
  18187. height: number;
  18188. } | {
  18189. ratio: number;
  18190. }): void;
  18191. /**
  18192. * Renders all the objects from the render list into the texture.
  18193. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18194. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18195. */
  18196. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18197. private _bestReflectionRenderTargetDimension;
  18198. /**
  18199. * @hidden
  18200. * @param faceIndex face index to bind to if this is a cubetexture
  18201. */
  18202. _bindFrameBuffer(faceIndex?: number): void;
  18203. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18204. private renderToTarget;
  18205. /**
  18206. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18207. * This allowed control for front to back rendering or reversly depending of the special needs.
  18208. *
  18209. * @param renderingGroupId The rendering group id corresponding to its index
  18210. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18211. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18212. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18213. */
  18214. 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;
  18215. /**
  18216. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18217. *
  18218. * @param renderingGroupId The rendering group id corresponding to its index
  18219. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18220. */
  18221. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18222. /**
  18223. * Clones the texture.
  18224. * @returns the cloned texture
  18225. */
  18226. clone(): RenderTargetTexture;
  18227. /**
  18228. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18229. * @returns The JSON representation of the texture
  18230. */
  18231. serialize(): any;
  18232. /**
  18233. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18234. */
  18235. disposeFramebufferObjects(): void;
  18236. /**
  18237. * Dispose the texture and release its associated resources.
  18238. */
  18239. dispose(): void;
  18240. /** @hidden */
  18241. _rebuild(): void;
  18242. /**
  18243. * Clear the info related to rendering groups preventing retention point in material dispose.
  18244. */
  18245. freeRenderingGroups(): void;
  18246. /**
  18247. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18248. * @returns the view count
  18249. */
  18250. getViewCount(): number;
  18251. }
  18252. /**
  18253. * Renders to multiple views with a single draw call
  18254. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  18255. */
  18256. export class MultiviewRenderTarget extends RenderTargetTexture {
  18257. /**
  18258. * Creates a multiview render target
  18259. * @param scene scene used with the render target
  18260. * @param size the size of the render target (used for each view)
  18261. */
  18262. constructor(scene: Scene, size?: number | {
  18263. width: number;
  18264. height: number;
  18265. } | {
  18266. ratio: number;
  18267. });
  18268. /**
  18269. * @hidden
  18270. * @param faceIndex the face index, if its a cube texture
  18271. */
  18272. _bindFrameBuffer(faceIndex?: number): void;
  18273. /**
  18274. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18275. * @returns the view count
  18276. */
  18277. getViewCount(): number;
  18278. }
  18279. }
  18280. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18281. import { Scene } from "babylonjs/scene";
  18282. import { Plane } from "babylonjs/Maths/math";
  18283. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18284. /**
  18285. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18286. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18287. * You can then easily use it as a reflectionTexture on a flat surface.
  18288. * In case the surface is not a plane, please consider relying on reflection probes.
  18289. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18290. */
  18291. export class MirrorTexture extends RenderTargetTexture {
  18292. private scene;
  18293. /**
  18294. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18295. * 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.
  18296. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18297. */
  18298. mirrorPlane: Plane;
  18299. /**
  18300. * Define the blur ratio used to blur the reflection if needed.
  18301. */
  18302. blurRatio: number;
  18303. /**
  18304. * Define the adaptive blur kernel used to blur the reflection if needed.
  18305. * This will autocompute the closest best match for the `blurKernel`
  18306. */
  18307. adaptiveBlurKernel: number;
  18308. /**
  18309. * Define the blur kernel used to blur the reflection if needed.
  18310. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18311. */
  18312. blurKernel: number;
  18313. /**
  18314. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18315. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18316. */
  18317. blurKernelX: number;
  18318. /**
  18319. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18320. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18321. */
  18322. blurKernelY: number;
  18323. private _autoComputeBlurKernel;
  18324. protected _onRatioRescale(): void;
  18325. private _updateGammaSpace;
  18326. private _imageProcessingConfigChangeObserver;
  18327. private _transformMatrix;
  18328. private _mirrorMatrix;
  18329. private _savedViewMatrix;
  18330. private _blurX;
  18331. private _blurY;
  18332. private _adaptiveBlurKernel;
  18333. private _blurKernelX;
  18334. private _blurKernelY;
  18335. private _blurRatio;
  18336. /**
  18337. * Instantiates a Mirror Texture.
  18338. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18339. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18340. * You can then easily use it as a reflectionTexture on a flat surface.
  18341. * In case the surface is not a plane, please consider relying on reflection probes.
  18342. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18343. * @param name
  18344. * @param size
  18345. * @param scene
  18346. * @param generateMipMaps
  18347. * @param type
  18348. * @param samplingMode
  18349. * @param generateDepthBuffer
  18350. */
  18351. constructor(name: string, size: number | {
  18352. width: number;
  18353. height: number;
  18354. } | {
  18355. ratio: number;
  18356. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18357. private _preparePostProcesses;
  18358. /**
  18359. * Clone the mirror texture.
  18360. * @returns the cloned texture
  18361. */
  18362. clone(): MirrorTexture;
  18363. /**
  18364. * Serialize the texture to a JSON representation you could use in Parse later on
  18365. * @returns the serialized JSON representation
  18366. */
  18367. serialize(): any;
  18368. /**
  18369. * Dispose the texture and release its associated resources.
  18370. */
  18371. dispose(): void;
  18372. }
  18373. }
  18374. declare module "babylonjs/Materials/Textures/texture" {
  18375. import { Observable } from "babylonjs/Misc/observable";
  18376. import { Nullable } from "babylonjs/types";
  18377. import { Scene } from "babylonjs/scene";
  18378. import { Matrix } from "babylonjs/Maths/math";
  18379. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18380. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18381. /**
  18382. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18383. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18384. */
  18385. export class Texture extends BaseTexture {
  18386. /** @hidden */
  18387. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18388. /** @hidden */
  18389. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18390. /** @hidden */
  18391. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18392. /** nearest is mag = nearest and min = nearest and mip = linear */
  18393. static readonly NEAREST_SAMPLINGMODE: number;
  18394. /** nearest is mag = nearest and min = nearest and mip = linear */
  18395. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18396. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18397. static readonly BILINEAR_SAMPLINGMODE: number;
  18398. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18399. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18400. /** Trilinear is mag = linear and min = linear and mip = linear */
  18401. static readonly TRILINEAR_SAMPLINGMODE: number;
  18402. /** Trilinear is mag = linear and min = linear and mip = linear */
  18403. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18404. /** mag = nearest and min = nearest and mip = nearest */
  18405. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18406. /** mag = nearest and min = linear and mip = nearest */
  18407. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18408. /** mag = nearest and min = linear and mip = linear */
  18409. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18410. /** mag = nearest and min = linear and mip = none */
  18411. static readonly NEAREST_LINEAR: number;
  18412. /** mag = nearest and min = nearest and mip = none */
  18413. static readonly NEAREST_NEAREST: number;
  18414. /** mag = linear and min = nearest and mip = nearest */
  18415. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18416. /** mag = linear and min = nearest and mip = linear */
  18417. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18418. /** mag = linear and min = linear and mip = none */
  18419. static readonly LINEAR_LINEAR: number;
  18420. /** mag = linear and min = nearest and mip = none */
  18421. static readonly LINEAR_NEAREST: number;
  18422. /** Explicit coordinates mode */
  18423. static readonly EXPLICIT_MODE: number;
  18424. /** Spherical coordinates mode */
  18425. static readonly SPHERICAL_MODE: number;
  18426. /** Planar coordinates mode */
  18427. static readonly PLANAR_MODE: number;
  18428. /** Cubic coordinates mode */
  18429. static readonly CUBIC_MODE: number;
  18430. /** Projection coordinates mode */
  18431. static readonly PROJECTION_MODE: number;
  18432. /** Inverse Cubic coordinates mode */
  18433. static readonly SKYBOX_MODE: number;
  18434. /** Inverse Cubic coordinates mode */
  18435. static readonly INVCUBIC_MODE: number;
  18436. /** Equirectangular coordinates mode */
  18437. static readonly EQUIRECTANGULAR_MODE: number;
  18438. /** Equirectangular Fixed coordinates mode */
  18439. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18440. /** Equirectangular Fixed Mirrored coordinates mode */
  18441. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18442. /** Texture is not repeating outside of 0..1 UVs */
  18443. static readonly CLAMP_ADDRESSMODE: number;
  18444. /** Texture is repeating outside of 0..1 UVs */
  18445. static readonly WRAP_ADDRESSMODE: number;
  18446. /** Texture is repeating and mirrored */
  18447. static readonly MIRROR_ADDRESSMODE: number;
  18448. /**
  18449. * 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
  18450. */
  18451. static UseSerializedUrlIfAny: boolean;
  18452. /**
  18453. * Define the url of the texture.
  18454. */
  18455. url: Nullable<string>;
  18456. /**
  18457. * Define an offset on the texture to offset the u coordinates of the UVs
  18458. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18459. */
  18460. uOffset: number;
  18461. /**
  18462. * Define an offset on the texture to offset the v coordinates of the UVs
  18463. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18464. */
  18465. vOffset: number;
  18466. /**
  18467. * Define an offset on the texture to scale the u coordinates of the UVs
  18468. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18469. */
  18470. uScale: number;
  18471. /**
  18472. * Define an offset on the texture to scale the v coordinates of the UVs
  18473. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18474. */
  18475. vScale: number;
  18476. /**
  18477. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18478. * @see http://doc.babylonjs.com/how_to/more_materials
  18479. */
  18480. uAng: number;
  18481. /**
  18482. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18483. * @see http://doc.babylonjs.com/how_to/more_materials
  18484. */
  18485. vAng: number;
  18486. /**
  18487. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18488. * @see http://doc.babylonjs.com/how_to/more_materials
  18489. */
  18490. wAng: number;
  18491. /**
  18492. * Defines the center of rotation (U)
  18493. */
  18494. uRotationCenter: number;
  18495. /**
  18496. * Defines the center of rotation (V)
  18497. */
  18498. vRotationCenter: number;
  18499. /**
  18500. * Defines the center of rotation (W)
  18501. */
  18502. wRotationCenter: number;
  18503. /**
  18504. * Are mip maps generated for this texture or not.
  18505. */
  18506. readonly noMipmap: boolean;
  18507. /**
  18508. * List of inspectable custom properties (used by the Inspector)
  18509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18510. */
  18511. inspectableCustomProperties: IInspectable[];
  18512. private _noMipmap;
  18513. /** @hidden */
  18514. _invertY: boolean;
  18515. private _rowGenerationMatrix;
  18516. private _cachedTextureMatrix;
  18517. private _projectionModeMatrix;
  18518. private _t0;
  18519. private _t1;
  18520. private _t2;
  18521. private _cachedUOffset;
  18522. private _cachedVOffset;
  18523. private _cachedUScale;
  18524. private _cachedVScale;
  18525. private _cachedUAng;
  18526. private _cachedVAng;
  18527. private _cachedWAng;
  18528. private _cachedProjectionMatrixId;
  18529. private _cachedCoordinatesMode;
  18530. /** @hidden */
  18531. protected _initialSamplingMode: number;
  18532. /** @hidden */
  18533. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18534. private _deleteBuffer;
  18535. protected _format: Nullable<number>;
  18536. private _delayedOnLoad;
  18537. private _delayedOnError;
  18538. /**
  18539. * Observable triggered once the texture has been loaded.
  18540. */
  18541. onLoadObservable: Observable<Texture>;
  18542. protected _isBlocking: boolean;
  18543. /**
  18544. * Is the texture preventing material to render while loading.
  18545. * If false, a default texture will be used instead of the loading one during the preparation step.
  18546. */
  18547. isBlocking: boolean;
  18548. /**
  18549. * Get the current sampling mode associated with the texture.
  18550. */
  18551. readonly samplingMode: number;
  18552. /**
  18553. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18554. */
  18555. readonly invertY: boolean;
  18556. /**
  18557. * Instantiates a new texture.
  18558. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18559. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18560. * @param url define the url of the picture to load as a texture
  18561. * @param scene define the scene the texture will belong to
  18562. * @param noMipmap define if the texture will require mip maps or not
  18563. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18564. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18565. * @param onLoad define a callback triggered when the texture has been loaded
  18566. * @param onError define a callback triggered when an error occurred during the loading session
  18567. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18568. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18569. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18570. */
  18571. 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);
  18572. /**
  18573. * Update the url (and optional buffer) of this texture if url was null during construction.
  18574. * @param url the url of the texture
  18575. * @param buffer the buffer of the texture (defaults to null)
  18576. * @param onLoad callback called when the texture is loaded (defaults to null)
  18577. */
  18578. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18579. /**
  18580. * Finish the loading sequence of a texture flagged as delayed load.
  18581. * @hidden
  18582. */
  18583. delayLoad(): void;
  18584. private _prepareRowForTextureGeneration;
  18585. /**
  18586. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18587. * @returns the transform matrix of the texture.
  18588. */
  18589. getTextureMatrix(): Matrix;
  18590. /**
  18591. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18592. * @returns The reflection texture transform
  18593. */
  18594. getReflectionTextureMatrix(): Matrix;
  18595. /**
  18596. * Clones the texture.
  18597. * @returns the cloned texture
  18598. */
  18599. clone(): Texture;
  18600. /**
  18601. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18602. * @returns The JSON representation of the texture
  18603. */
  18604. serialize(): any;
  18605. /**
  18606. * Get the current class name of the texture useful for serialization or dynamic coding.
  18607. * @returns "Texture"
  18608. */
  18609. getClassName(): string;
  18610. /**
  18611. * Dispose the texture and release its associated resources.
  18612. */
  18613. dispose(): void;
  18614. /**
  18615. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18616. * @param parsedTexture Define the JSON representation of the texture
  18617. * @param scene Define the scene the parsed texture should be instantiated in
  18618. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18619. * @returns The parsed texture if successful
  18620. */
  18621. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18622. /**
  18623. * Creates a texture from its base 64 representation.
  18624. * @param data Define the base64 payload without the data: prefix
  18625. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18626. * @param scene Define the scene the texture should belong to
  18627. * @param noMipmap Forces the texture to not create mip map information if true
  18628. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18629. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18630. * @param onLoad define a callback triggered when the texture has been loaded
  18631. * @param onError define a callback triggered when an error occurred during the loading session
  18632. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18633. * @returns the created texture
  18634. */
  18635. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18636. /**
  18637. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18638. * @param data Define the base64 payload without the data: prefix
  18639. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18640. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18641. * @param scene Define the scene the texture should belong to
  18642. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18643. * @param noMipmap Forces the texture to not create mip map information if true
  18644. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18645. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18646. * @param onLoad define a callback triggered when the texture has been loaded
  18647. * @param onError define a callback triggered when an error occurred during the loading session
  18648. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18649. * @returns the created texture
  18650. */
  18651. 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;
  18652. }
  18653. }
  18654. declare module "babylonjs/Materials/Textures/rawTexture" {
  18655. import { Scene } from "babylonjs/scene";
  18656. import { Texture } from "babylonjs/Materials/Textures/texture";
  18657. /**
  18658. * Raw texture can help creating a texture directly from an array of data.
  18659. * This can be super useful if you either get the data from an uncompressed source or
  18660. * if you wish to create your texture pixel by pixel.
  18661. */
  18662. export class RawTexture extends Texture {
  18663. /**
  18664. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18665. */
  18666. format: number;
  18667. private _engine;
  18668. /**
  18669. * Instantiates a new RawTexture.
  18670. * Raw texture can help creating a texture directly from an array of data.
  18671. * This can be super useful if you either get the data from an uncompressed source or
  18672. * if you wish to create your texture pixel by pixel.
  18673. * @param data define the array of data to use to create the texture
  18674. * @param width define the width of the texture
  18675. * @param height define the height of the texture
  18676. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18677. * @param scene define the scene the texture belongs to
  18678. * @param generateMipMaps define whether mip maps should be generated or not
  18679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18681. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18682. */
  18683. constructor(data: ArrayBufferView, width: number, height: number,
  18684. /**
  18685. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18686. */
  18687. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18688. /**
  18689. * Updates the texture underlying data.
  18690. * @param data Define the new data of the texture
  18691. */
  18692. update(data: ArrayBufferView): void;
  18693. /**
  18694. * Creates a luminance texture from some data.
  18695. * @param data Define the texture data
  18696. * @param width Define the width of the texture
  18697. * @param height Define the height of the texture
  18698. * @param scene Define the scene the texture belongs to
  18699. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18700. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18701. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18702. * @returns the luminance texture
  18703. */
  18704. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18705. /**
  18706. * Creates a luminance alpha texture from some data.
  18707. * @param data Define the texture data
  18708. * @param width Define the width of the texture
  18709. * @param height Define the height of the texture
  18710. * @param scene Define the scene the texture belongs to
  18711. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18712. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18713. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18714. * @returns the luminance alpha texture
  18715. */
  18716. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18717. /**
  18718. * Creates an alpha texture from some data.
  18719. * @param data Define the texture data
  18720. * @param width Define the width of the texture
  18721. * @param height Define the height of the texture
  18722. * @param scene Define the scene the texture belongs to
  18723. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18724. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18725. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18726. * @returns the alpha texture
  18727. */
  18728. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18729. /**
  18730. * Creates a RGB texture from some data.
  18731. * @param data Define the texture data
  18732. * @param width Define the width of the texture
  18733. * @param height Define the height of the texture
  18734. * @param scene Define the scene the texture belongs to
  18735. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18736. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18737. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18738. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18739. * @returns the RGB alpha texture
  18740. */
  18741. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18742. /**
  18743. * Creates a RGBA texture from some data.
  18744. * @param data Define the texture data
  18745. * @param width Define the width of the texture
  18746. * @param height Define the height of the texture
  18747. * @param scene Define the scene the texture belongs to
  18748. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18749. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18750. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18751. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18752. * @returns the RGBA texture
  18753. */
  18754. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18755. /**
  18756. * Creates a R texture from some data.
  18757. * @param data Define the texture data
  18758. * @param width Define the width of the texture
  18759. * @param height Define the height of the texture
  18760. * @param scene Define the scene the texture belongs to
  18761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18764. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18765. * @returns the R texture
  18766. */
  18767. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18768. }
  18769. }
  18770. declare module "babylonjs/Animations/runtimeAnimation" {
  18771. import { Animation } from "babylonjs/Animations/animation";
  18772. import { Animatable } from "babylonjs/Animations/animatable";
  18773. import { Scene } from "babylonjs/scene";
  18774. /**
  18775. * Defines a runtime animation
  18776. */
  18777. export class RuntimeAnimation {
  18778. private _events;
  18779. /**
  18780. * The current frame of the runtime animation
  18781. */
  18782. private _currentFrame;
  18783. /**
  18784. * The animation used by the runtime animation
  18785. */
  18786. private _animation;
  18787. /**
  18788. * The target of the runtime animation
  18789. */
  18790. private _target;
  18791. /**
  18792. * The initiating animatable
  18793. */
  18794. private _host;
  18795. /**
  18796. * The original value of the runtime animation
  18797. */
  18798. private _originalValue;
  18799. /**
  18800. * The original blend value of the runtime animation
  18801. */
  18802. private _originalBlendValue;
  18803. /**
  18804. * The offsets cache of the runtime animation
  18805. */
  18806. private _offsetsCache;
  18807. /**
  18808. * The high limits cache of the runtime animation
  18809. */
  18810. private _highLimitsCache;
  18811. /**
  18812. * Specifies if the runtime animation has been stopped
  18813. */
  18814. private _stopped;
  18815. /**
  18816. * The blending factor of the runtime animation
  18817. */
  18818. private _blendingFactor;
  18819. /**
  18820. * The BabylonJS scene
  18821. */
  18822. private _scene;
  18823. /**
  18824. * The current value of the runtime animation
  18825. */
  18826. private _currentValue;
  18827. /** @hidden */
  18828. _workValue: any;
  18829. /**
  18830. * The active target of the runtime animation
  18831. */
  18832. private _activeTarget;
  18833. /**
  18834. * The target path of the runtime animation
  18835. */
  18836. private _targetPath;
  18837. /**
  18838. * The weight of the runtime animation
  18839. */
  18840. private _weight;
  18841. /**
  18842. * The ratio offset of the runtime animation
  18843. */
  18844. private _ratioOffset;
  18845. /**
  18846. * The previous delay of the runtime animation
  18847. */
  18848. private _previousDelay;
  18849. /**
  18850. * The previous ratio of the runtime animation
  18851. */
  18852. private _previousRatio;
  18853. /**
  18854. * Gets the current frame of the runtime animation
  18855. */
  18856. readonly currentFrame: number;
  18857. /**
  18858. * Gets the weight of the runtime animation
  18859. */
  18860. readonly weight: number;
  18861. /**
  18862. * Gets the current value of the runtime animation
  18863. */
  18864. readonly currentValue: any;
  18865. /**
  18866. * Gets the target path of the runtime animation
  18867. */
  18868. readonly targetPath: string;
  18869. /**
  18870. * Gets the actual target of the runtime animation
  18871. */
  18872. readonly target: any;
  18873. /**
  18874. * Create a new RuntimeAnimation object
  18875. * @param target defines the target of the animation
  18876. * @param animation defines the source animation object
  18877. * @param scene defines the hosting scene
  18878. * @param host defines the initiating Animatable
  18879. */
  18880. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18881. /**
  18882. * Gets the animation from the runtime animation
  18883. */
  18884. readonly animation: Animation;
  18885. /**
  18886. * Resets the runtime animation to the beginning
  18887. * @param restoreOriginal defines whether to restore the target property to the original value
  18888. */
  18889. reset(restoreOriginal?: boolean): void;
  18890. /**
  18891. * Specifies if the runtime animation is stopped
  18892. * @returns Boolean specifying if the runtime animation is stopped
  18893. */
  18894. isStopped(): boolean;
  18895. /**
  18896. * Disposes of the runtime animation
  18897. */
  18898. dispose(): void;
  18899. /**
  18900. * Interpolates the animation from the current frame
  18901. * @param currentFrame The frame to interpolate the animation to
  18902. * @param repeatCount The number of times that the animation should loop
  18903. * @param loopMode The type of looping mode to use
  18904. * @param offsetValue Animation offset value
  18905. * @param highLimitValue The high limit value
  18906. * @returns The interpolated value
  18907. */
  18908. private _interpolate;
  18909. /**
  18910. * Apply the interpolated value to the target
  18911. * @param currentValue defines the value computed by the animation
  18912. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18913. */
  18914. setValue(currentValue: any, weight?: number): void;
  18915. private _setValue;
  18916. /**
  18917. * Gets the loop pmode of the runtime animation
  18918. * @returns Loop Mode
  18919. */
  18920. private _getCorrectLoopMode;
  18921. /**
  18922. * Move the current animation to a given frame
  18923. * @param frame defines the frame to move to
  18924. */
  18925. goToFrame(frame: number): void;
  18926. /**
  18927. * @hidden Internal use only
  18928. */
  18929. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18930. /**
  18931. * Execute the current animation
  18932. * @param delay defines the delay to add to the current frame
  18933. * @param from defines the lower bound of the animation range
  18934. * @param to defines the upper bound of the animation range
  18935. * @param loop defines if the current animation must loop
  18936. * @param speedRatio defines the current speed ratio
  18937. * @param weight defines the weight of the animation (default is -1 so no weight)
  18938. * @param onLoop optional callback called when animation loops
  18939. * @returns a boolean indicating if the animation is running
  18940. */
  18941. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18942. }
  18943. }
  18944. declare module "babylonjs/Animations/animatable" {
  18945. import { Animation } from "babylonjs/Animations/animation";
  18946. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18947. import { Nullable } from "babylonjs/types";
  18948. import { Observable } from "babylonjs/Misc/observable";
  18949. import { Scene } from "babylonjs/scene";
  18950. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18951. import { Node } from "babylonjs/node";
  18952. /**
  18953. * Class used to store an actual running animation
  18954. */
  18955. export class Animatable {
  18956. /** defines the target object */
  18957. target: any;
  18958. /** defines the starting frame number (default is 0) */
  18959. fromFrame: number;
  18960. /** defines the ending frame number (default is 100) */
  18961. toFrame: number;
  18962. /** defines if the animation must loop (default is false) */
  18963. loopAnimation: boolean;
  18964. /** defines a callback to call when animation ends if it is not looping */
  18965. onAnimationEnd?: (() => void) | null | undefined;
  18966. /** defines a callback to call when animation loops */
  18967. onAnimationLoop?: (() => void) | null | undefined;
  18968. private _localDelayOffset;
  18969. private _pausedDelay;
  18970. private _runtimeAnimations;
  18971. private _paused;
  18972. private _scene;
  18973. private _speedRatio;
  18974. private _weight;
  18975. private _syncRoot;
  18976. /**
  18977. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18978. * This will only apply for non looping animation (default is true)
  18979. */
  18980. disposeOnEnd: boolean;
  18981. /**
  18982. * Gets a boolean indicating if the animation has started
  18983. */
  18984. animationStarted: boolean;
  18985. /**
  18986. * Observer raised when the animation ends
  18987. */
  18988. onAnimationEndObservable: Observable<Animatable>;
  18989. /**
  18990. * Observer raised when the animation loops
  18991. */
  18992. onAnimationLoopObservable: Observable<Animatable>;
  18993. /**
  18994. * Gets the root Animatable used to synchronize and normalize animations
  18995. */
  18996. readonly syncRoot: Animatable;
  18997. /**
  18998. * Gets the current frame of the first RuntimeAnimation
  18999. * Used to synchronize Animatables
  19000. */
  19001. readonly masterFrame: number;
  19002. /**
  19003. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19004. */
  19005. weight: number;
  19006. /**
  19007. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19008. */
  19009. speedRatio: number;
  19010. /**
  19011. * Creates a new Animatable
  19012. * @param scene defines the hosting scene
  19013. * @param target defines the target object
  19014. * @param fromFrame defines the starting frame number (default is 0)
  19015. * @param toFrame defines the ending frame number (default is 100)
  19016. * @param loopAnimation defines if the animation must loop (default is false)
  19017. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19018. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19019. * @param animations defines a group of animation to add to the new Animatable
  19020. * @param onAnimationLoop defines a callback to call when animation loops
  19021. */
  19022. constructor(scene: Scene,
  19023. /** defines the target object */
  19024. target: any,
  19025. /** defines the starting frame number (default is 0) */
  19026. fromFrame?: number,
  19027. /** defines the ending frame number (default is 100) */
  19028. toFrame?: number,
  19029. /** defines if the animation must loop (default is false) */
  19030. loopAnimation?: boolean, speedRatio?: number,
  19031. /** defines a callback to call when animation ends if it is not looping */
  19032. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19033. /** defines a callback to call when animation loops */
  19034. onAnimationLoop?: (() => void) | null | undefined);
  19035. /**
  19036. * Synchronize and normalize current Animatable with a source Animatable
  19037. * This is useful when using animation weights and when animations are not of the same length
  19038. * @param root defines the root Animatable to synchronize with
  19039. * @returns the current Animatable
  19040. */
  19041. syncWith(root: Animatable): Animatable;
  19042. /**
  19043. * Gets the list of runtime animations
  19044. * @returns an array of RuntimeAnimation
  19045. */
  19046. getAnimations(): RuntimeAnimation[];
  19047. /**
  19048. * Adds more animations to the current animatable
  19049. * @param target defines the target of the animations
  19050. * @param animations defines the new animations to add
  19051. */
  19052. appendAnimations(target: any, animations: Animation[]): void;
  19053. /**
  19054. * Gets the source animation for a specific property
  19055. * @param property defines the propertyu to look for
  19056. * @returns null or the source animation for the given property
  19057. */
  19058. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19059. /**
  19060. * Gets the runtime animation for a specific property
  19061. * @param property defines the propertyu to look for
  19062. * @returns null or the runtime animation for the given property
  19063. */
  19064. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19065. /**
  19066. * Resets the animatable to its original state
  19067. */
  19068. reset(): void;
  19069. /**
  19070. * Allows the animatable to blend with current running animations
  19071. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19072. * @param blendingSpeed defines the blending speed to use
  19073. */
  19074. enableBlending(blendingSpeed: number): void;
  19075. /**
  19076. * Disable animation blending
  19077. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19078. */
  19079. disableBlending(): void;
  19080. /**
  19081. * Jump directly to a given frame
  19082. * @param frame defines the frame to jump to
  19083. */
  19084. goToFrame(frame: number): void;
  19085. /**
  19086. * Pause the animation
  19087. */
  19088. pause(): void;
  19089. /**
  19090. * Restart the animation
  19091. */
  19092. restart(): void;
  19093. private _raiseOnAnimationEnd;
  19094. /**
  19095. * Stop and delete the current animation
  19096. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19097. * @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)
  19098. */
  19099. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19100. /**
  19101. * Wait asynchronously for the animation to end
  19102. * @returns a promise which will be fullfilled when the animation ends
  19103. */
  19104. waitAsync(): Promise<Animatable>;
  19105. /** @hidden */
  19106. _animate(delay: number): boolean;
  19107. }
  19108. module "babylonjs/scene" {
  19109. interface Scene {
  19110. /** @hidden */
  19111. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19112. /** @hidden */
  19113. _processLateAnimationBindingsForMatrices(holder: {
  19114. totalWeight: number;
  19115. animations: RuntimeAnimation[];
  19116. originalValue: Matrix;
  19117. }): any;
  19118. /** @hidden */
  19119. _processLateAnimationBindingsForQuaternions(holder: {
  19120. totalWeight: number;
  19121. animations: RuntimeAnimation[];
  19122. originalValue: Quaternion;
  19123. }, refQuaternion: Quaternion): Quaternion;
  19124. /** @hidden */
  19125. _processLateAnimationBindings(): void;
  19126. /**
  19127. * Will start the animation sequence of a given target
  19128. * @param target defines the target
  19129. * @param from defines from which frame should animation start
  19130. * @param to defines until which frame should animation run.
  19131. * @param weight defines the weight to apply to the animation (1.0 by default)
  19132. * @param loop defines if the animation loops
  19133. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19134. * @param onAnimationEnd defines the function to be executed when the animation ends
  19135. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19136. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19137. * @param onAnimationLoop defines the callback to call when an animation loops
  19138. * @returns the animatable object created for this animation
  19139. */
  19140. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19141. /**
  19142. * Will start the animation sequence of a given target
  19143. * @param target defines the target
  19144. * @param from defines from which frame should animation start
  19145. * @param to defines until which frame should animation run.
  19146. * @param loop defines if the animation loops
  19147. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19148. * @param onAnimationEnd defines the function to be executed when the animation ends
  19149. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19150. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19151. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19152. * @param onAnimationLoop defines the callback to call when an animation loops
  19153. * @returns the animatable object created for this animation
  19154. */
  19155. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19156. /**
  19157. * Will start the animation sequence of a given target and its hierarchy
  19158. * @param target defines the target
  19159. * @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.
  19160. * @param from defines from which frame should animation start
  19161. * @param to defines until which frame should animation run.
  19162. * @param loop defines if the animation loops
  19163. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19164. * @param onAnimationEnd defines the function to be executed when the animation ends
  19165. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19166. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19167. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19168. * @param onAnimationLoop defines the callback to call when an animation loops
  19169. * @returns the list of created animatables
  19170. */
  19171. 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[];
  19172. /**
  19173. * Begin a new animation on a given node
  19174. * @param target defines the target where the animation will take place
  19175. * @param animations defines the list of animations to start
  19176. * @param from defines the initial value
  19177. * @param to defines the final value
  19178. * @param loop defines if you want animation to loop (off by default)
  19179. * @param speedRatio defines the speed ratio to apply to all animations
  19180. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19181. * @param onAnimationLoop defines the callback to call when an animation loops
  19182. * @returns the list of created animatables
  19183. */
  19184. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19185. /**
  19186. * Begin a new animation on a given node and its hierarchy
  19187. * @param target defines the root node where the animation will take place
  19188. * @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.
  19189. * @param animations defines the list of animations to start
  19190. * @param from defines the initial value
  19191. * @param to defines the final value
  19192. * @param loop defines if you want animation to loop (off by default)
  19193. * @param speedRatio defines the speed ratio to apply to all animations
  19194. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19195. * @param onAnimationLoop defines the callback to call when an animation loops
  19196. * @returns the list of animatables created for all nodes
  19197. */
  19198. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19199. /**
  19200. * Gets the animatable associated with a specific target
  19201. * @param target defines the target of the animatable
  19202. * @returns the required animatable if found
  19203. */
  19204. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19205. /**
  19206. * Gets all animatables associated with a given target
  19207. * @param target defines the target to look animatables for
  19208. * @returns an array of Animatables
  19209. */
  19210. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19211. /**
  19212. * Will stop the animation of the given target
  19213. * @param target - the target
  19214. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19215. * @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)
  19216. */
  19217. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19218. /**
  19219. * Stops and removes all animations that have been applied to the scene
  19220. */
  19221. stopAllAnimations(): void;
  19222. }
  19223. }
  19224. module "babylonjs/Bones/bone" {
  19225. interface Bone {
  19226. /**
  19227. * Copy an animation range from another bone
  19228. * @param source defines the source bone
  19229. * @param rangeName defines the range name to copy
  19230. * @param frameOffset defines the frame offset
  19231. * @param rescaleAsRequired defines if rescaling must be applied if required
  19232. * @param skelDimensionsRatio defines the scaling ratio
  19233. * @returns true if operation was successful
  19234. */
  19235. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19236. }
  19237. }
  19238. }
  19239. declare module "babylonjs/Bones/skeleton" {
  19240. import { Bone } from "babylonjs/Bones/bone";
  19241. import { IAnimatable } from "babylonjs/Misc/tools";
  19242. import { Observable } from "babylonjs/Misc/observable";
  19243. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19244. import { Scene } from "babylonjs/scene";
  19245. import { Nullable } from "babylonjs/types";
  19246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19247. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19248. import { Animatable } from "babylonjs/Animations/animatable";
  19249. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19250. import { Animation } from "babylonjs/Animations/animation";
  19251. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19252. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19253. /**
  19254. * Class used to handle skinning animations
  19255. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19256. */
  19257. export class Skeleton implements IAnimatable {
  19258. /** defines the skeleton name */
  19259. name: string;
  19260. /** defines the skeleton Id */
  19261. id: string;
  19262. /**
  19263. * Defines the list of child bones
  19264. */
  19265. bones: Bone[];
  19266. /**
  19267. * Defines an estimate of the dimension of the skeleton at rest
  19268. */
  19269. dimensionsAtRest: Vector3;
  19270. /**
  19271. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19272. */
  19273. needInitialSkinMatrix: boolean;
  19274. /**
  19275. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19276. */
  19277. overrideMesh: Nullable<AbstractMesh>;
  19278. /**
  19279. * Gets the list of animations attached to this skeleton
  19280. */
  19281. animations: Array<Animation>;
  19282. private _scene;
  19283. private _isDirty;
  19284. private _transformMatrices;
  19285. private _transformMatrixTexture;
  19286. private _meshesWithPoseMatrix;
  19287. private _animatables;
  19288. private _identity;
  19289. private _synchronizedWithMesh;
  19290. private _ranges;
  19291. private _lastAbsoluteTransformsUpdateId;
  19292. private _canUseTextureForBones;
  19293. private _uniqueId;
  19294. /** @hidden */
  19295. _numBonesWithLinkedTransformNode: number;
  19296. /**
  19297. * Specifies if the skeleton should be serialized
  19298. */
  19299. doNotSerialize: boolean;
  19300. private _useTextureToStoreBoneMatrices;
  19301. /**
  19302. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19303. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19304. */
  19305. useTextureToStoreBoneMatrices: boolean;
  19306. private _animationPropertiesOverride;
  19307. /**
  19308. * Gets or sets the animation properties override
  19309. */
  19310. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19311. /**
  19312. * List of inspectable custom properties (used by the Inspector)
  19313. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19314. */
  19315. inspectableCustomProperties: IInspectable[];
  19316. /**
  19317. * An observable triggered before computing the skeleton's matrices
  19318. */
  19319. onBeforeComputeObservable: Observable<Skeleton>;
  19320. /**
  19321. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19322. */
  19323. readonly isUsingTextureForMatrices: boolean;
  19324. /**
  19325. * Gets the unique ID of this skeleton
  19326. */
  19327. readonly uniqueId: number;
  19328. /**
  19329. * Creates a new skeleton
  19330. * @param name defines the skeleton name
  19331. * @param id defines the skeleton Id
  19332. * @param scene defines the hosting scene
  19333. */
  19334. constructor(
  19335. /** defines the skeleton name */
  19336. name: string,
  19337. /** defines the skeleton Id */
  19338. id: string, scene: Scene);
  19339. /**
  19340. * Gets the current object class name.
  19341. * @return the class name
  19342. */
  19343. getClassName(): string;
  19344. /**
  19345. * Returns an array containing the root bones
  19346. * @returns an array containing the root bones
  19347. */
  19348. getChildren(): Array<Bone>;
  19349. /**
  19350. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19351. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19352. * @returns a Float32Array containing matrices data
  19353. */
  19354. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19355. /**
  19356. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19357. * @returns a raw texture containing the data
  19358. */
  19359. getTransformMatrixTexture(): Nullable<RawTexture>;
  19360. /**
  19361. * Gets the current hosting scene
  19362. * @returns a scene object
  19363. */
  19364. getScene(): Scene;
  19365. /**
  19366. * Gets a string representing the current skeleton data
  19367. * @param fullDetails defines a boolean indicating if we want a verbose version
  19368. * @returns a string representing the current skeleton data
  19369. */
  19370. toString(fullDetails?: boolean): string;
  19371. /**
  19372. * Get bone's index searching by name
  19373. * @param name defines bone's name to search for
  19374. * @return the indice of the bone. Returns -1 if not found
  19375. */
  19376. getBoneIndexByName(name: string): number;
  19377. /**
  19378. * Creater a new animation range
  19379. * @param name defines the name of the range
  19380. * @param from defines the start key
  19381. * @param to defines the end key
  19382. */
  19383. createAnimationRange(name: string, from: number, to: number): void;
  19384. /**
  19385. * Delete a specific animation range
  19386. * @param name defines the name of the range
  19387. * @param deleteFrames defines if frames must be removed as well
  19388. */
  19389. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19390. /**
  19391. * Gets a specific animation range
  19392. * @param name defines the name of the range to look for
  19393. * @returns the requested animation range or null if not found
  19394. */
  19395. getAnimationRange(name: string): Nullable<AnimationRange>;
  19396. /**
  19397. * Gets the list of all animation ranges defined on this skeleton
  19398. * @returns an array
  19399. */
  19400. getAnimationRanges(): Nullable<AnimationRange>[];
  19401. /**
  19402. * Copy animation range from a source skeleton.
  19403. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19404. * @param source defines the source skeleton
  19405. * @param name defines the name of the range to copy
  19406. * @param rescaleAsRequired defines if rescaling must be applied if required
  19407. * @returns true if operation was successful
  19408. */
  19409. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19410. /**
  19411. * Forces the skeleton to go to rest pose
  19412. */
  19413. returnToRest(): void;
  19414. private _getHighestAnimationFrame;
  19415. /**
  19416. * Begin a specific animation range
  19417. * @param name defines the name of the range to start
  19418. * @param loop defines if looping must be turned on (false by default)
  19419. * @param speedRatio defines the speed ratio to apply (1 by default)
  19420. * @param onAnimationEnd defines a callback which will be called when animation will end
  19421. * @returns a new animatable
  19422. */
  19423. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19424. /** @hidden */
  19425. _markAsDirty(): void;
  19426. /** @hidden */
  19427. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19428. /** @hidden */
  19429. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19430. private _computeTransformMatrices;
  19431. /**
  19432. * Build all resources required to render a skeleton
  19433. */
  19434. prepare(): void;
  19435. /**
  19436. * Gets the list of animatables currently running for this skeleton
  19437. * @returns an array of animatables
  19438. */
  19439. getAnimatables(): IAnimatable[];
  19440. /**
  19441. * Clone the current skeleton
  19442. * @param name defines the name of the new skeleton
  19443. * @param id defines the id of the enw skeleton
  19444. * @returns the new skeleton
  19445. */
  19446. clone(name: string, id: string): Skeleton;
  19447. /**
  19448. * Enable animation blending for this skeleton
  19449. * @param blendingSpeed defines the blending speed to apply
  19450. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19451. */
  19452. enableBlending(blendingSpeed?: number): void;
  19453. /**
  19454. * Releases all resources associated with the current skeleton
  19455. */
  19456. dispose(): void;
  19457. /**
  19458. * Serialize the skeleton in a JSON object
  19459. * @returns a JSON object
  19460. */
  19461. serialize(): any;
  19462. /**
  19463. * Creates a new skeleton from serialized data
  19464. * @param parsedSkeleton defines the serialized data
  19465. * @param scene defines the hosting scene
  19466. * @returns a new skeleton
  19467. */
  19468. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19469. /**
  19470. * Compute all node absolute transforms
  19471. * @param forceUpdate defines if computation must be done even if cache is up to date
  19472. */
  19473. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19474. /**
  19475. * Gets the root pose matrix
  19476. * @returns a matrix
  19477. */
  19478. getPoseMatrix(): Nullable<Matrix>;
  19479. /**
  19480. * Sorts bones per internal index
  19481. */
  19482. sortBones(): void;
  19483. private _sortBones;
  19484. }
  19485. }
  19486. declare module "babylonjs/Morph/morphTarget" {
  19487. import { IAnimatable } from "babylonjs/Misc/tools";
  19488. import { Observable } from "babylonjs/Misc/observable";
  19489. import { Nullable, FloatArray } from "babylonjs/types";
  19490. import { Scene } from "babylonjs/scene";
  19491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19492. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19493. /**
  19494. * Defines a target to use with MorphTargetManager
  19495. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19496. */
  19497. export class MorphTarget implements IAnimatable {
  19498. /** defines the name of the target */
  19499. name: string;
  19500. /**
  19501. * Gets or sets the list of animations
  19502. */
  19503. animations: import("babylonjs/Animations/animation").Animation[];
  19504. private _scene;
  19505. private _positions;
  19506. private _normals;
  19507. private _tangents;
  19508. private _influence;
  19509. /**
  19510. * Observable raised when the influence changes
  19511. */
  19512. onInfluenceChanged: Observable<boolean>;
  19513. /** @hidden */
  19514. _onDataLayoutChanged: Observable<void>;
  19515. /**
  19516. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19517. */
  19518. influence: number;
  19519. /**
  19520. * Gets or sets the id of the morph Target
  19521. */
  19522. id: string;
  19523. private _animationPropertiesOverride;
  19524. /**
  19525. * Gets or sets the animation properties override
  19526. */
  19527. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19528. /**
  19529. * Creates a new MorphTarget
  19530. * @param name defines the name of the target
  19531. * @param influence defines the influence to use
  19532. * @param scene defines the scene the morphtarget belongs to
  19533. */
  19534. constructor(
  19535. /** defines the name of the target */
  19536. name: string, influence?: number, scene?: Nullable<Scene>);
  19537. /**
  19538. * Gets a boolean defining if the target contains position data
  19539. */
  19540. readonly hasPositions: boolean;
  19541. /**
  19542. * Gets a boolean defining if the target contains normal data
  19543. */
  19544. readonly hasNormals: boolean;
  19545. /**
  19546. * Gets a boolean defining if the target contains tangent data
  19547. */
  19548. readonly hasTangents: boolean;
  19549. /**
  19550. * Affects position data to this target
  19551. * @param data defines the position data to use
  19552. */
  19553. setPositions(data: Nullable<FloatArray>): void;
  19554. /**
  19555. * Gets the position data stored in this target
  19556. * @returns a FloatArray containing the position data (or null if not present)
  19557. */
  19558. getPositions(): Nullable<FloatArray>;
  19559. /**
  19560. * Affects normal data to this target
  19561. * @param data defines the normal data to use
  19562. */
  19563. setNormals(data: Nullable<FloatArray>): void;
  19564. /**
  19565. * Gets the normal data stored in this target
  19566. * @returns a FloatArray containing the normal data (or null if not present)
  19567. */
  19568. getNormals(): Nullable<FloatArray>;
  19569. /**
  19570. * Affects tangent data to this target
  19571. * @param data defines the tangent data to use
  19572. */
  19573. setTangents(data: Nullable<FloatArray>): void;
  19574. /**
  19575. * Gets the tangent data stored in this target
  19576. * @returns a FloatArray containing the tangent data (or null if not present)
  19577. */
  19578. getTangents(): Nullable<FloatArray>;
  19579. /**
  19580. * Serializes the current target into a Serialization object
  19581. * @returns the serialized object
  19582. */
  19583. serialize(): any;
  19584. /**
  19585. * Returns the string "MorphTarget"
  19586. * @returns "MorphTarget"
  19587. */
  19588. getClassName(): string;
  19589. /**
  19590. * Creates a new target from serialized data
  19591. * @param serializationObject defines the serialized data to use
  19592. * @returns a new MorphTarget
  19593. */
  19594. static Parse(serializationObject: any): MorphTarget;
  19595. /**
  19596. * Creates a MorphTarget from mesh data
  19597. * @param mesh defines the source mesh
  19598. * @param name defines the name to use for the new target
  19599. * @param influence defines the influence to attach to the target
  19600. * @returns a new MorphTarget
  19601. */
  19602. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19603. }
  19604. }
  19605. declare module "babylonjs/Morph/morphTargetManager" {
  19606. import { Nullable } from "babylonjs/types";
  19607. import { Scene } from "babylonjs/scene";
  19608. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19609. /**
  19610. * This class is used to deform meshes using morphing between different targets
  19611. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19612. */
  19613. export class MorphTargetManager {
  19614. private _targets;
  19615. private _targetInfluenceChangedObservers;
  19616. private _targetDataLayoutChangedObservers;
  19617. private _activeTargets;
  19618. private _scene;
  19619. private _influences;
  19620. private _supportsNormals;
  19621. private _supportsTangents;
  19622. private _vertexCount;
  19623. private _uniqueId;
  19624. private _tempInfluences;
  19625. /**
  19626. * Creates a new MorphTargetManager
  19627. * @param scene defines the current scene
  19628. */
  19629. constructor(scene?: Nullable<Scene>);
  19630. /**
  19631. * Gets the unique ID of this manager
  19632. */
  19633. readonly uniqueId: number;
  19634. /**
  19635. * Gets the number of vertices handled by this manager
  19636. */
  19637. readonly vertexCount: number;
  19638. /**
  19639. * Gets a boolean indicating if this manager supports morphing of normals
  19640. */
  19641. readonly supportsNormals: boolean;
  19642. /**
  19643. * Gets a boolean indicating if this manager supports morphing of tangents
  19644. */
  19645. readonly supportsTangents: boolean;
  19646. /**
  19647. * Gets the number of targets stored in this manager
  19648. */
  19649. readonly numTargets: number;
  19650. /**
  19651. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19652. */
  19653. readonly numInfluencers: number;
  19654. /**
  19655. * Gets the list of influences (one per target)
  19656. */
  19657. readonly influences: Float32Array;
  19658. /**
  19659. * Gets the active target at specified index. An active target is a target with an influence > 0
  19660. * @param index defines the index to check
  19661. * @returns the requested target
  19662. */
  19663. getActiveTarget(index: number): MorphTarget;
  19664. /**
  19665. * Gets the target at specified index
  19666. * @param index defines the index to check
  19667. * @returns the requested target
  19668. */
  19669. getTarget(index: number): MorphTarget;
  19670. /**
  19671. * Add a new target to this manager
  19672. * @param target defines the target to add
  19673. */
  19674. addTarget(target: MorphTarget): void;
  19675. /**
  19676. * Removes a target from the manager
  19677. * @param target defines the target to remove
  19678. */
  19679. removeTarget(target: MorphTarget): void;
  19680. /**
  19681. * Serializes the current manager into a Serialization object
  19682. * @returns the serialized object
  19683. */
  19684. serialize(): any;
  19685. private _syncActiveTargets;
  19686. /**
  19687. * Syncrhonize the targets with all the meshes using this morph target manager
  19688. */
  19689. synchronize(): void;
  19690. /**
  19691. * Creates a new MorphTargetManager from serialized data
  19692. * @param serializationObject defines the serialized data
  19693. * @param scene defines the hosting scene
  19694. * @returns the new MorphTargetManager
  19695. */
  19696. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19697. }
  19698. }
  19699. declare module "babylonjs/Meshes/groundMesh" {
  19700. import { Scene } from "babylonjs/scene";
  19701. import { Vector3 } from "babylonjs/Maths/math";
  19702. import { Mesh } from "babylonjs/Meshes/mesh";
  19703. /**
  19704. * Mesh representing the gorund
  19705. */
  19706. export class GroundMesh extends Mesh {
  19707. /** If octree should be generated */
  19708. generateOctree: boolean;
  19709. private _heightQuads;
  19710. /** @hidden */
  19711. _subdivisionsX: number;
  19712. /** @hidden */
  19713. _subdivisionsY: number;
  19714. /** @hidden */
  19715. _width: number;
  19716. /** @hidden */
  19717. _height: number;
  19718. /** @hidden */
  19719. _minX: number;
  19720. /** @hidden */
  19721. _maxX: number;
  19722. /** @hidden */
  19723. _minZ: number;
  19724. /** @hidden */
  19725. _maxZ: number;
  19726. constructor(name: string, scene: Scene);
  19727. /**
  19728. * "GroundMesh"
  19729. * @returns "GroundMesh"
  19730. */
  19731. getClassName(): string;
  19732. /**
  19733. * The minimum of x and y subdivisions
  19734. */
  19735. readonly subdivisions: number;
  19736. /**
  19737. * X subdivisions
  19738. */
  19739. readonly subdivisionsX: number;
  19740. /**
  19741. * Y subdivisions
  19742. */
  19743. readonly subdivisionsY: number;
  19744. /**
  19745. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19746. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19747. * @param chunksCount the number of subdivisions for x and y
  19748. * @param octreeBlocksSize (Default: 32)
  19749. */
  19750. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19751. /**
  19752. * Returns a height (y) value in the Worl system :
  19753. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19754. * @param x x coordinate
  19755. * @param z z coordinate
  19756. * @returns the ground y position if (x, z) are outside the ground surface.
  19757. */
  19758. getHeightAtCoordinates(x: number, z: number): number;
  19759. /**
  19760. * Returns a normalized vector (Vector3) orthogonal to the ground
  19761. * at the ground coordinates (x, z) expressed in the World system.
  19762. * @param x x coordinate
  19763. * @param z z coordinate
  19764. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19765. */
  19766. getNormalAtCoordinates(x: number, z: number): Vector3;
  19767. /**
  19768. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19769. * at the ground coordinates (x, z) expressed in the World system.
  19770. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19771. * @param x x coordinate
  19772. * @param z z coordinate
  19773. * @param ref vector to store the result
  19774. * @returns the GroundMesh.
  19775. */
  19776. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19777. /**
  19778. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19779. * if the ground has been updated.
  19780. * This can be used in the render loop.
  19781. * @returns the GroundMesh.
  19782. */
  19783. updateCoordinateHeights(): GroundMesh;
  19784. private _getFacetAt;
  19785. private _initHeightQuads;
  19786. private _computeHeightQuads;
  19787. /**
  19788. * Serializes this ground mesh
  19789. * @param serializationObject object to write serialization to
  19790. */
  19791. serialize(serializationObject: any): void;
  19792. /**
  19793. * Parses a serialized ground mesh
  19794. * @param parsedMesh the serialized mesh
  19795. * @param scene the scene to create the ground mesh in
  19796. * @returns the created ground mesh
  19797. */
  19798. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19799. }
  19800. }
  19801. declare module "babylonjs/Physics/physicsJoint" {
  19802. import { Vector3 } from "babylonjs/Maths/math";
  19803. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19804. /**
  19805. * Interface for Physics-Joint data
  19806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19807. */
  19808. export interface PhysicsJointData {
  19809. /**
  19810. * The main pivot of the joint
  19811. */
  19812. mainPivot?: Vector3;
  19813. /**
  19814. * The connected pivot of the joint
  19815. */
  19816. connectedPivot?: Vector3;
  19817. /**
  19818. * The main axis of the joint
  19819. */
  19820. mainAxis?: Vector3;
  19821. /**
  19822. * The connected axis of the joint
  19823. */
  19824. connectedAxis?: Vector3;
  19825. /**
  19826. * The collision of the joint
  19827. */
  19828. collision?: boolean;
  19829. /**
  19830. * Native Oimo/Cannon/Energy data
  19831. */
  19832. nativeParams?: any;
  19833. }
  19834. /**
  19835. * This is a holder class for the physics joint created by the physics plugin
  19836. * It holds a set of functions to control the underlying joint
  19837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19838. */
  19839. export class PhysicsJoint {
  19840. /**
  19841. * The type of the physics joint
  19842. */
  19843. type: number;
  19844. /**
  19845. * The data for the physics joint
  19846. */
  19847. jointData: PhysicsJointData;
  19848. private _physicsJoint;
  19849. protected _physicsPlugin: IPhysicsEnginePlugin;
  19850. /**
  19851. * Initializes the physics joint
  19852. * @param type The type of the physics joint
  19853. * @param jointData The data for the physics joint
  19854. */
  19855. constructor(
  19856. /**
  19857. * The type of the physics joint
  19858. */
  19859. type: number,
  19860. /**
  19861. * The data for the physics joint
  19862. */
  19863. jointData: PhysicsJointData);
  19864. /**
  19865. * Gets the physics joint
  19866. */
  19867. /**
  19868. * Sets the physics joint
  19869. */
  19870. physicsJoint: any;
  19871. /**
  19872. * Sets the physics plugin
  19873. */
  19874. physicsPlugin: IPhysicsEnginePlugin;
  19875. /**
  19876. * Execute a function that is physics-plugin specific.
  19877. * @param {Function} func the function that will be executed.
  19878. * It accepts two parameters: the physics world and the physics joint
  19879. */
  19880. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19881. /**
  19882. * Distance-Joint type
  19883. */
  19884. static DistanceJoint: number;
  19885. /**
  19886. * Hinge-Joint type
  19887. */
  19888. static HingeJoint: number;
  19889. /**
  19890. * Ball-and-Socket joint type
  19891. */
  19892. static BallAndSocketJoint: number;
  19893. /**
  19894. * Wheel-Joint type
  19895. */
  19896. static WheelJoint: number;
  19897. /**
  19898. * Slider-Joint type
  19899. */
  19900. static SliderJoint: number;
  19901. /**
  19902. * Prismatic-Joint type
  19903. */
  19904. static PrismaticJoint: number;
  19905. /**
  19906. * Universal-Joint type
  19907. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19908. */
  19909. static UniversalJoint: number;
  19910. /**
  19911. * Hinge-Joint 2 type
  19912. */
  19913. static Hinge2Joint: number;
  19914. /**
  19915. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19916. */
  19917. static PointToPointJoint: number;
  19918. /**
  19919. * Spring-Joint type
  19920. */
  19921. static SpringJoint: number;
  19922. /**
  19923. * Lock-Joint type
  19924. */
  19925. static LockJoint: number;
  19926. }
  19927. /**
  19928. * A class representing a physics distance joint
  19929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19930. */
  19931. export class DistanceJoint extends PhysicsJoint {
  19932. /**
  19933. *
  19934. * @param jointData The data for the Distance-Joint
  19935. */
  19936. constructor(jointData: DistanceJointData);
  19937. /**
  19938. * Update the predefined distance.
  19939. * @param maxDistance The maximum preferred distance
  19940. * @param minDistance The minimum preferred distance
  19941. */
  19942. updateDistance(maxDistance: number, minDistance?: number): void;
  19943. }
  19944. /**
  19945. * Represents a Motor-Enabled Joint
  19946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19947. */
  19948. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19949. /**
  19950. * Initializes the Motor-Enabled Joint
  19951. * @param type The type of the joint
  19952. * @param jointData The physica joint data for the joint
  19953. */
  19954. constructor(type: number, jointData: PhysicsJointData);
  19955. /**
  19956. * Set the motor values.
  19957. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19958. * @param force the force to apply
  19959. * @param maxForce max force for this motor.
  19960. */
  19961. setMotor(force?: number, maxForce?: number): void;
  19962. /**
  19963. * Set the motor's limits.
  19964. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19965. * @param upperLimit The upper limit of the motor
  19966. * @param lowerLimit The lower limit of the motor
  19967. */
  19968. setLimit(upperLimit: number, lowerLimit?: number): void;
  19969. }
  19970. /**
  19971. * This class represents a single physics Hinge-Joint
  19972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19973. */
  19974. export class HingeJoint extends MotorEnabledJoint {
  19975. /**
  19976. * Initializes the Hinge-Joint
  19977. * @param jointData The joint data for the Hinge-Joint
  19978. */
  19979. constructor(jointData: PhysicsJointData);
  19980. /**
  19981. * Set the motor values.
  19982. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19983. * @param {number} force the force to apply
  19984. * @param {number} maxForce max force for this motor.
  19985. */
  19986. setMotor(force?: number, maxForce?: number): void;
  19987. /**
  19988. * Set the motor's limits.
  19989. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19990. * @param upperLimit The upper limit of the motor
  19991. * @param lowerLimit The lower limit of the motor
  19992. */
  19993. setLimit(upperLimit: number, lowerLimit?: number): void;
  19994. }
  19995. /**
  19996. * This class represents a dual hinge physics joint (same as wheel joint)
  19997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19998. */
  19999. export class Hinge2Joint extends MotorEnabledJoint {
  20000. /**
  20001. * Initializes the Hinge2-Joint
  20002. * @param jointData The joint data for the Hinge2-Joint
  20003. */
  20004. constructor(jointData: PhysicsJointData);
  20005. /**
  20006. * Set the motor values.
  20007. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20008. * @param {number} targetSpeed the speed the motor is to reach
  20009. * @param {number} maxForce max force for this motor.
  20010. * @param {motorIndex} the motor's index, 0 or 1.
  20011. */
  20012. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20013. /**
  20014. * Set the motor limits.
  20015. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20016. * @param {number} upperLimit the upper limit
  20017. * @param {number} lowerLimit lower limit
  20018. * @param {motorIndex} the motor's index, 0 or 1.
  20019. */
  20020. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20021. }
  20022. /**
  20023. * Interface for a motor enabled joint
  20024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20025. */
  20026. export interface IMotorEnabledJoint {
  20027. /**
  20028. * Physics joint
  20029. */
  20030. physicsJoint: any;
  20031. /**
  20032. * Sets the motor of the motor-enabled joint
  20033. * @param force The force of the motor
  20034. * @param maxForce The maximum force of the motor
  20035. * @param motorIndex The index of the motor
  20036. */
  20037. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20038. /**
  20039. * Sets the limit of the motor
  20040. * @param upperLimit The upper limit of the motor
  20041. * @param lowerLimit The lower limit of the motor
  20042. * @param motorIndex The index of the motor
  20043. */
  20044. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20045. }
  20046. /**
  20047. * Joint data for a Distance-Joint
  20048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20049. */
  20050. export interface DistanceJointData extends PhysicsJointData {
  20051. /**
  20052. * Max distance the 2 joint objects can be apart
  20053. */
  20054. maxDistance: number;
  20055. }
  20056. /**
  20057. * Joint data from a spring joint
  20058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20059. */
  20060. export interface SpringJointData extends PhysicsJointData {
  20061. /**
  20062. * Length of the spring
  20063. */
  20064. length: number;
  20065. /**
  20066. * Stiffness of the spring
  20067. */
  20068. stiffness: number;
  20069. /**
  20070. * Damping of the spring
  20071. */
  20072. damping: number;
  20073. /** this callback will be called when applying the force to the impostors. */
  20074. forceApplicationCallback: () => void;
  20075. }
  20076. }
  20077. declare module "babylonjs/Physics/physicsRaycastResult" {
  20078. import { Vector3 } from "babylonjs/Maths/math";
  20079. /**
  20080. * Holds the data for the raycast result
  20081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20082. */
  20083. export class PhysicsRaycastResult {
  20084. private _hasHit;
  20085. private _hitDistance;
  20086. private _hitNormalWorld;
  20087. private _hitPointWorld;
  20088. private _rayFromWorld;
  20089. private _rayToWorld;
  20090. /**
  20091. * Gets if there was a hit
  20092. */
  20093. readonly hasHit: boolean;
  20094. /**
  20095. * Gets the distance from the hit
  20096. */
  20097. readonly hitDistance: number;
  20098. /**
  20099. * Gets the hit normal/direction in the world
  20100. */
  20101. readonly hitNormalWorld: Vector3;
  20102. /**
  20103. * Gets the hit point in the world
  20104. */
  20105. readonly hitPointWorld: Vector3;
  20106. /**
  20107. * Gets the ray "start point" of the ray in the world
  20108. */
  20109. readonly rayFromWorld: Vector3;
  20110. /**
  20111. * Gets the ray "end point" of the ray in the world
  20112. */
  20113. readonly rayToWorld: Vector3;
  20114. /**
  20115. * Sets the hit data (normal & point in world space)
  20116. * @param hitNormalWorld defines the normal in world space
  20117. * @param hitPointWorld defines the point in world space
  20118. */
  20119. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20120. /**
  20121. * Sets the distance from the start point to the hit point
  20122. * @param distance
  20123. */
  20124. setHitDistance(distance: number): void;
  20125. /**
  20126. * Calculates the distance manually
  20127. */
  20128. calculateHitDistance(): void;
  20129. /**
  20130. * Resets all the values to default
  20131. * @param from The from point on world space
  20132. * @param to The to point on world space
  20133. */
  20134. reset(from?: Vector3, to?: Vector3): void;
  20135. }
  20136. /**
  20137. * Interface for the size containing width and height
  20138. */
  20139. interface IXYZ {
  20140. /**
  20141. * X
  20142. */
  20143. x: number;
  20144. /**
  20145. * Y
  20146. */
  20147. y: number;
  20148. /**
  20149. * Z
  20150. */
  20151. z: number;
  20152. }
  20153. }
  20154. declare module "babylonjs/Physics/IPhysicsEngine" {
  20155. import { Nullable } from "babylonjs/types";
  20156. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20158. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20159. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20160. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20161. /**
  20162. * Interface used to describe a physics joint
  20163. */
  20164. export interface PhysicsImpostorJoint {
  20165. /** Defines the main impostor to which the joint is linked */
  20166. mainImpostor: PhysicsImpostor;
  20167. /** Defines the impostor that is connected to the main impostor using this joint */
  20168. connectedImpostor: PhysicsImpostor;
  20169. /** Defines the joint itself */
  20170. joint: PhysicsJoint;
  20171. }
  20172. /** @hidden */
  20173. export interface IPhysicsEnginePlugin {
  20174. world: any;
  20175. name: string;
  20176. setGravity(gravity: Vector3): void;
  20177. setTimeStep(timeStep: number): void;
  20178. getTimeStep(): number;
  20179. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20180. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20181. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20182. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20183. removePhysicsBody(impostor: PhysicsImpostor): void;
  20184. generateJoint(joint: PhysicsImpostorJoint): void;
  20185. removeJoint(joint: PhysicsImpostorJoint): void;
  20186. isSupported(): boolean;
  20187. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20188. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20189. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20190. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20191. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20192. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20193. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20194. getBodyMass(impostor: PhysicsImpostor): number;
  20195. getBodyFriction(impostor: PhysicsImpostor): number;
  20196. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20197. getBodyRestitution(impostor: PhysicsImpostor): number;
  20198. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20199. getBodyPressure?(impostor: PhysicsImpostor): number;
  20200. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20201. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20202. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20203. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20204. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20205. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20206. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20207. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20208. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20209. sleepBody(impostor: PhysicsImpostor): void;
  20210. wakeUpBody(impostor: PhysicsImpostor): void;
  20211. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20212. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20213. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20214. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20215. getRadius(impostor: PhysicsImpostor): number;
  20216. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20217. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20218. dispose(): void;
  20219. }
  20220. /**
  20221. * Interface used to define a physics engine
  20222. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20223. */
  20224. export interface IPhysicsEngine {
  20225. /**
  20226. * Gets the gravity vector used by the simulation
  20227. */
  20228. gravity: Vector3;
  20229. /**
  20230. * Sets the gravity vector used by the simulation
  20231. * @param gravity defines the gravity vector to use
  20232. */
  20233. setGravity(gravity: Vector3): void;
  20234. /**
  20235. * Set the time step of the physics engine.
  20236. * Default is 1/60.
  20237. * To slow it down, enter 1/600 for example.
  20238. * To speed it up, 1/30
  20239. * @param newTimeStep the new timestep to apply to this world.
  20240. */
  20241. setTimeStep(newTimeStep: number): void;
  20242. /**
  20243. * Get the time step of the physics engine.
  20244. * @returns the current time step
  20245. */
  20246. getTimeStep(): number;
  20247. /**
  20248. * Release all resources
  20249. */
  20250. dispose(): void;
  20251. /**
  20252. * Gets the name of the current physics plugin
  20253. * @returns the name of the plugin
  20254. */
  20255. getPhysicsPluginName(): string;
  20256. /**
  20257. * Adding a new impostor for the impostor tracking.
  20258. * This will be done by the impostor itself.
  20259. * @param impostor the impostor to add
  20260. */
  20261. addImpostor(impostor: PhysicsImpostor): void;
  20262. /**
  20263. * Remove an impostor from the engine.
  20264. * This impostor and its mesh will not longer be updated by the physics engine.
  20265. * @param impostor the impostor to remove
  20266. */
  20267. removeImpostor(impostor: PhysicsImpostor): void;
  20268. /**
  20269. * Add a joint to the physics engine
  20270. * @param mainImpostor defines the main impostor to which the joint is added.
  20271. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20272. * @param joint defines the joint that will connect both impostors.
  20273. */
  20274. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20275. /**
  20276. * Removes a joint from the simulation
  20277. * @param mainImpostor defines the impostor used with the joint
  20278. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20279. * @param joint defines the joint to remove
  20280. */
  20281. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20282. /**
  20283. * Gets the current plugin used to run the simulation
  20284. * @returns current plugin
  20285. */
  20286. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20287. /**
  20288. * Gets the list of physic impostors
  20289. * @returns an array of PhysicsImpostor
  20290. */
  20291. getImpostors(): Array<PhysicsImpostor>;
  20292. /**
  20293. * Gets the impostor for a physics enabled object
  20294. * @param object defines the object impersonated by the impostor
  20295. * @returns the PhysicsImpostor or null if not found
  20296. */
  20297. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20298. /**
  20299. * Gets the impostor for a physics body object
  20300. * @param body defines physics body used by the impostor
  20301. * @returns the PhysicsImpostor or null if not found
  20302. */
  20303. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20304. /**
  20305. * Does a raycast in the physics world
  20306. * @param from when should the ray start?
  20307. * @param to when should the ray end?
  20308. * @returns PhysicsRaycastResult
  20309. */
  20310. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20311. /**
  20312. * Called by the scene. No need to call it.
  20313. * @param delta defines the timespam between frames
  20314. */
  20315. _step(delta: number): void;
  20316. }
  20317. }
  20318. declare module "babylonjs/Physics/physicsImpostor" {
  20319. import { Nullable, IndicesArray } from "babylonjs/types";
  20320. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20321. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20323. import { Scene } from "babylonjs/scene";
  20324. import { Bone } from "babylonjs/Bones/bone";
  20325. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20326. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20327. /**
  20328. * The interface for the physics imposter parameters
  20329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20330. */
  20331. export interface PhysicsImpostorParameters {
  20332. /**
  20333. * The mass of the physics imposter
  20334. */
  20335. mass: number;
  20336. /**
  20337. * The friction of the physics imposter
  20338. */
  20339. friction?: number;
  20340. /**
  20341. * The coefficient of restitution of the physics imposter
  20342. */
  20343. restitution?: number;
  20344. /**
  20345. * The native options of the physics imposter
  20346. */
  20347. nativeOptions?: any;
  20348. /**
  20349. * Specifies if the parent should be ignored
  20350. */
  20351. ignoreParent?: boolean;
  20352. /**
  20353. * Specifies if bi-directional transformations should be disabled
  20354. */
  20355. disableBidirectionalTransformation?: boolean;
  20356. /**
  20357. * The pressure inside the physics imposter, soft object only
  20358. */
  20359. pressure?: number;
  20360. /**
  20361. * The stiffness the physics imposter, soft object only
  20362. */
  20363. stiffness?: number;
  20364. /**
  20365. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20366. */
  20367. velocityIterations?: number;
  20368. /**
  20369. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20370. */
  20371. positionIterations?: number;
  20372. /**
  20373. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20374. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20375. * Add to fix multiple points
  20376. */
  20377. fixedPoints?: number;
  20378. /**
  20379. * The collision margin around a soft object
  20380. */
  20381. margin?: number;
  20382. /**
  20383. * The collision margin around a soft object
  20384. */
  20385. damping?: number;
  20386. /**
  20387. * The path for a rope based on an extrusion
  20388. */
  20389. path?: any;
  20390. /**
  20391. * The shape of an extrusion used for a rope based on an extrusion
  20392. */
  20393. shape?: any;
  20394. }
  20395. /**
  20396. * Interface for a physics-enabled object
  20397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20398. */
  20399. export interface IPhysicsEnabledObject {
  20400. /**
  20401. * The position of the physics-enabled object
  20402. */
  20403. position: Vector3;
  20404. /**
  20405. * The rotation of the physics-enabled object
  20406. */
  20407. rotationQuaternion: Nullable<Quaternion>;
  20408. /**
  20409. * The scale of the physics-enabled object
  20410. */
  20411. scaling: Vector3;
  20412. /**
  20413. * The rotation of the physics-enabled object
  20414. */
  20415. rotation?: Vector3;
  20416. /**
  20417. * The parent of the physics-enabled object
  20418. */
  20419. parent?: any;
  20420. /**
  20421. * The bounding info of the physics-enabled object
  20422. * @returns The bounding info of the physics-enabled object
  20423. */
  20424. getBoundingInfo(): BoundingInfo;
  20425. /**
  20426. * Computes the world matrix
  20427. * @param force Specifies if the world matrix should be computed by force
  20428. * @returns A world matrix
  20429. */
  20430. computeWorldMatrix(force: boolean): Matrix;
  20431. /**
  20432. * Gets the world matrix
  20433. * @returns A world matrix
  20434. */
  20435. getWorldMatrix?(): Matrix;
  20436. /**
  20437. * Gets the child meshes
  20438. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20439. * @returns An array of abstract meshes
  20440. */
  20441. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20442. /**
  20443. * Gets the vertex data
  20444. * @param kind The type of vertex data
  20445. * @returns A nullable array of numbers, or a float32 array
  20446. */
  20447. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20448. /**
  20449. * Gets the indices from the mesh
  20450. * @returns A nullable array of index arrays
  20451. */
  20452. getIndices?(): Nullable<IndicesArray>;
  20453. /**
  20454. * Gets the scene from the mesh
  20455. * @returns the indices array or null
  20456. */
  20457. getScene?(): Scene;
  20458. /**
  20459. * Gets the absolute position from the mesh
  20460. * @returns the absolute position
  20461. */
  20462. getAbsolutePosition(): Vector3;
  20463. /**
  20464. * Gets the absolute pivot point from the mesh
  20465. * @returns the absolute pivot point
  20466. */
  20467. getAbsolutePivotPoint(): Vector3;
  20468. /**
  20469. * Rotates the mesh
  20470. * @param axis The axis of rotation
  20471. * @param amount The amount of rotation
  20472. * @param space The space of the rotation
  20473. * @returns The rotation transform node
  20474. */
  20475. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20476. /**
  20477. * Translates the mesh
  20478. * @param axis The axis of translation
  20479. * @param distance The distance of translation
  20480. * @param space The space of the translation
  20481. * @returns The transform node
  20482. */
  20483. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20484. /**
  20485. * Sets the absolute position of the mesh
  20486. * @param absolutePosition The absolute position of the mesh
  20487. * @returns The transform node
  20488. */
  20489. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20490. /**
  20491. * Gets the class name of the mesh
  20492. * @returns The class name
  20493. */
  20494. getClassName(): string;
  20495. }
  20496. /**
  20497. * Represents a physics imposter
  20498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20499. */
  20500. export class PhysicsImpostor {
  20501. /**
  20502. * The physics-enabled object used as the physics imposter
  20503. */
  20504. object: IPhysicsEnabledObject;
  20505. /**
  20506. * The type of the physics imposter
  20507. */
  20508. type: number;
  20509. private _options;
  20510. private _scene?;
  20511. /**
  20512. * The default object size of the imposter
  20513. */
  20514. static DEFAULT_OBJECT_SIZE: Vector3;
  20515. /**
  20516. * The identity quaternion of the imposter
  20517. */
  20518. static IDENTITY_QUATERNION: Quaternion;
  20519. /** @hidden */
  20520. _pluginData: any;
  20521. private _physicsEngine;
  20522. private _physicsBody;
  20523. private _bodyUpdateRequired;
  20524. private _onBeforePhysicsStepCallbacks;
  20525. private _onAfterPhysicsStepCallbacks;
  20526. /** @hidden */
  20527. _onPhysicsCollideCallbacks: Array<{
  20528. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20529. otherImpostors: Array<PhysicsImpostor>;
  20530. }>;
  20531. private _deltaPosition;
  20532. private _deltaRotation;
  20533. private _deltaRotationConjugated;
  20534. /** hidden */
  20535. _isFromLine: boolean;
  20536. private _parent;
  20537. private _isDisposed;
  20538. private static _tmpVecs;
  20539. private static _tmpQuat;
  20540. /**
  20541. * Specifies if the physics imposter is disposed
  20542. */
  20543. readonly isDisposed: boolean;
  20544. /**
  20545. * Gets the mass of the physics imposter
  20546. */
  20547. mass: number;
  20548. /**
  20549. * Gets the coefficient of friction
  20550. */
  20551. /**
  20552. * Sets the coefficient of friction
  20553. */
  20554. friction: number;
  20555. /**
  20556. * Gets the coefficient of restitution
  20557. */
  20558. /**
  20559. * Sets the coefficient of restitution
  20560. */
  20561. restitution: number;
  20562. /**
  20563. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20564. */
  20565. /**
  20566. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20567. */
  20568. pressure: number;
  20569. /**
  20570. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20571. */
  20572. /**
  20573. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20574. */
  20575. stiffness: number;
  20576. /**
  20577. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20578. */
  20579. /**
  20580. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20581. */
  20582. velocityIterations: number;
  20583. /**
  20584. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20585. */
  20586. /**
  20587. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20588. */
  20589. positionIterations: number;
  20590. /**
  20591. * The unique id of the physics imposter
  20592. * set by the physics engine when adding this impostor to the array
  20593. */
  20594. uniqueId: number;
  20595. /**
  20596. * @hidden
  20597. */
  20598. soft: boolean;
  20599. /**
  20600. * @hidden
  20601. */
  20602. segments: number;
  20603. private _joints;
  20604. /**
  20605. * Initializes the physics imposter
  20606. * @param object The physics-enabled object used as the physics imposter
  20607. * @param type The type of the physics imposter
  20608. * @param _options The options for the physics imposter
  20609. * @param _scene The Babylon scene
  20610. */
  20611. constructor(
  20612. /**
  20613. * The physics-enabled object used as the physics imposter
  20614. */
  20615. object: IPhysicsEnabledObject,
  20616. /**
  20617. * The type of the physics imposter
  20618. */
  20619. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20620. /**
  20621. * This function will completly initialize this impostor.
  20622. * It will create a new body - but only if this mesh has no parent.
  20623. * If it has, this impostor will not be used other than to define the impostor
  20624. * of the child mesh.
  20625. * @hidden
  20626. */
  20627. _init(): void;
  20628. private _getPhysicsParent;
  20629. /**
  20630. * Should a new body be generated.
  20631. * @returns boolean specifying if body initialization is required
  20632. */
  20633. isBodyInitRequired(): boolean;
  20634. /**
  20635. * Sets the updated scaling
  20636. * @param updated Specifies if the scaling is updated
  20637. */
  20638. setScalingUpdated(): void;
  20639. /**
  20640. * Force a regeneration of this or the parent's impostor's body.
  20641. * Use under cautious - This will remove all joints already implemented.
  20642. */
  20643. forceUpdate(): void;
  20644. /**
  20645. * Gets the body that holds this impostor. Either its own, or its parent.
  20646. */
  20647. /**
  20648. * Set the physics body. Used mainly by the physics engine/plugin
  20649. */
  20650. physicsBody: any;
  20651. /**
  20652. * Get the parent of the physics imposter
  20653. * @returns Physics imposter or null
  20654. */
  20655. /**
  20656. * Sets the parent of the physics imposter
  20657. */
  20658. parent: Nullable<PhysicsImpostor>;
  20659. /**
  20660. * Resets the update flags
  20661. */
  20662. resetUpdateFlags(): void;
  20663. /**
  20664. * Gets the object extend size
  20665. * @returns the object extend size
  20666. */
  20667. getObjectExtendSize(): Vector3;
  20668. /**
  20669. * Gets the object center
  20670. * @returns The object center
  20671. */
  20672. getObjectCenter(): Vector3;
  20673. /**
  20674. * Get a specific parametes from the options parameter
  20675. * @param paramName The object parameter name
  20676. * @returns The object parameter
  20677. */
  20678. getParam(paramName: string): any;
  20679. /**
  20680. * Sets a specific parameter in the options given to the physics plugin
  20681. * @param paramName The parameter name
  20682. * @param value The value of the parameter
  20683. */
  20684. setParam(paramName: string, value: number): void;
  20685. /**
  20686. * Specifically change the body's mass option. Won't recreate the physics body object
  20687. * @param mass The mass of the physics imposter
  20688. */
  20689. setMass(mass: number): void;
  20690. /**
  20691. * Gets the linear velocity
  20692. * @returns linear velocity or null
  20693. */
  20694. getLinearVelocity(): Nullable<Vector3>;
  20695. /**
  20696. * Sets the linear velocity
  20697. * @param velocity linear velocity or null
  20698. */
  20699. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20700. /**
  20701. * Gets the angular velocity
  20702. * @returns angular velocity or null
  20703. */
  20704. getAngularVelocity(): Nullable<Vector3>;
  20705. /**
  20706. * Sets the angular velocity
  20707. * @param velocity The velocity or null
  20708. */
  20709. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20710. /**
  20711. * Execute a function with the physics plugin native code
  20712. * Provide a function the will have two variables - the world object and the physics body object
  20713. * @param func The function to execute with the physics plugin native code
  20714. */
  20715. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20716. /**
  20717. * Register a function that will be executed before the physics world is stepping forward
  20718. * @param func The function to execute before the physics world is stepped forward
  20719. */
  20720. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20721. /**
  20722. * Unregister a function that will be executed before the physics world is stepping forward
  20723. * @param func The function to execute before the physics world is stepped forward
  20724. */
  20725. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20726. /**
  20727. * Register a function that will be executed after the physics step
  20728. * @param func The function to execute after physics step
  20729. */
  20730. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20731. /**
  20732. * Unregisters a function that will be executed after the physics step
  20733. * @param func The function to execute after physics step
  20734. */
  20735. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20736. /**
  20737. * register a function that will be executed when this impostor collides against a different body
  20738. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20739. * @param func Callback that is executed on collision
  20740. */
  20741. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20742. /**
  20743. * Unregisters the physics imposter on contact
  20744. * @param collideAgainst The physics object to collide against
  20745. * @param func Callback to execute on collision
  20746. */
  20747. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20748. private _tmpQuat;
  20749. private _tmpQuat2;
  20750. /**
  20751. * Get the parent rotation
  20752. * @returns The parent rotation
  20753. */
  20754. getParentsRotation(): Quaternion;
  20755. /**
  20756. * this function is executed by the physics engine.
  20757. */
  20758. beforeStep: () => void;
  20759. /**
  20760. * this function is executed by the physics engine
  20761. */
  20762. afterStep: () => void;
  20763. /**
  20764. * Legacy collision detection event support
  20765. */
  20766. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20767. /**
  20768. * event and body object due to cannon's event-based architecture.
  20769. */
  20770. onCollide: (e: {
  20771. body: any;
  20772. }) => void;
  20773. /**
  20774. * Apply a force
  20775. * @param force The force to apply
  20776. * @param contactPoint The contact point for the force
  20777. * @returns The physics imposter
  20778. */
  20779. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20780. /**
  20781. * Apply an impulse
  20782. * @param force The impulse force
  20783. * @param contactPoint The contact point for the impulse force
  20784. * @returns The physics imposter
  20785. */
  20786. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20787. /**
  20788. * A help function to create a joint
  20789. * @param otherImpostor A physics imposter used to create a joint
  20790. * @param jointType The type of joint
  20791. * @param jointData The data for the joint
  20792. * @returns The physics imposter
  20793. */
  20794. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20795. /**
  20796. * Add a joint to this impostor with a different impostor
  20797. * @param otherImpostor A physics imposter used to add a joint
  20798. * @param joint The joint to add
  20799. * @returns The physics imposter
  20800. */
  20801. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20802. /**
  20803. * Add an anchor to a cloth impostor
  20804. * @param otherImpostor rigid impostor to anchor to
  20805. * @param width ratio across width from 0 to 1
  20806. * @param height ratio up height from 0 to 1
  20807. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20808. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20809. * @returns impostor the soft imposter
  20810. */
  20811. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20812. /**
  20813. * Add a hook to a rope impostor
  20814. * @param otherImpostor rigid impostor to anchor to
  20815. * @param length ratio across rope from 0 to 1
  20816. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20817. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20818. * @returns impostor the rope imposter
  20819. */
  20820. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20821. /**
  20822. * Will keep this body still, in a sleep mode.
  20823. * @returns the physics imposter
  20824. */
  20825. sleep(): PhysicsImpostor;
  20826. /**
  20827. * Wake the body up.
  20828. * @returns The physics imposter
  20829. */
  20830. wakeUp(): PhysicsImpostor;
  20831. /**
  20832. * Clones the physics imposter
  20833. * @param newObject The physics imposter clones to this physics-enabled object
  20834. * @returns A nullable physics imposter
  20835. */
  20836. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20837. /**
  20838. * Disposes the physics imposter
  20839. */
  20840. dispose(): void;
  20841. /**
  20842. * Sets the delta position
  20843. * @param position The delta position amount
  20844. */
  20845. setDeltaPosition(position: Vector3): void;
  20846. /**
  20847. * Sets the delta rotation
  20848. * @param rotation The delta rotation amount
  20849. */
  20850. setDeltaRotation(rotation: Quaternion): void;
  20851. /**
  20852. * Gets the box size of the physics imposter and stores the result in the input parameter
  20853. * @param result Stores the box size
  20854. * @returns The physics imposter
  20855. */
  20856. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20857. /**
  20858. * Gets the radius of the physics imposter
  20859. * @returns Radius of the physics imposter
  20860. */
  20861. getRadius(): number;
  20862. /**
  20863. * Sync a bone with this impostor
  20864. * @param bone The bone to sync to the impostor.
  20865. * @param boneMesh The mesh that the bone is influencing.
  20866. * @param jointPivot The pivot of the joint / bone in local space.
  20867. * @param distToJoint Optional distance from the impostor to the joint.
  20868. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20869. */
  20870. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20871. /**
  20872. * Sync impostor to a bone
  20873. * @param bone The bone that the impostor will be synced to.
  20874. * @param boneMesh The mesh that the bone is influencing.
  20875. * @param jointPivot The pivot of the joint / bone in local space.
  20876. * @param distToJoint Optional distance from the impostor to the joint.
  20877. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20878. * @param boneAxis Optional vector3 axis the bone is aligned with
  20879. */
  20880. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20881. /**
  20882. * No-Imposter type
  20883. */
  20884. static NoImpostor: number;
  20885. /**
  20886. * Sphere-Imposter type
  20887. */
  20888. static SphereImpostor: number;
  20889. /**
  20890. * Box-Imposter type
  20891. */
  20892. static BoxImpostor: number;
  20893. /**
  20894. * Plane-Imposter type
  20895. */
  20896. static PlaneImpostor: number;
  20897. /**
  20898. * Mesh-imposter type
  20899. */
  20900. static MeshImpostor: number;
  20901. /**
  20902. * Cylinder-Imposter type
  20903. */
  20904. static CylinderImpostor: number;
  20905. /**
  20906. * Particle-Imposter type
  20907. */
  20908. static ParticleImpostor: number;
  20909. /**
  20910. * Heightmap-Imposter type
  20911. */
  20912. static HeightmapImpostor: number;
  20913. /**
  20914. * ConvexHull-Impostor type (Ammo.js plugin only)
  20915. */
  20916. static ConvexHullImpostor: number;
  20917. /**
  20918. * Rope-Imposter type
  20919. */
  20920. static RopeImpostor: number;
  20921. /**
  20922. * Cloth-Imposter type
  20923. */
  20924. static ClothImpostor: number;
  20925. /**
  20926. * Softbody-Imposter type
  20927. */
  20928. static SoftbodyImpostor: number;
  20929. }
  20930. }
  20931. declare module "babylonjs/Meshes/mesh" {
  20932. import { Observable } from "babylonjs/Misc/observable";
  20933. import { IAnimatable } from "babylonjs/Misc/tools";
  20934. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20935. import { Camera } from "babylonjs/Cameras/camera";
  20936. import { Scene } from "babylonjs/scene";
  20937. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20938. import { Engine } from "babylonjs/Engines/engine";
  20939. import { Node } from "babylonjs/node";
  20940. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20941. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20942. import { Buffer } from "babylonjs/Meshes/buffer";
  20943. import { Geometry } from "babylonjs/Meshes/geometry";
  20944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20945. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20946. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20947. import { Effect } from "babylonjs/Materials/effect";
  20948. import { Material } from "babylonjs/Materials/material";
  20949. import { Skeleton } from "babylonjs/Bones/skeleton";
  20950. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20951. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20952. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20953. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20954. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20955. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20956. /**
  20957. * Class used to represent a specific level of detail of a mesh
  20958. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20959. */
  20960. export class MeshLODLevel {
  20961. /** Defines the distance where this level should star being displayed */
  20962. distance: number;
  20963. /** Defines the mesh to use to render this level */
  20964. mesh: Nullable<Mesh>;
  20965. /**
  20966. * Creates a new LOD level
  20967. * @param distance defines the distance where this level should star being displayed
  20968. * @param mesh defines the mesh to use to render this level
  20969. */
  20970. constructor(
  20971. /** Defines the distance where this level should star being displayed */
  20972. distance: number,
  20973. /** Defines the mesh to use to render this level */
  20974. mesh: Nullable<Mesh>);
  20975. }
  20976. /**
  20977. * @hidden
  20978. **/
  20979. export class _CreationDataStorage {
  20980. closePath?: boolean;
  20981. closeArray?: boolean;
  20982. idx: number[];
  20983. dashSize: number;
  20984. gapSize: number;
  20985. path3D: Path3D;
  20986. pathArray: Vector3[][];
  20987. arc: number;
  20988. radius: number;
  20989. cap: number;
  20990. tessellation: number;
  20991. }
  20992. /**
  20993. * @hidden
  20994. **/
  20995. class _InstanceDataStorage {
  20996. visibleInstances: any;
  20997. renderIdForInstances: number[];
  20998. batchCache: _InstancesBatch;
  20999. instancesBufferSize: number;
  21000. instancesBuffer: Nullable<Buffer>;
  21001. instancesData: Float32Array;
  21002. overridenInstanceCount: number;
  21003. }
  21004. /**
  21005. * @hidden
  21006. **/
  21007. export class _InstancesBatch {
  21008. mustReturn: boolean;
  21009. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21010. renderSelf: boolean[];
  21011. }
  21012. /**
  21013. * Class used to represent renderable models
  21014. */
  21015. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21016. /**
  21017. * Mesh side orientation : usually the external or front surface
  21018. */
  21019. static readonly FRONTSIDE: number;
  21020. /**
  21021. * Mesh side orientation : usually the internal or back surface
  21022. */
  21023. static readonly BACKSIDE: number;
  21024. /**
  21025. * Mesh side orientation : both internal and external or front and back surfaces
  21026. */
  21027. static readonly DOUBLESIDE: number;
  21028. /**
  21029. * Mesh side orientation : by default, `FRONTSIDE`
  21030. */
  21031. static readonly DEFAULTSIDE: number;
  21032. /**
  21033. * Mesh cap setting : no cap
  21034. */
  21035. static readonly NO_CAP: number;
  21036. /**
  21037. * Mesh cap setting : one cap at the beginning of the mesh
  21038. */
  21039. static readonly CAP_START: number;
  21040. /**
  21041. * Mesh cap setting : one cap at the end of the mesh
  21042. */
  21043. static readonly CAP_END: number;
  21044. /**
  21045. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21046. */
  21047. static readonly CAP_ALL: number;
  21048. /**
  21049. * Gets the default side orientation.
  21050. * @param orientation the orientation to value to attempt to get
  21051. * @returns the default orientation
  21052. * @hidden
  21053. */
  21054. static _GetDefaultSideOrientation(orientation?: number): number;
  21055. private _onBeforeRenderObservable;
  21056. private _onBeforeBindObservable;
  21057. private _onAfterRenderObservable;
  21058. private _onBeforeDrawObservable;
  21059. /**
  21060. * An event triggered before rendering the mesh
  21061. */
  21062. readonly onBeforeRenderObservable: Observable<Mesh>;
  21063. /**
  21064. * An event triggered before binding the mesh
  21065. */
  21066. readonly onBeforeBindObservable: Observable<Mesh>;
  21067. /**
  21068. * An event triggered after rendering the mesh
  21069. */
  21070. readonly onAfterRenderObservable: Observable<Mesh>;
  21071. /**
  21072. * An event triggered before drawing the mesh
  21073. */
  21074. readonly onBeforeDrawObservable: Observable<Mesh>;
  21075. private _onBeforeDrawObserver;
  21076. /**
  21077. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21078. */
  21079. onBeforeDraw: () => void;
  21080. /**
  21081. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21082. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21083. */
  21084. delayLoadState: number;
  21085. /**
  21086. * Gets the list of instances created from this mesh
  21087. * it is not supposed to be modified manually.
  21088. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21089. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21090. */
  21091. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21092. /**
  21093. * Gets the file containing delay loading data for this mesh
  21094. */
  21095. delayLoadingFile: string;
  21096. /** @hidden */
  21097. _binaryInfo: any;
  21098. private _LODLevels;
  21099. /**
  21100. * User defined function used to change how LOD level selection is done
  21101. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21102. */
  21103. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21104. private _morphTargetManager;
  21105. /**
  21106. * Gets or sets the morph target manager
  21107. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21108. */
  21109. morphTargetManager: Nullable<MorphTargetManager>;
  21110. /** @hidden */
  21111. _creationDataStorage: Nullable<_CreationDataStorage>;
  21112. /** @hidden */
  21113. _geometry: Nullable<Geometry>;
  21114. /** @hidden */
  21115. _delayInfo: Array<string>;
  21116. /** @hidden */
  21117. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21118. /** @hidden */
  21119. _instanceDataStorage: _InstanceDataStorage;
  21120. private _effectiveMaterial;
  21121. /** @hidden */
  21122. _shouldGenerateFlatShading: boolean;
  21123. private _preActivateId;
  21124. /** @hidden */
  21125. _originalBuilderSideOrientation: number;
  21126. /**
  21127. * Use this property to change the original side orientation defined at construction time
  21128. */
  21129. overrideMaterialSideOrientation: Nullable<number>;
  21130. private _areNormalsFrozen;
  21131. private _sourcePositions;
  21132. private _sourceNormals;
  21133. private _source;
  21134. private meshMap;
  21135. /**
  21136. * Gets the source mesh (the one used to clone this one from)
  21137. */
  21138. readonly source: Nullable<Mesh>;
  21139. /**
  21140. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21141. */
  21142. isUnIndexed: boolean;
  21143. /**
  21144. * @constructor
  21145. * @param name The value used by scene.getMeshByName() to do a lookup.
  21146. * @param scene The scene to add this mesh to.
  21147. * @param parent The parent of this mesh, if it has one
  21148. * @param source An optional Mesh from which geometry is shared, cloned.
  21149. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21150. * When false, achieved by calling a clone(), also passing False.
  21151. * This will make creation of children, recursive.
  21152. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21153. */
  21154. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21155. /**
  21156. * Gets the class name
  21157. * @returns the string "Mesh".
  21158. */
  21159. getClassName(): string;
  21160. /** @hidden */
  21161. readonly _isMesh: boolean;
  21162. /**
  21163. * Returns a description of this mesh
  21164. * @param fullDetails define if full details about this mesh must be used
  21165. * @returns a descriptive string representing this mesh
  21166. */
  21167. toString(fullDetails?: boolean): string;
  21168. /** @hidden */
  21169. _unBindEffect(): void;
  21170. /**
  21171. * Gets a boolean indicating if this mesh has LOD
  21172. */
  21173. readonly hasLODLevels: boolean;
  21174. /**
  21175. * Gets the list of MeshLODLevel associated with the current mesh
  21176. * @returns an array of MeshLODLevel
  21177. */
  21178. getLODLevels(): MeshLODLevel[];
  21179. private _sortLODLevels;
  21180. /**
  21181. * Add a mesh as LOD level triggered at the given distance.
  21182. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21183. * @param distance The distance from the center of the object to show this level
  21184. * @param mesh The mesh to be added as LOD level (can be null)
  21185. * @return This mesh (for chaining)
  21186. */
  21187. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21188. /**
  21189. * Returns the LOD level mesh at the passed distance or null if not found.
  21190. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21191. * @param distance The distance from the center of the object to show this level
  21192. * @returns a Mesh or `null`
  21193. */
  21194. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21195. /**
  21196. * Remove a mesh from the LOD array
  21197. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21198. * @param mesh defines the mesh to be removed
  21199. * @return This mesh (for chaining)
  21200. */
  21201. removeLODLevel(mesh: Mesh): Mesh;
  21202. /**
  21203. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21204. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21205. * @param camera defines the camera to use to compute distance
  21206. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21207. * @return This mesh (for chaining)
  21208. */
  21209. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21210. /**
  21211. * Gets the mesh internal Geometry object
  21212. */
  21213. readonly geometry: Nullable<Geometry>;
  21214. /**
  21215. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21216. * @returns the total number of vertices
  21217. */
  21218. getTotalVertices(): number;
  21219. /**
  21220. * Returns the content of an associated vertex buffer
  21221. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21222. * - VertexBuffer.PositionKind
  21223. * - VertexBuffer.UVKind
  21224. * - VertexBuffer.UV2Kind
  21225. * - VertexBuffer.UV3Kind
  21226. * - VertexBuffer.UV4Kind
  21227. * - VertexBuffer.UV5Kind
  21228. * - VertexBuffer.UV6Kind
  21229. * - VertexBuffer.ColorKind
  21230. * - VertexBuffer.MatricesIndicesKind
  21231. * - VertexBuffer.MatricesIndicesExtraKind
  21232. * - VertexBuffer.MatricesWeightsKind
  21233. * - VertexBuffer.MatricesWeightsExtraKind
  21234. * @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
  21235. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21236. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21237. */
  21238. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21239. /**
  21240. * Returns the mesh VertexBuffer object from the requested `kind`
  21241. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21242. * - VertexBuffer.PositionKind
  21243. * - VertexBuffer.UVKind
  21244. * - VertexBuffer.UV2Kind
  21245. * - VertexBuffer.UV3Kind
  21246. * - VertexBuffer.UV4Kind
  21247. * - VertexBuffer.UV5Kind
  21248. * - VertexBuffer.UV6Kind
  21249. * - VertexBuffer.ColorKind
  21250. * - VertexBuffer.MatricesIndicesKind
  21251. * - VertexBuffer.MatricesIndicesExtraKind
  21252. * - VertexBuffer.MatricesWeightsKind
  21253. * - VertexBuffer.MatricesWeightsExtraKind
  21254. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21255. */
  21256. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21257. /**
  21258. * Tests if a specific vertex buffer is associated with this mesh
  21259. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21260. * - VertexBuffer.PositionKind
  21261. * - VertexBuffer.UVKind
  21262. * - VertexBuffer.UV2Kind
  21263. * - VertexBuffer.UV3Kind
  21264. * - VertexBuffer.UV4Kind
  21265. * - VertexBuffer.UV5Kind
  21266. * - VertexBuffer.UV6Kind
  21267. * - VertexBuffer.ColorKind
  21268. * - VertexBuffer.MatricesIndicesKind
  21269. * - VertexBuffer.MatricesIndicesExtraKind
  21270. * - VertexBuffer.MatricesWeightsKind
  21271. * - VertexBuffer.MatricesWeightsExtraKind
  21272. * @returns a boolean
  21273. */
  21274. isVerticesDataPresent(kind: string): boolean;
  21275. /**
  21276. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21277. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21278. * - VertexBuffer.PositionKind
  21279. * - VertexBuffer.UVKind
  21280. * - VertexBuffer.UV2Kind
  21281. * - VertexBuffer.UV3Kind
  21282. * - VertexBuffer.UV4Kind
  21283. * - VertexBuffer.UV5Kind
  21284. * - VertexBuffer.UV6Kind
  21285. * - VertexBuffer.ColorKind
  21286. * - VertexBuffer.MatricesIndicesKind
  21287. * - VertexBuffer.MatricesIndicesExtraKind
  21288. * - VertexBuffer.MatricesWeightsKind
  21289. * - VertexBuffer.MatricesWeightsExtraKind
  21290. * @returns a boolean
  21291. */
  21292. isVertexBufferUpdatable(kind: string): boolean;
  21293. /**
  21294. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21295. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21296. * - VertexBuffer.PositionKind
  21297. * - VertexBuffer.UVKind
  21298. * - VertexBuffer.UV2Kind
  21299. * - VertexBuffer.UV3Kind
  21300. * - VertexBuffer.UV4Kind
  21301. * - VertexBuffer.UV5Kind
  21302. * - VertexBuffer.UV6Kind
  21303. * - VertexBuffer.ColorKind
  21304. * - VertexBuffer.MatricesIndicesKind
  21305. * - VertexBuffer.MatricesIndicesExtraKind
  21306. * - VertexBuffer.MatricesWeightsKind
  21307. * - VertexBuffer.MatricesWeightsExtraKind
  21308. * @returns an array of strings
  21309. */
  21310. getVerticesDataKinds(): string[];
  21311. /**
  21312. * Returns a positive integer : the total number of indices in this mesh geometry.
  21313. * @returns the numner of indices or zero if the mesh has no geometry.
  21314. */
  21315. getTotalIndices(): number;
  21316. /**
  21317. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21318. * @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.
  21319. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21320. * @returns the indices array or an empty array if the mesh has no geometry
  21321. */
  21322. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21323. readonly isBlocked: boolean;
  21324. /**
  21325. * Determine if the current mesh is ready to be rendered
  21326. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21327. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21328. * @returns true if all associated assets are ready (material, textures, shaders)
  21329. */
  21330. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21331. /**
  21332. * 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.
  21333. */
  21334. readonly areNormalsFrozen: boolean;
  21335. /**
  21336. * 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.
  21337. * @returns the current mesh
  21338. */
  21339. freezeNormals(): Mesh;
  21340. /**
  21341. * 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
  21342. * @returns the current mesh
  21343. */
  21344. unfreezeNormals(): Mesh;
  21345. /**
  21346. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21347. */
  21348. overridenInstanceCount: number;
  21349. /** @hidden */
  21350. _preActivate(): Mesh;
  21351. /** @hidden */
  21352. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21353. /** @hidden */
  21354. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21355. /**
  21356. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21357. * This means the mesh underlying bounding box and sphere are recomputed.
  21358. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21359. * @returns the current mesh
  21360. */
  21361. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21362. /** @hidden */
  21363. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21364. /**
  21365. * This function will subdivide the mesh into multiple submeshes
  21366. * @param count defines the expected number of submeshes
  21367. */
  21368. subdivide(count: number): void;
  21369. /**
  21370. * Copy a FloatArray into a specific associated vertex buffer
  21371. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21372. * - VertexBuffer.PositionKind
  21373. * - VertexBuffer.UVKind
  21374. * - VertexBuffer.UV2Kind
  21375. * - VertexBuffer.UV3Kind
  21376. * - VertexBuffer.UV4Kind
  21377. * - VertexBuffer.UV5Kind
  21378. * - VertexBuffer.UV6Kind
  21379. * - VertexBuffer.ColorKind
  21380. * - VertexBuffer.MatricesIndicesKind
  21381. * - VertexBuffer.MatricesIndicesExtraKind
  21382. * - VertexBuffer.MatricesWeightsKind
  21383. * - VertexBuffer.MatricesWeightsExtraKind
  21384. * @param data defines the data source
  21385. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21386. * @param stride defines the data stride size (can be null)
  21387. * @returns the current mesh
  21388. */
  21389. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21390. /**
  21391. * Flags an associated vertex buffer as updatable
  21392. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21393. * - VertexBuffer.PositionKind
  21394. * - VertexBuffer.UVKind
  21395. * - VertexBuffer.UV2Kind
  21396. * - VertexBuffer.UV3Kind
  21397. * - VertexBuffer.UV4Kind
  21398. * - VertexBuffer.UV5Kind
  21399. * - VertexBuffer.UV6Kind
  21400. * - VertexBuffer.ColorKind
  21401. * - VertexBuffer.MatricesIndicesKind
  21402. * - VertexBuffer.MatricesIndicesExtraKind
  21403. * - VertexBuffer.MatricesWeightsKind
  21404. * - VertexBuffer.MatricesWeightsExtraKind
  21405. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21406. */
  21407. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21408. /**
  21409. * Sets the mesh global Vertex Buffer
  21410. * @param buffer defines the buffer to use
  21411. * @returns the current mesh
  21412. */
  21413. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21414. /**
  21415. * Update a specific associated vertex buffer
  21416. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21417. * - VertexBuffer.PositionKind
  21418. * - VertexBuffer.UVKind
  21419. * - VertexBuffer.UV2Kind
  21420. * - VertexBuffer.UV3Kind
  21421. * - VertexBuffer.UV4Kind
  21422. * - VertexBuffer.UV5Kind
  21423. * - VertexBuffer.UV6Kind
  21424. * - VertexBuffer.ColorKind
  21425. * - VertexBuffer.MatricesIndicesKind
  21426. * - VertexBuffer.MatricesIndicesExtraKind
  21427. * - VertexBuffer.MatricesWeightsKind
  21428. * - VertexBuffer.MatricesWeightsExtraKind
  21429. * @param data defines the data source
  21430. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21431. * @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)
  21432. * @returns the current mesh
  21433. */
  21434. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21435. /**
  21436. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21437. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21438. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21439. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21440. * @returns the current mesh
  21441. */
  21442. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21443. /**
  21444. * Creates a un-shared specific occurence of the geometry for the mesh.
  21445. * @returns the current mesh
  21446. */
  21447. makeGeometryUnique(): Mesh;
  21448. /**
  21449. * Set the index buffer of this mesh
  21450. * @param indices defines the source data
  21451. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21452. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21453. * @returns the current mesh
  21454. */
  21455. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21456. /**
  21457. * Update the current index buffer
  21458. * @param indices defines the source data
  21459. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21460. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21461. * @returns the current mesh
  21462. */
  21463. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21464. /**
  21465. * Invert the geometry to move from a right handed system to a left handed one.
  21466. * @returns the current mesh
  21467. */
  21468. toLeftHanded(): Mesh;
  21469. /** @hidden */
  21470. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21471. /** @hidden */
  21472. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21473. /**
  21474. * Registers for this mesh a javascript function called just before the rendering process
  21475. * @param func defines the function to call before rendering this mesh
  21476. * @returns the current mesh
  21477. */
  21478. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21479. /**
  21480. * Disposes a previously registered javascript function called before the rendering
  21481. * @param func defines the function to remove
  21482. * @returns the current mesh
  21483. */
  21484. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21485. /**
  21486. * Registers for this mesh a javascript function called just after the rendering is complete
  21487. * @param func defines the function to call after rendering this mesh
  21488. * @returns the current mesh
  21489. */
  21490. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21491. /**
  21492. * Disposes a previously registered javascript function called after the rendering.
  21493. * @param func defines the function to remove
  21494. * @returns the current mesh
  21495. */
  21496. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21497. /** @hidden */
  21498. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21499. /** @hidden */
  21500. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21501. /** @hidden */
  21502. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21503. /**
  21504. * 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
  21505. * @param subMesh defines the subMesh to render
  21506. * @param enableAlphaMode defines if alpha mode can be changed
  21507. * @returns the current mesh
  21508. */
  21509. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21510. private _onBeforeDraw;
  21511. /**
  21512. * Renormalize the mesh and patch it up if there are no weights
  21513. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21514. * However in the case of zero weights then we set just a single influence to 1.
  21515. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21516. */
  21517. cleanMatrixWeights(): void;
  21518. private normalizeSkinFourWeights;
  21519. private normalizeSkinWeightsAndExtra;
  21520. /**
  21521. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21522. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21523. * the user know there was an issue with importing the mesh
  21524. * @returns a validation object with skinned, valid and report string
  21525. */
  21526. validateSkinning(): {
  21527. skinned: boolean;
  21528. valid: boolean;
  21529. report: string;
  21530. };
  21531. /** @hidden */
  21532. _checkDelayState(): Mesh;
  21533. private _queueLoad;
  21534. /**
  21535. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21536. * A mesh is in the frustum if its bounding box intersects the frustum
  21537. * @param frustumPlanes defines the frustum to test
  21538. * @returns true if the mesh is in the frustum planes
  21539. */
  21540. isInFrustum(frustumPlanes: Plane[]): boolean;
  21541. /**
  21542. * Sets the mesh material by the material or multiMaterial `id` property
  21543. * @param id is a string identifying the material or the multiMaterial
  21544. * @returns the current mesh
  21545. */
  21546. setMaterialByID(id: string): Mesh;
  21547. /**
  21548. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21549. * @returns an array of IAnimatable
  21550. */
  21551. getAnimatables(): IAnimatable[];
  21552. /**
  21553. * Modifies the mesh geometry according to the passed transformation matrix.
  21554. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21555. * The mesh normals are modified using the same transformation.
  21556. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21557. * @param transform defines the transform matrix to use
  21558. * @see http://doc.babylonjs.com/resources/baking_transformations
  21559. * @returns the current mesh
  21560. */
  21561. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21562. /**
  21563. * Modifies the mesh geometry according to its own current World Matrix.
  21564. * The mesh World Matrix is then reset.
  21565. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21566. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21567. * @see http://doc.babylonjs.com/resources/baking_transformations
  21568. * @returns the current mesh
  21569. */
  21570. bakeCurrentTransformIntoVertices(): Mesh;
  21571. /** @hidden */
  21572. readonly _positions: Nullable<Vector3[]>;
  21573. /** @hidden */
  21574. _resetPointsArrayCache(): Mesh;
  21575. /** @hidden */
  21576. _generatePointsArray(): boolean;
  21577. /**
  21578. * Returns a new Mesh object generated from the current mesh properties.
  21579. * This method must not get confused with createInstance()
  21580. * @param name is a string, the name given to the new mesh
  21581. * @param newParent can be any Node object (default `null`)
  21582. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21583. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21584. * @returns a new mesh
  21585. */
  21586. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21587. /**
  21588. * Releases resources associated with this mesh.
  21589. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21590. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21591. */
  21592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21593. /**
  21594. * Modifies the mesh geometry according to a displacement map.
  21595. * 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.
  21596. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21597. * @param url is a string, the URL from the image file is to be downloaded.
  21598. * @param minHeight is the lower limit of the displacement.
  21599. * @param maxHeight is the upper limit of the displacement.
  21600. * @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.
  21601. * @param uvOffset is an optional vector2 used to offset UV.
  21602. * @param uvScale is an optional vector2 used to scale UV.
  21603. * @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.
  21604. * @returns the Mesh.
  21605. */
  21606. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21607. /**
  21608. * Modifies the mesh geometry according to a displacementMap buffer.
  21609. * 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.
  21610. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21611. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21612. * @param heightMapWidth is the width of the buffer image.
  21613. * @param heightMapHeight is the height of the buffer image.
  21614. * @param minHeight is the lower limit of the displacement.
  21615. * @param maxHeight is the upper limit of the displacement.
  21616. * @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.
  21617. * @param uvOffset is an optional vector2 used to offset UV.
  21618. * @param uvScale is an optional vector2 used to scale UV.
  21619. * @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.
  21620. * @returns the Mesh.
  21621. */
  21622. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21623. /**
  21624. * Modify the mesh to get a flat shading rendering.
  21625. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21626. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21627. * @returns current mesh
  21628. */
  21629. convertToFlatShadedMesh(): Mesh;
  21630. /**
  21631. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21632. * In other words, more vertices, no more indices and a single bigger VBO.
  21633. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21634. * @returns current mesh
  21635. */
  21636. convertToUnIndexedMesh(): Mesh;
  21637. /**
  21638. * Inverses facet orientations.
  21639. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21640. * @param flipNormals will also inverts the normals
  21641. * @returns current mesh
  21642. */
  21643. flipFaces(flipNormals?: boolean): Mesh;
  21644. /**
  21645. * Increase the number of facets and hence vertices in a mesh
  21646. * Vertex normals are interpolated from existing vertex normals
  21647. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21648. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21649. */
  21650. increaseVertices(numberPerEdge: number): void;
  21651. /**
  21652. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21653. * This will undo any application of covertToFlatShadedMesh
  21654. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21655. */
  21656. forceSharedVertices(): void;
  21657. /** @hidden */
  21658. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21659. /** @hidden */
  21660. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21661. /**
  21662. * Creates a new InstancedMesh object from the mesh model.
  21663. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21664. * @param name defines the name of the new instance
  21665. * @returns a new InstancedMesh
  21666. */
  21667. createInstance(name: string): InstancedMesh;
  21668. /**
  21669. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21670. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21671. * @returns the current mesh
  21672. */
  21673. synchronizeInstances(): Mesh;
  21674. /**
  21675. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21676. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21677. * This should be used together with the simplification to avoid disappearing triangles.
  21678. * @param successCallback an optional success callback to be called after the optimization finished.
  21679. * @returns the current mesh
  21680. */
  21681. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21682. /**
  21683. * Serialize current mesh
  21684. * @param serializationObject defines the object which will receive the serialization data
  21685. */
  21686. serialize(serializationObject: any): void;
  21687. /** @hidden */
  21688. _syncGeometryWithMorphTargetManager(): void;
  21689. /** @hidden */
  21690. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21691. /**
  21692. * Returns a new Mesh object parsed from the source provided.
  21693. * @param parsedMesh is the source
  21694. * @param scene defines the hosting scene
  21695. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21696. * @returns a new Mesh
  21697. */
  21698. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21699. /**
  21700. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21701. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21702. * @param name defines the name of the mesh to create
  21703. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21704. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21705. * @param closePath creates a seam between the first and the last points of each path of the path array
  21706. * @param offset is taken in account only if the `pathArray` is containing a single path
  21707. * @param scene defines the hosting scene
  21708. * @param updatable defines if the mesh must be flagged as updatable
  21709. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21710. * @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)
  21711. * @returns a new Mesh
  21712. */
  21713. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21714. /**
  21715. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21716. * @param name defines the name of the mesh to create
  21717. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21718. * @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
  21719. * @param scene defines the hosting scene
  21720. * @param updatable defines if the mesh must be flagged as updatable
  21721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21722. * @returns a new Mesh
  21723. */
  21724. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21725. /**
  21726. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21727. * @param name defines the name of the mesh to create
  21728. * @param size sets the size (float) of each box side (default 1)
  21729. * @param scene defines the hosting scene
  21730. * @param updatable defines if the mesh must be flagged as updatable
  21731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21732. * @returns a new Mesh
  21733. */
  21734. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21735. /**
  21736. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21737. * @param name defines the name of the mesh to create
  21738. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21739. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21740. * @param scene defines the hosting scene
  21741. * @param updatable defines if the mesh must be flagged as updatable
  21742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21743. * @returns a new Mesh
  21744. */
  21745. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21746. /**
  21747. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21748. * @param name defines the name of the mesh to create
  21749. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21750. * @param diameterTop set the top cap diameter (floats, default 1)
  21751. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21752. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21753. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21754. * @param scene defines the hosting scene
  21755. * @param updatable defines if the mesh must be flagged as updatable
  21756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21757. * @returns a new Mesh
  21758. */
  21759. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21760. /**
  21761. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21762. * @param name defines the name of the mesh to create
  21763. * @param diameter sets the diameter size (float) of the torus (default 1)
  21764. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21765. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21766. * @param scene defines the hosting scene
  21767. * @param updatable defines if the mesh must be flagged as updatable
  21768. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21769. * @returns a new Mesh
  21770. */
  21771. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21772. /**
  21773. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21774. * @param name defines the name of the mesh to create
  21775. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21776. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21777. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21778. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21779. * @param p the number of windings on X axis (positive integers, default 2)
  21780. * @param q the number of windings on Y axis (positive integers, default 3)
  21781. * @param scene defines the hosting scene
  21782. * @param updatable defines if the mesh must be flagged as updatable
  21783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21784. * @returns a new Mesh
  21785. */
  21786. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21787. /**
  21788. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21789. * @param name defines the name of the mesh to create
  21790. * @param points is an array successive Vector3
  21791. * @param scene defines the hosting scene
  21792. * @param updatable defines if the mesh must be flagged as updatable
  21793. * @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).
  21794. * @returns a new Mesh
  21795. */
  21796. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21797. /**
  21798. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21799. * @param name defines the name of the mesh to create
  21800. * @param points is an array successive Vector3
  21801. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21802. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21803. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21804. * @param scene defines the hosting scene
  21805. * @param updatable defines if the mesh must be flagged as updatable
  21806. * @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)
  21807. * @returns a new Mesh
  21808. */
  21809. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21810. /**
  21811. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21812. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21813. * 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.
  21814. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21815. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21816. * Remember you can only change the shape positions, not their number when updating a polygon.
  21817. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21818. * @param name defines the name of the mesh to create
  21819. * @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
  21820. * @param scene defines the hosting scene
  21821. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21822. * @param updatable defines if the mesh must be flagged as updatable
  21823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21824. * @param earcutInjection can be used to inject your own earcut reference
  21825. * @returns a new Mesh
  21826. */
  21827. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21828. /**
  21829. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21830. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21831. * @param name defines the name of the mesh to create
  21832. * @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
  21833. * @param depth defines the height of extrusion
  21834. * @param scene defines the hosting scene
  21835. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21836. * @param updatable defines if the mesh must be flagged as updatable
  21837. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21838. * @param earcutInjection can be used to inject your own earcut reference
  21839. * @returns a new Mesh
  21840. */
  21841. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21842. /**
  21843. * Creates an extruded shape mesh.
  21844. * 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
  21845. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21846. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21847. * @param name defines the name of the mesh to create
  21848. * @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
  21849. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21850. * @param scale is the value to scale the shape
  21851. * @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
  21852. * @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
  21853. * @param scene defines the hosting scene
  21854. * @param updatable defines if the mesh must be flagged as updatable
  21855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21856. * @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)
  21857. * @returns a new Mesh
  21858. */
  21859. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21860. /**
  21861. * Creates an custom extruded shape mesh.
  21862. * The custom extrusion is a parametric shape.
  21863. * It has no predefined shape. Its final shape will depend on the input parameters.
  21864. * Please consider using the same method from the MeshBuilder class instead
  21865. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21866. * @param name defines the name of the mesh to create
  21867. * @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
  21868. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21869. * @param scaleFunction is a custom Javascript function called on each path point
  21870. * @param rotationFunction is a custom Javascript function called on each path point
  21871. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21872. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21873. * @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
  21874. * @param scene defines the hosting scene
  21875. * @param updatable defines if the mesh must be flagged as updatable
  21876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21877. * @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)
  21878. * @returns a new Mesh
  21879. */
  21880. 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;
  21881. /**
  21882. * Creates lathe mesh.
  21883. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21884. * Please consider using the same method from the MeshBuilder class instead
  21885. * @param name defines the name of the mesh to create
  21886. * @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
  21887. * @param radius is the radius value of the lathe
  21888. * @param tessellation is the side number of the lathe.
  21889. * @param scene defines the hosting scene
  21890. * @param updatable defines if the mesh must be flagged as updatable
  21891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21892. * @returns a new Mesh
  21893. */
  21894. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21895. /**
  21896. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21897. * @param name defines the name of the mesh to create
  21898. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21899. * @param scene defines the hosting scene
  21900. * @param updatable defines if the mesh must be flagged as updatable
  21901. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21902. * @returns a new Mesh
  21903. */
  21904. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21905. /**
  21906. * Creates a ground mesh.
  21907. * Please consider using the same method from the MeshBuilder class instead
  21908. * @param name defines the name of the mesh to create
  21909. * @param width set the width of the ground
  21910. * @param height set the height of the ground
  21911. * @param subdivisions sets the number of subdivisions per side
  21912. * @param scene defines the hosting scene
  21913. * @param updatable defines if the mesh must be flagged as updatable
  21914. * @returns a new Mesh
  21915. */
  21916. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21917. /**
  21918. * Creates a tiled ground mesh.
  21919. * Please consider using the same method from the MeshBuilder class instead
  21920. * @param name defines the name of the mesh to create
  21921. * @param xmin set the ground minimum X coordinate
  21922. * @param zmin set the ground minimum Y coordinate
  21923. * @param xmax set the ground maximum X coordinate
  21924. * @param zmax set the ground maximum Z coordinate
  21925. * @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
  21926. * @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
  21927. * @param scene defines the hosting scene
  21928. * @param updatable defines if the mesh must be flagged as updatable
  21929. * @returns a new Mesh
  21930. */
  21931. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21932. w: number;
  21933. h: number;
  21934. }, precision: {
  21935. w: number;
  21936. h: number;
  21937. }, scene: Scene, updatable?: boolean): Mesh;
  21938. /**
  21939. * Creates a ground mesh from a height map.
  21940. * Please consider using the same method from the MeshBuilder class instead
  21941. * @see http://doc.babylonjs.com/babylon101/height_map
  21942. * @param name defines the name of the mesh to create
  21943. * @param url sets the URL of the height map image resource
  21944. * @param width set the ground width size
  21945. * @param height set the ground height size
  21946. * @param subdivisions sets the number of subdivision per side
  21947. * @param minHeight is the minimum altitude on the ground
  21948. * @param maxHeight is the maximum altitude on the ground
  21949. * @param scene defines the hosting scene
  21950. * @param updatable defines if the mesh must be flagged as updatable
  21951. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21952. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21953. * @returns a new Mesh
  21954. */
  21955. 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;
  21956. /**
  21957. * Creates a tube mesh.
  21958. * The tube is a parametric shape.
  21959. * It has no predefined shape. Its final shape will depend on the input parameters.
  21960. * Please consider using the same method from the MeshBuilder class instead
  21961. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21962. * @param name defines the name of the mesh to create
  21963. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21964. * @param radius sets the tube radius size
  21965. * @param tessellation is the number of sides on the tubular surface
  21966. * @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
  21967. * @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
  21968. * @param scene defines the hosting scene
  21969. * @param updatable defines if the mesh must be flagged as updatable
  21970. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21971. * @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)
  21972. * @returns a new Mesh
  21973. */
  21974. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21975. (i: number, distance: number): number;
  21976. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21977. /**
  21978. * Creates a polyhedron mesh.
  21979. * Please consider using the same method from the MeshBuilder class instead.
  21980. * * 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
  21981. * * The parameter `size` (positive float, default 1) sets the polygon size
  21982. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21983. * * 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`
  21984. * * 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
  21985. * * 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)`)
  21986. * * 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
  21987. * * 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
  21988. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21989. * * If you create a double-sided mesh, you can choose what parts of 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
  21990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21991. * @param name defines the name of the mesh to create
  21992. * @param options defines the options used to create the mesh
  21993. * @param scene defines the hosting scene
  21994. * @returns a new Mesh
  21995. */
  21996. static CreatePolyhedron(name: string, options: {
  21997. type?: number;
  21998. size?: number;
  21999. sizeX?: number;
  22000. sizeY?: number;
  22001. sizeZ?: number;
  22002. custom?: any;
  22003. faceUV?: Vector4[];
  22004. faceColors?: Color4[];
  22005. updatable?: boolean;
  22006. sideOrientation?: number;
  22007. }, scene: Scene): Mesh;
  22008. /**
  22009. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22010. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22011. * * 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`)
  22012. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22013. * * 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
  22014. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22015. * * If you create a double-sided mesh, you can choose what parts of 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
  22016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22017. * @param name defines the name of the mesh
  22018. * @param options defines the options used to create the mesh
  22019. * @param scene defines the hosting scene
  22020. * @returns a new Mesh
  22021. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22022. */
  22023. static CreateIcoSphere(name: string, options: {
  22024. radius?: number;
  22025. flat?: boolean;
  22026. subdivisions?: number;
  22027. sideOrientation?: number;
  22028. updatable?: boolean;
  22029. }, scene: Scene): Mesh;
  22030. /**
  22031. * Creates a decal mesh.
  22032. * Please consider using the same method from the MeshBuilder class instead.
  22033. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22034. * @param name defines the name of the mesh
  22035. * @param sourceMesh defines the mesh receiving the decal
  22036. * @param position sets the position of the decal in world coordinates
  22037. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22038. * @param size sets the decal scaling
  22039. * @param angle sets the angle to rotate the decal
  22040. * @returns a new Mesh
  22041. */
  22042. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22043. /**
  22044. * Prepare internal position array for software CPU skinning
  22045. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22046. */
  22047. setPositionsForCPUSkinning(): Float32Array;
  22048. /**
  22049. * Prepare internal normal array for software CPU skinning
  22050. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22051. */
  22052. setNormalsForCPUSkinning(): Float32Array;
  22053. /**
  22054. * Updates the vertex buffer by applying transformation from the bones
  22055. * @param skeleton defines the skeleton to apply to current mesh
  22056. * @returns the current mesh
  22057. */
  22058. applySkeleton(skeleton: Skeleton): Mesh;
  22059. /**
  22060. * 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
  22061. * @param meshes defines the list of meshes to scan
  22062. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22063. */
  22064. static MinMax(meshes: AbstractMesh[]): {
  22065. min: Vector3;
  22066. max: Vector3;
  22067. };
  22068. /**
  22069. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22070. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22071. * @returns a vector3
  22072. */
  22073. static Center(meshesOrMinMaxVector: {
  22074. min: Vector3;
  22075. max: Vector3;
  22076. } | AbstractMesh[]): Vector3;
  22077. /**
  22078. * Merge the array of meshes into a single mesh for performance reasons.
  22079. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22080. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22081. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22082. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22083. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22084. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22085. * @returns a new mesh
  22086. */
  22087. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22088. /** @hidden */
  22089. addInstance(instance: InstancedMesh): void;
  22090. /** @hidden */
  22091. removeInstance(instance: InstancedMesh): void;
  22092. }
  22093. }
  22094. declare module "babylonjs/Materials/material" {
  22095. import { IAnimatable } from "babylonjs/Misc/tools";
  22096. import { SmartArray } from "babylonjs/Misc/smartArray";
  22097. import { Observable } from "babylonjs/Misc/observable";
  22098. import { Nullable } from "babylonjs/types";
  22099. import { Scene } from "babylonjs/scene";
  22100. import { Matrix } from "babylonjs/Maths/math";
  22101. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22103. import { Mesh } from "babylonjs/Meshes/mesh";
  22104. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22105. import { Effect } from "babylonjs/Materials/effect";
  22106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22107. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22108. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22109. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22110. import { Animation } from "babylonjs/Animations/animation";
  22111. /**
  22112. * Base class for the main features of a material in Babylon.js
  22113. */
  22114. export class Material implements IAnimatable {
  22115. /**
  22116. * Returns the triangle fill mode
  22117. */
  22118. static readonly TriangleFillMode: number;
  22119. /**
  22120. * Returns the wireframe mode
  22121. */
  22122. static readonly WireFrameFillMode: number;
  22123. /**
  22124. * Returns the point fill mode
  22125. */
  22126. static readonly PointFillMode: number;
  22127. /**
  22128. * Returns the point list draw mode
  22129. */
  22130. static readonly PointListDrawMode: number;
  22131. /**
  22132. * Returns the line list draw mode
  22133. */
  22134. static readonly LineListDrawMode: number;
  22135. /**
  22136. * Returns the line loop draw mode
  22137. */
  22138. static readonly LineLoopDrawMode: number;
  22139. /**
  22140. * Returns the line strip draw mode
  22141. */
  22142. static readonly LineStripDrawMode: number;
  22143. /**
  22144. * Returns the triangle strip draw mode
  22145. */
  22146. static readonly TriangleStripDrawMode: number;
  22147. /**
  22148. * Returns the triangle fan draw mode
  22149. */
  22150. static readonly TriangleFanDrawMode: number;
  22151. /**
  22152. * Stores the clock-wise side orientation
  22153. */
  22154. static readonly ClockWiseSideOrientation: number;
  22155. /**
  22156. * Stores the counter clock-wise side orientation
  22157. */
  22158. static readonly CounterClockWiseSideOrientation: number;
  22159. /**
  22160. * The dirty texture flag value
  22161. */
  22162. static readonly TextureDirtyFlag: number;
  22163. /**
  22164. * The dirty light flag value
  22165. */
  22166. static readonly LightDirtyFlag: number;
  22167. /**
  22168. * The dirty fresnel flag value
  22169. */
  22170. static readonly FresnelDirtyFlag: number;
  22171. /**
  22172. * The dirty attribute flag value
  22173. */
  22174. static readonly AttributesDirtyFlag: number;
  22175. /**
  22176. * The dirty misc flag value
  22177. */
  22178. static readonly MiscDirtyFlag: number;
  22179. /**
  22180. * The all dirty flag value
  22181. */
  22182. static readonly AllDirtyFlag: number;
  22183. /**
  22184. * The ID of the material
  22185. */
  22186. id: string;
  22187. /**
  22188. * Gets or sets the unique id of the material
  22189. */
  22190. uniqueId: number;
  22191. /**
  22192. * The name of the material
  22193. */
  22194. name: string;
  22195. /**
  22196. * Gets or sets user defined metadata
  22197. */
  22198. metadata: any;
  22199. /**
  22200. * For internal use only. Please do not use.
  22201. */
  22202. reservedDataStore: any;
  22203. /**
  22204. * Specifies if the ready state should be checked on each call
  22205. */
  22206. checkReadyOnEveryCall: boolean;
  22207. /**
  22208. * Specifies if the ready state should be checked once
  22209. */
  22210. checkReadyOnlyOnce: boolean;
  22211. /**
  22212. * The state of the material
  22213. */
  22214. state: string;
  22215. /**
  22216. * The alpha value of the material
  22217. */
  22218. protected _alpha: number;
  22219. /**
  22220. * List of inspectable custom properties (used by the Inspector)
  22221. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22222. */
  22223. inspectableCustomProperties: IInspectable[];
  22224. /**
  22225. * Sets the alpha value of the material
  22226. */
  22227. /**
  22228. * Gets the alpha value of the material
  22229. */
  22230. alpha: number;
  22231. /**
  22232. * Specifies if back face culling is enabled
  22233. */
  22234. protected _backFaceCulling: boolean;
  22235. /**
  22236. * Sets the back-face culling state
  22237. */
  22238. /**
  22239. * Gets the back-face culling state
  22240. */
  22241. backFaceCulling: boolean;
  22242. /**
  22243. * Stores the value for side orientation
  22244. */
  22245. sideOrientation: number;
  22246. /**
  22247. * Callback triggered when the material is compiled
  22248. */
  22249. onCompiled: (effect: Effect) => void;
  22250. /**
  22251. * Callback triggered when an error occurs
  22252. */
  22253. onError: (effect: Effect, errors: string) => void;
  22254. /**
  22255. * Callback triggered to get the render target textures
  22256. */
  22257. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22258. /**
  22259. * Gets a boolean indicating that current material needs to register RTT
  22260. */
  22261. readonly hasRenderTargetTextures: boolean;
  22262. /**
  22263. * Specifies if the material should be serialized
  22264. */
  22265. doNotSerialize: boolean;
  22266. /**
  22267. * @hidden
  22268. */
  22269. _storeEffectOnSubMeshes: boolean;
  22270. /**
  22271. * Stores the animations for the material
  22272. */
  22273. animations: Array<Animation>;
  22274. /**
  22275. * An event triggered when the material is disposed
  22276. */
  22277. onDisposeObservable: Observable<Material>;
  22278. /**
  22279. * An observer which watches for dispose events
  22280. */
  22281. private _onDisposeObserver;
  22282. private _onUnBindObservable;
  22283. /**
  22284. * Called during a dispose event
  22285. */
  22286. onDispose: () => void;
  22287. private _onBindObservable;
  22288. /**
  22289. * An event triggered when the material is bound
  22290. */
  22291. readonly onBindObservable: Observable<AbstractMesh>;
  22292. /**
  22293. * An observer which watches for bind events
  22294. */
  22295. private _onBindObserver;
  22296. /**
  22297. * Called during a bind event
  22298. */
  22299. onBind: (Mesh: AbstractMesh) => void;
  22300. /**
  22301. * An event triggered when the material is unbound
  22302. */
  22303. readonly onUnBindObservable: Observable<Material>;
  22304. /**
  22305. * Stores the value of the alpha mode
  22306. */
  22307. private _alphaMode;
  22308. /**
  22309. * Sets the value of the alpha mode.
  22310. *
  22311. * | Value | Type | Description |
  22312. * | --- | --- | --- |
  22313. * | 0 | ALPHA_DISABLE | |
  22314. * | 1 | ALPHA_ADD | |
  22315. * | 2 | ALPHA_COMBINE | |
  22316. * | 3 | ALPHA_SUBTRACT | |
  22317. * | 4 | ALPHA_MULTIPLY | |
  22318. * | 5 | ALPHA_MAXIMIZED | |
  22319. * | 6 | ALPHA_ONEONE | |
  22320. * | 7 | ALPHA_PREMULTIPLIED | |
  22321. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22322. * | 9 | ALPHA_INTERPOLATE | |
  22323. * | 10 | ALPHA_SCREENMODE | |
  22324. *
  22325. */
  22326. /**
  22327. * Gets the value of the alpha mode
  22328. */
  22329. alphaMode: number;
  22330. /**
  22331. * Stores the state of the need depth pre-pass value
  22332. */
  22333. private _needDepthPrePass;
  22334. /**
  22335. * Sets the need depth pre-pass value
  22336. */
  22337. /**
  22338. * Gets the depth pre-pass value
  22339. */
  22340. needDepthPrePass: boolean;
  22341. /**
  22342. * Specifies if depth writing should be disabled
  22343. */
  22344. disableDepthWrite: boolean;
  22345. /**
  22346. * Specifies if depth writing should be forced
  22347. */
  22348. forceDepthWrite: boolean;
  22349. /**
  22350. * Specifies if there should be a separate pass for culling
  22351. */
  22352. separateCullingPass: boolean;
  22353. /**
  22354. * Stores the state specifing if fog should be enabled
  22355. */
  22356. private _fogEnabled;
  22357. /**
  22358. * Sets the state for enabling fog
  22359. */
  22360. /**
  22361. * Gets the value of the fog enabled state
  22362. */
  22363. fogEnabled: boolean;
  22364. /**
  22365. * Stores the size of points
  22366. */
  22367. pointSize: number;
  22368. /**
  22369. * Stores the z offset value
  22370. */
  22371. zOffset: number;
  22372. /**
  22373. * Gets a value specifying if wireframe mode is enabled
  22374. */
  22375. /**
  22376. * Sets the state of wireframe mode
  22377. */
  22378. wireframe: boolean;
  22379. /**
  22380. * Gets the value specifying if point clouds are enabled
  22381. */
  22382. /**
  22383. * Sets the state of point cloud mode
  22384. */
  22385. pointsCloud: boolean;
  22386. /**
  22387. * Gets the material fill mode
  22388. */
  22389. /**
  22390. * Sets the material fill mode
  22391. */
  22392. fillMode: number;
  22393. /**
  22394. * @hidden
  22395. * Stores the effects for the material
  22396. */
  22397. _effect: Nullable<Effect>;
  22398. /**
  22399. * @hidden
  22400. * Specifies if the material was previously ready
  22401. */
  22402. _wasPreviouslyReady: boolean;
  22403. /**
  22404. * Specifies if uniform buffers should be used
  22405. */
  22406. private _useUBO;
  22407. /**
  22408. * Stores a reference to the scene
  22409. */
  22410. private _scene;
  22411. /**
  22412. * Stores the fill mode state
  22413. */
  22414. private _fillMode;
  22415. /**
  22416. * Specifies if the depth write state should be cached
  22417. */
  22418. private _cachedDepthWriteState;
  22419. /**
  22420. * Stores the uniform buffer
  22421. */
  22422. protected _uniformBuffer: UniformBuffer;
  22423. /** @hidden */
  22424. _indexInSceneMaterialArray: number;
  22425. /** @hidden */
  22426. meshMap: Nullable<{
  22427. [id: string]: AbstractMesh | undefined;
  22428. }>;
  22429. /**
  22430. * Creates a material instance
  22431. * @param name defines the name of the material
  22432. * @param scene defines the scene to reference
  22433. * @param doNotAdd specifies if the material should be added to the scene
  22434. */
  22435. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22436. /**
  22437. * Returns a string representation of the current material
  22438. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22439. * @returns a string with material information
  22440. */
  22441. toString(fullDetails?: boolean): string;
  22442. /**
  22443. * Gets the class name of the material
  22444. * @returns a string with the class name of the material
  22445. */
  22446. getClassName(): string;
  22447. /**
  22448. * Specifies if updates for the material been locked
  22449. */
  22450. readonly isFrozen: boolean;
  22451. /**
  22452. * Locks updates for the material
  22453. */
  22454. freeze(): void;
  22455. /**
  22456. * Unlocks updates for the material
  22457. */
  22458. unfreeze(): void;
  22459. /**
  22460. * Specifies if the material is ready to be used
  22461. * @param mesh defines the mesh to check
  22462. * @param useInstances specifies if instances should be used
  22463. * @returns a boolean indicating if the material is ready to be used
  22464. */
  22465. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22466. /**
  22467. * Specifies that the submesh is ready to be used
  22468. * @param mesh defines the mesh to check
  22469. * @param subMesh defines which submesh to check
  22470. * @param useInstances specifies that instances should be used
  22471. * @returns a boolean indicating that the submesh is ready or not
  22472. */
  22473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22474. /**
  22475. * Returns the material effect
  22476. * @returns the effect associated with the material
  22477. */
  22478. getEffect(): Nullable<Effect>;
  22479. /**
  22480. * Returns the current scene
  22481. * @returns a Scene
  22482. */
  22483. getScene(): Scene;
  22484. /**
  22485. * Specifies if the material will require alpha blending
  22486. * @returns a boolean specifying if alpha blending is needed
  22487. */
  22488. needAlphaBlending(): boolean;
  22489. /**
  22490. * Specifies if the mesh will require alpha blending
  22491. * @param mesh defines the mesh to check
  22492. * @returns a boolean specifying if alpha blending is needed for the mesh
  22493. */
  22494. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22495. /**
  22496. * Specifies if this material should be rendered in alpha test mode
  22497. * @returns a boolean specifying if an alpha test is needed.
  22498. */
  22499. needAlphaTesting(): boolean;
  22500. /**
  22501. * Gets the texture used for the alpha test
  22502. * @returns the texture to use for alpha testing
  22503. */
  22504. getAlphaTestTexture(): Nullable<BaseTexture>;
  22505. /**
  22506. * Marks the material to indicate that it needs to be re-calculated
  22507. */
  22508. markDirty(): void;
  22509. /** @hidden */
  22510. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22511. /**
  22512. * Binds the material to the mesh
  22513. * @param world defines the world transformation matrix
  22514. * @param mesh defines the mesh to bind the material to
  22515. */
  22516. bind(world: Matrix, mesh?: Mesh): void;
  22517. /**
  22518. * Binds the submesh to the material
  22519. * @param world defines the world transformation matrix
  22520. * @param mesh defines the mesh containing the submesh
  22521. * @param subMesh defines the submesh to bind the material to
  22522. */
  22523. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22524. /**
  22525. * Binds the world matrix to the material
  22526. * @param world defines the world transformation matrix
  22527. */
  22528. bindOnlyWorldMatrix(world: Matrix): void;
  22529. /**
  22530. * Binds the scene's uniform buffer to the effect.
  22531. * @param effect defines the effect to bind to the scene uniform buffer
  22532. * @param sceneUbo defines the uniform buffer storing scene data
  22533. */
  22534. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22535. /**
  22536. * Binds the view matrix to the effect
  22537. * @param effect defines the effect to bind the view matrix to
  22538. */
  22539. bindView(effect: Effect): void;
  22540. /**
  22541. * Binds the view projection matrix to the effect
  22542. * @param effect defines the effect to bind the view projection matrix to
  22543. */
  22544. bindViewProjection(effect: Effect): void;
  22545. /**
  22546. * Specifies if material alpha testing should be turned on for the mesh
  22547. * @param mesh defines the mesh to check
  22548. */
  22549. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22550. /**
  22551. * Processes to execute after binding the material to a mesh
  22552. * @param mesh defines the rendered mesh
  22553. */
  22554. protected _afterBind(mesh?: Mesh): void;
  22555. /**
  22556. * Unbinds the material from the mesh
  22557. */
  22558. unbind(): void;
  22559. /**
  22560. * Gets the active textures from the material
  22561. * @returns an array of textures
  22562. */
  22563. getActiveTextures(): BaseTexture[];
  22564. /**
  22565. * Specifies if the material uses a texture
  22566. * @param texture defines the texture to check against the material
  22567. * @returns a boolean specifying if the material uses the texture
  22568. */
  22569. hasTexture(texture: BaseTexture): boolean;
  22570. /**
  22571. * Makes a duplicate of the material, and gives it a new name
  22572. * @param name defines the new name for the duplicated material
  22573. * @returns the cloned material
  22574. */
  22575. clone(name: string): Nullable<Material>;
  22576. /**
  22577. * Gets the meshes bound to the material
  22578. * @returns an array of meshes bound to the material
  22579. */
  22580. getBindedMeshes(): AbstractMesh[];
  22581. /**
  22582. * Force shader compilation
  22583. * @param mesh defines the mesh associated with this material
  22584. * @param onCompiled defines a function to execute once the material is compiled
  22585. * @param options defines the options to configure the compilation
  22586. */
  22587. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22588. clipPlane: boolean;
  22589. }>): void;
  22590. /**
  22591. * Force shader compilation
  22592. * @param mesh defines the mesh that will use this material
  22593. * @param options defines additional options for compiling the shaders
  22594. * @returns a promise that resolves when the compilation completes
  22595. */
  22596. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22597. clipPlane: boolean;
  22598. }>): Promise<void>;
  22599. private static readonly _ImageProcessingDirtyCallBack;
  22600. private static readonly _TextureDirtyCallBack;
  22601. private static readonly _FresnelDirtyCallBack;
  22602. private static readonly _MiscDirtyCallBack;
  22603. private static readonly _LightsDirtyCallBack;
  22604. private static readonly _AttributeDirtyCallBack;
  22605. private static _FresnelAndMiscDirtyCallBack;
  22606. private static _TextureAndMiscDirtyCallBack;
  22607. private static readonly _DirtyCallbackArray;
  22608. private static readonly _RunDirtyCallBacks;
  22609. /**
  22610. * Marks a define in the material to indicate that it needs to be re-computed
  22611. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22612. */
  22613. markAsDirty(flag: number): void;
  22614. /**
  22615. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22616. * @param func defines a function which checks material defines against the submeshes
  22617. */
  22618. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22619. /**
  22620. * Indicates that image processing needs to be re-calculated for all submeshes
  22621. */
  22622. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22623. /**
  22624. * Indicates that textures need to be re-calculated for all submeshes
  22625. */
  22626. protected _markAllSubMeshesAsTexturesDirty(): void;
  22627. /**
  22628. * Indicates that fresnel needs to be re-calculated for all submeshes
  22629. */
  22630. protected _markAllSubMeshesAsFresnelDirty(): void;
  22631. /**
  22632. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22633. */
  22634. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22635. /**
  22636. * Indicates that lights need to be re-calculated for all submeshes
  22637. */
  22638. protected _markAllSubMeshesAsLightsDirty(): void;
  22639. /**
  22640. * Indicates that attributes need to be re-calculated for all submeshes
  22641. */
  22642. protected _markAllSubMeshesAsAttributesDirty(): void;
  22643. /**
  22644. * Indicates that misc needs to be re-calculated for all submeshes
  22645. */
  22646. protected _markAllSubMeshesAsMiscDirty(): void;
  22647. /**
  22648. * Indicates that textures and misc need to be re-calculated for all submeshes
  22649. */
  22650. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22651. /**
  22652. * Disposes the material
  22653. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22654. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22655. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22656. */
  22657. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22658. /** @hidden */
  22659. private releaseVertexArrayObject;
  22660. /**
  22661. * Serializes this material
  22662. * @returns the serialized material object
  22663. */
  22664. serialize(): any;
  22665. /**
  22666. * Creates a material from parsed material data
  22667. * @param parsedMaterial defines parsed material data
  22668. * @param scene defines the hosting scene
  22669. * @param rootUrl defines the root URL to use to load textures
  22670. * @returns a new material
  22671. */
  22672. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22673. }
  22674. }
  22675. declare module "babylonjs/Meshes/subMesh" {
  22676. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22677. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22678. import { Engine } from "babylonjs/Engines/engine";
  22679. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22680. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22681. import { Effect } from "babylonjs/Materials/effect";
  22682. import { Collider } from "babylonjs/Collisions/collider";
  22683. import { Material } from "babylonjs/Materials/material";
  22684. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22686. import { Mesh } from "babylonjs/Meshes/mesh";
  22687. import { Ray } from "babylonjs/Culling/ray";
  22688. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22689. /**
  22690. * Base class for submeshes
  22691. */
  22692. export class BaseSubMesh {
  22693. /** @hidden */
  22694. _materialDefines: Nullable<MaterialDefines>;
  22695. /** @hidden */
  22696. _materialEffect: Nullable<Effect>;
  22697. /**
  22698. * Gets associated effect
  22699. */
  22700. readonly effect: Nullable<Effect>;
  22701. /**
  22702. * Sets associated effect (effect used to render this submesh)
  22703. * @param effect defines the effect to associate with
  22704. * @param defines defines the set of defines used to compile this effect
  22705. */
  22706. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22707. }
  22708. /**
  22709. * Defines a subdivision inside a mesh
  22710. */
  22711. export class SubMesh extends BaseSubMesh implements ICullable {
  22712. /** the material index to use */
  22713. materialIndex: number;
  22714. /** vertex index start */
  22715. verticesStart: number;
  22716. /** vertices count */
  22717. verticesCount: number;
  22718. /** index start */
  22719. indexStart: number;
  22720. /** indices count */
  22721. indexCount: number;
  22722. /** @hidden */
  22723. _linesIndexCount: number;
  22724. private _mesh;
  22725. private _renderingMesh;
  22726. private _boundingInfo;
  22727. private _linesIndexBuffer;
  22728. /** @hidden */
  22729. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22730. /** @hidden */
  22731. _trianglePlanes: Plane[];
  22732. /** @hidden */
  22733. _lastColliderTransformMatrix: Matrix;
  22734. /** @hidden */
  22735. _renderId: number;
  22736. /** @hidden */
  22737. _alphaIndex: number;
  22738. /** @hidden */
  22739. _distanceToCamera: number;
  22740. /** @hidden */
  22741. _id: number;
  22742. private _currentMaterial;
  22743. /**
  22744. * Add a new submesh to a mesh
  22745. * @param materialIndex defines the material index to use
  22746. * @param verticesStart defines vertex index start
  22747. * @param verticesCount defines vertices count
  22748. * @param indexStart defines index start
  22749. * @param indexCount defines indices count
  22750. * @param mesh defines the parent mesh
  22751. * @param renderingMesh defines an optional rendering mesh
  22752. * @param createBoundingBox defines if bounding box should be created for this submesh
  22753. * @returns the new submesh
  22754. */
  22755. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22756. /**
  22757. * Creates a new submesh
  22758. * @param materialIndex defines the material index to use
  22759. * @param verticesStart defines vertex index start
  22760. * @param verticesCount defines vertices count
  22761. * @param indexStart defines index start
  22762. * @param indexCount defines indices count
  22763. * @param mesh defines the parent mesh
  22764. * @param renderingMesh defines an optional rendering mesh
  22765. * @param createBoundingBox defines if bounding box should be created for this submesh
  22766. */
  22767. constructor(
  22768. /** the material index to use */
  22769. materialIndex: number,
  22770. /** vertex index start */
  22771. verticesStart: number,
  22772. /** vertices count */
  22773. verticesCount: number,
  22774. /** index start */
  22775. indexStart: number,
  22776. /** indices count */
  22777. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22778. /**
  22779. * Returns true if this submesh covers the entire parent mesh
  22780. * @ignorenaming
  22781. */
  22782. readonly IsGlobal: boolean;
  22783. /**
  22784. * Returns the submesh BoudingInfo object
  22785. * @returns current bounding info (or mesh's one if the submesh is global)
  22786. */
  22787. getBoundingInfo(): BoundingInfo;
  22788. /**
  22789. * Sets the submesh BoundingInfo
  22790. * @param boundingInfo defines the new bounding info to use
  22791. * @returns the SubMesh
  22792. */
  22793. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22794. /**
  22795. * Returns the mesh of the current submesh
  22796. * @return the parent mesh
  22797. */
  22798. getMesh(): AbstractMesh;
  22799. /**
  22800. * Returns the rendering mesh of the submesh
  22801. * @returns the rendering mesh (could be different from parent mesh)
  22802. */
  22803. getRenderingMesh(): Mesh;
  22804. /**
  22805. * Returns the submesh material
  22806. * @returns null or the current material
  22807. */
  22808. getMaterial(): Nullable<Material>;
  22809. /**
  22810. * Sets a new updated BoundingInfo object to the submesh
  22811. * @returns the SubMesh
  22812. */
  22813. refreshBoundingInfo(): SubMesh;
  22814. /** @hidden */
  22815. _checkCollision(collider: Collider): boolean;
  22816. /**
  22817. * Updates the submesh BoundingInfo
  22818. * @param world defines the world matrix to use to update the bounding info
  22819. * @returns the submesh
  22820. */
  22821. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22822. /**
  22823. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22824. * @param frustumPlanes defines the frustum planes
  22825. * @returns true if the submesh is intersecting with the frustum
  22826. */
  22827. isInFrustum(frustumPlanes: Plane[]): boolean;
  22828. /**
  22829. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22830. * @param frustumPlanes defines the frustum planes
  22831. * @returns true if the submesh is inside the frustum
  22832. */
  22833. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22834. /**
  22835. * Renders the submesh
  22836. * @param enableAlphaMode defines if alpha needs to be used
  22837. * @returns the submesh
  22838. */
  22839. render(enableAlphaMode: boolean): SubMesh;
  22840. /**
  22841. * @hidden
  22842. */
  22843. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22844. /**
  22845. * Checks if the submesh intersects with a ray
  22846. * @param ray defines the ray to test
  22847. * @returns true is the passed ray intersects the submesh bounding box
  22848. */
  22849. canIntersects(ray: Ray): boolean;
  22850. /**
  22851. * Intersects current submesh with a ray
  22852. * @param ray defines the ray to test
  22853. * @param positions defines mesh's positions array
  22854. * @param indices defines mesh's indices array
  22855. * @param fastCheck defines if only bounding info should be used
  22856. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22857. * @returns intersection info or null if no intersection
  22858. */
  22859. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22860. /** @hidden */
  22861. private _intersectLines;
  22862. /** @hidden */
  22863. private _intersectTriangles;
  22864. /** @hidden */
  22865. _rebuild(): void;
  22866. /**
  22867. * Creates a new submesh from the passed mesh
  22868. * @param newMesh defines the new hosting mesh
  22869. * @param newRenderingMesh defines an optional rendering mesh
  22870. * @returns the new submesh
  22871. */
  22872. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22873. /**
  22874. * Release associated resources
  22875. */
  22876. dispose(): void;
  22877. /**
  22878. * Gets the class name
  22879. * @returns the string "SubMesh".
  22880. */
  22881. getClassName(): string;
  22882. /**
  22883. * Creates a new submesh from indices data
  22884. * @param materialIndex the index of the main mesh material
  22885. * @param startIndex the index where to start the copy in the mesh indices array
  22886. * @param indexCount the number of indices to copy then from the startIndex
  22887. * @param mesh the main mesh to create the submesh from
  22888. * @param renderingMesh the optional rendering mesh
  22889. * @returns a new submesh
  22890. */
  22891. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22892. }
  22893. }
  22894. declare module "babylonjs/Meshes/geometry" {
  22895. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22896. import { Scene } from "babylonjs/scene";
  22897. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22898. import { Engine } from "babylonjs/Engines/engine";
  22899. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22900. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22901. import { Effect } from "babylonjs/Materials/effect";
  22902. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22903. import { Mesh } from "babylonjs/Meshes/mesh";
  22904. /**
  22905. * Class used to store geometry data (vertex buffers + index buffer)
  22906. */
  22907. export class Geometry implements IGetSetVerticesData {
  22908. /**
  22909. * Gets or sets the ID of the geometry
  22910. */
  22911. id: string;
  22912. /**
  22913. * Gets or sets the unique ID of the geometry
  22914. */
  22915. uniqueId: number;
  22916. /**
  22917. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22918. */
  22919. delayLoadState: number;
  22920. /**
  22921. * Gets the file containing the data to load when running in delay load state
  22922. */
  22923. delayLoadingFile: Nullable<string>;
  22924. /**
  22925. * Callback called when the geometry is updated
  22926. */
  22927. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22928. private _scene;
  22929. private _engine;
  22930. private _meshes;
  22931. private _totalVertices;
  22932. /** @hidden */
  22933. _indices: IndicesArray;
  22934. /** @hidden */
  22935. _vertexBuffers: {
  22936. [key: string]: VertexBuffer;
  22937. };
  22938. private _isDisposed;
  22939. private _extend;
  22940. private _boundingBias;
  22941. /** @hidden */
  22942. _delayInfo: Array<string>;
  22943. private _indexBuffer;
  22944. private _indexBufferIsUpdatable;
  22945. /** @hidden */
  22946. _boundingInfo: Nullable<BoundingInfo>;
  22947. /** @hidden */
  22948. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22949. /** @hidden */
  22950. _softwareSkinningFrameId: number;
  22951. private _vertexArrayObjects;
  22952. private _updatable;
  22953. /** @hidden */
  22954. _positions: Nullable<Vector3[]>;
  22955. /**
  22956. * 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
  22957. */
  22958. /**
  22959. * 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
  22960. */
  22961. boundingBias: Vector2;
  22962. /**
  22963. * Static function used to attach a new empty geometry to a mesh
  22964. * @param mesh defines the mesh to attach the geometry to
  22965. * @returns the new Geometry
  22966. */
  22967. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22968. /**
  22969. * Creates a new geometry
  22970. * @param id defines the unique ID
  22971. * @param scene defines the hosting scene
  22972. * @param vertexData defines the VertexData used to get geometry data
  22973. * @param updatable defines if geometry must be updatable (false by default)
  22974. * @param mesh defines the mesh that will be associated with the geometry
  22975. */
  22976. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22977. /**
  22978. * Gets the current extend of the geometry
  22979. */
  22980. readonly extend: {
  22981. minimum: Vector3;
  22982. maximum: Vector3;
  22983. };
  22984. /**
  22985. * Gets the hosting scene
  22986. * @returns the hosting Scene
  22987. */
  22988. getScene(): Scene;
  22989. /**
  22990. * Gets the hosting engine
  22991. * @returns the hosting Engine
  22992. */
  22993. getEngine(): Engine;
  22994. /**
  22995. * Defines if the geometry is ready to use
  22996. * @returns true if the geometry is ready to be used
  22997. */
  22998. isReady(): boolean;
  22999. /**
  23000. * Gets a value indicating that the geometry should not be serialized
  23001. */
  23002. readonly doNotSerialize: boolean;
  23003. /** @hidden */
  23004. _rebuild(): void;
  23005. /**
  23006. * Affects all geometry data in one call
  23007. * @param vertexData defines the geometry data
  23008. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23009. */
  23010. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23011. /**
  23012. * Set specific vertex data
  23013. * @param kind defines the data kind (Position, normal, etc...)
  23014. * @param data defines the vertex data to use
  23015. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23016. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23017. */
  23018. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23019. /**
  23020. * Removes a specific vertex data
  23021. * @param kind defines the data kind (Position, normal, etc...)
  23022. */
  23023. removeVerticesData(kind: string): void;
  23024. /**
  23025. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23026. * @param buffer defines the vertex buffer to use
  23027. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23028. */
  23029. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23030. /**
  23031. * Update a specific vertex buffer
  23032. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23033. * It will do nothing if the buffer is not updatable
  23034. * @param kind defines the data kind (Position, normal, etc...)
  23035. * @param data defines the data to use
  23036. * @param offset defines the offset in the target buffer where to store the data
  23037. * @param useBytes set to true if the offset is in bytes
  23038. */
  23039. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23040. /**
  23041. * Update a specific vertex buffer
  23042. * This function will create a new buffer if the current one is not updatable
  23043. * @param kind defines the data kind (Position, normal, etc...)
  23044. * @param data defines the data to use
  23045. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23046. */
  23047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23048. private _updateBoundingInfo;
  23049. /** @hidden */
  23050. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23051. /**
  23052. * Gets total number of vertices
  23053. * @returns the total number of vertices
  23054. */
  23055. getTotalVertices(): number;
  23056. /**
  23057. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23058. * @param kind defines the data kind (Position, normal, etc...)
  23059. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23060. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23061. * @returns a float array containing vertex data
  23062. */
  23063. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23064. /**
  23065. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23066. * @param kind defines the data kind (Position, normal, etc...)
  23067. * @returns true if the vertex buffer with the specified kind is updatable
  23068. */
  23069. isVertexBufferUpdatable(kind: string): boolean;
  23070. /**
  23071. * Gets a specific vertex buffer
  23072. * @param kind defines the data kind (Position, normal, etc...)
  23073. * @returns a VertexBuffer
  23074. */
  23075. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23076. /**
  23077. * Returns all vertex buffers
  23078. * @return an object holding all vertex buffers indexed by kind
  23079. */
  23080. getVertexBuffers(): Nullable<{
  23081. [key: string]: VertexBuffer;
  23082. }>;
  23083. /**
  23084. * Gets a boolean indicating if specific vertex buffer is present
  23085. * @param kind defines the data kind (Position, normal, etc...)
  23086. * @returns true if data is present
  23087. */
  23088. isVerticesDataPresent(kind: string): boolean;
  23089. /**
  23090. * Gets a list of all attached data kinds (Position, normal, etc...)
  23091. * @returns a list of string containing all kinds
  23092. */
  23093. getVerticesDataKinds(): string[];
  23094. /**
  23095. * Update index buffer
  23096. * @param indices defines the indices to store in the index buffer
  23097. * @param offset defines the offset in the target buffer where to store the data
  23098. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  23099. */
  23100. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23101. /**
  23102. * Creates a new index buffer
  23103. * @param indices defines the indices to store in the index buffer
  23104. * @param totalVertices defines the total number of vertices (could be null)
  23105. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23106. */
  23107. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23108. /**
  23109. * Return the total number of indices
  23110. * @returns the total number of indices
  23111. */
  23112. getTotalIndices(): number;
  23113. /**
  23114. * Gets the index buffer array
  23115. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23117. * @returns the index buffer array
  23118. */
  23119. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23120. /**
  23121. * Gets the index buffer
  23122. * @return the index buffer
  23123. */
  23124. getIndexBuffer(): Nullable<WebGLBuffer>;
  23125. /** @hidden */
  23126. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23127. /**
  23128. * Release the associated resources for a specific mesh
  23129. * @param mesh defines the source mesh
  23130. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23131. */
  23132. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23133. /**
  23134. * Apply current geometry to a given mesh
  23135. * @param mesh defines the mesh to apply geometry to
  23136. */
  23137. applyToMesh(mesh: Mesh): void;
  23138. private _updateExtend;
  23139. private _applyToMesh;
  23140. private notifyUpdate;
  23141. /**
  23142. * Load the geometry if it was flagged as delay loaded
  23143. * @param scene defines the hosting scene
  23144. * @param onLoaded defines a callback called when the geometry is loaded
  23145. */
  23146. load(scene: Scene, onLoaded?: () => void): void;
  23147. private _queueLoad;
  23148. /**
  23149. * Invert the geometry to move from a right handed system to a left handed one.
  23150. */
  23151. toLeftHanded(): void;
  23152. /** @hidden */
  23153. _resetPointsArrayCache(): void;
  23154. /** @hidden */
  23155. _generatePointsArray(): boolean;
  23156. /**
  23157. * Gets a value indicating if the geometry is disposed
  23158. * @returns true if the geometry was disposed
  23159. */
  23160. isDisposed(): boolean;
  23161. private _disposeVertexArrayObjects;
  23162. /**
  23163. * Free all associated resources
  23164. */
  23165. dispose(): void;
  23166. /**
  23167. * Clone the current geometry into a new geometry
  23168. * @param id defines the unique ID of the new geometry
  23169. * @returns a new geometry object
  23170. */
  23171. copy(id: string): Geometry;
  23172. /**
  23173. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23174. * @return a JSON representation of the current geometry data (without the vertices data)
  23175. */
  23176. serialize(): any;
  23177. private toNumberArray;
  23178. /**
  23179. * Serialize all vertices data into a JSON oject
  23180. * @returns a JSON representation of the current geometry data
  23181. */
  23182. serializeVerticeData(): any;
  23183. /**
  23184. * Extracts a clone of a mesh geometry
  23185. * @param mesh defines the source mesh
  23186. * @param id defines the unique ID of the new geometry object
  23187. * @returns the new geometry object
  23188. */
  23189. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23190. /**
  23191. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23192. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23193. * Be aware Math.random() could cause collisions, but:
  23194. * "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"
  23195. * @returns a string containing a new GUID
  23196. */
  23197. static RandomId(): string;
  23198. /** @hidden */
  23199. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23200. private static _CleanMatricesWeights;
  23201. /**
  23202. * Create a new geometry from persisted data (Using .babylon file format)
  23203. * @param parsedVertexData defines the persisted data
  23204. * @param scene defines the hosting scene
  23205. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23206. * @returns the new geometry object
  23207. */
  23208. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23209. }
  23210. }
  23211. declare module "babylonjs/Meshes/mesh.vertexData" {
  23212. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23213. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23214. import { Geometry } from "babylonjs/Meshes/geometry";
  23215. import { Mesh } from "babylonjs/Meshes/mesh";
  23216. /**
  23217. * Define an interface for all classes that will get and set the data on vertices
  23218. */
  23219. export interface IGetSetVerticesData {
  23220. /**
  23221. * Gets a boolean indicating if specific vertex data is present
  23222. * @param kind defines the vertex data kind to use
  23223. * @returns true is data kind is present
  23224. */
  23225. isVerticesDataPresent(kind: string): boolean;
  23226. /**
  23227. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23228. * @param kind defines the data kind (Position, normal, etc...)
  23229. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23230. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23231. * @returns a float array containing vertex data
  23232. */
  23233. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23234. /**
  23235. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23236. * @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.
  23237. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23238. * @returns the indices array or an empty array if the mesh has no geometry
  23239. */
  23240. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23241. /**
  23242. * Set specific vertex data
  23243. * @param kind defines the data kind (Position, normal, etc...)
  23244. * @param data defines the vertex data to use
  23245. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23246. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23247. */
  23248. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23249. /**
  23250. * Update a specific associated vertex buffer
  23251. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23252. * - VertexBuffer.PositionKind
  23253. * - VertexBuffer.UVKind
  23254. * - VertexBuffer.UV2Kind
  23255. * - VertexBuffer.UV3Kind
  23256. * - VertexBuffer.UV4Kind
  23257. * - VertexBuffer.UV5Kind
  23258. * - VertexBuffer.UV6Kind
  23259. * - VertexBuffer.ColorKind
  23260. * - VertexBuffer.MatricesIndicesKind
  23261. * - VertexBuffer.MatricesIndicesExtraKind
  23262. * - VertexBuffer.MatricesWeightsKind
  23263. * - VertexBuffer.MatricesWeightsExtraKind
  23264. * @param data defines the data source
  23265. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23266. * @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)
  23267. */
  23268. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23269. /**
  23270. * Creates a new index buffer
  23271. * @param indices defines the indices to store in the index buffer
  23272. * @param totalVertices defines the total number of vertices (could be null)
  23273. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23274. */
  23275. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23276. }
  23277. /**
  23278. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23279. */
  23280. export class VertexData {
  23281. /**
  23282. * Mesh side orientation : usually the external or front surface
  23283. */
  23284. static readonly FRONTSIDE: number;
  23285. /**
  23286. * Mesh side orientation : usually the internal or back surface
  23287. */
  23288. static readonly BACKSIDE: number;
  23289. /**
  23290. * Mesh side orientation : both internal and external or front and back surfaces
  23291. */
  23292. static readonly DOUBLESIDE: number;
  23293. /**
  23294. * Mesh side orientation : by default, `FRONTSIDE`
  23295. */
  23296. static readonly DEFAULTSIDE: number;
  23297. /**
  23298. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23299. */
  23300. positions: Nullable<FloatArray>;
  23301. /**
  23302. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23303. */
  23304. normals: Nullable<FloatArray>;
  23305. /**
  23306. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23307. */
  23308. tangents: Nullable<FloatArray>;
  23309. /**
  23310. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23311. */
  23312. uvs: Nullable<FloatArray>;
  23313. /**
  23314. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23315. */
  23316. uvs2: Nullable<FloatArray>;
  23317. /**
  23318. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23319. */
  23320. uvs3: Nullable<FloatArray>;
  23321. /**
  23322. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23323. */
  23324. uvs4: Nullable<FloatArray>;
  23325. /**
  23326. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23327. */
  23328. uvs5: Nullable<FloatArray>;
  23329. /**
  23330. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23331. */
  23332. uvs6: Nullable<FloatArray>;
  23333. /**
  23334. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23335. */
  23336. colors: Nullable<FloatArray>;
  23337. /**
  23338. * 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).
  23339. */
  23340. matricesIndices: Nullable<FloatArray>;
  23341. /**
  23342. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23343. */
  23344. matricesWeights: Nullable<FloatArray>;
  23345. /**
  23346. * An array extending the number of possible indices
  23347. */
  23348. matricesIndicesExtra: Nullable<FloatArray>;
  23349. /**
  23350. * An array extending the number of possible weights when the number of indices is extended
  23351. */
  23352. matricesWeightsExtra: Nullable<FloatArray>;
  23353. /**
  23354. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23355. */
  23356. indices: Nullable<IndicesArray>;
  23357. /**
  23358. * Uses the passed data array to set the set the values for the specified kind of data
  23359. * @param data a linear array of floating numbers
  23360. * @param kind the type of data that is being set, eg positions, colors etc
  23361. */
  23362. set(data: FloatArray, kind: string): void;
  23363. /**
  23364. * Associates the vertexData to the passed Mesh.
  23365. * Sets it as updatable or not (default `false`)
  23366. * @param mesh the mesh the vertexData is applied to
  23367. * @param updatable when used and having the value true allows new data to update the vertexData
  23368. * @returns the VertexData
  23369. */
  23370. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23371. /**
  23372. * Associates the vertexData to the passed Geometry.
  23373. * Sets it as updatable or not (default `false`)
  23374. * @param geometry the geometry the vertexData is applied to
  23375. * @param updatable when used and having the value true allows new data to update the vertexData
  23376. * @returns VertexData
  23377. */
  23378. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23379. /**
  23380. * Updates the associated mesh
  23381. * @param mesh the mesh to be updated
  23382. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23383. * @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
  23384. * @returns VertexData
  23385. */
  23386. updateMesh(mesh: Mesh): VertexData;
  23387. /**
  23388. * Updates the associated geometry
  23389. * @param geometry the geometry to be updated
  23390. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23391. * @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
  23392. * @returns VertexData.
  23393. */
  23394. updateGeometry(geometry: Geometry): VertexData;
  23395. private _applyTo;
  23396. private _update;
  23397. /**
  23398. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23399. * @param matrix the transforming matrix
  23400. * @returns the VertexData
  23401. */
  23402. transform(matrix: Matrix): VertexData;
  23403. /**
  23404. * Merges the passed VertexData into the current one
  23405. * @param other the VertexData to be merged into the current one
  23406. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23407. * @returns the modified VertexData
  23408. */
  23409. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23410. private _mergeElement;
  23411. private _validate;
  23412. /**
  23413. * Serializes the VertexData
  23414. * @returns a serialized object
  23415. */
  23416. serialize(): any;
  23417. /**
  23418. * Extracts the vertexData from a mesh
  23419. * @param mesh the mesh from which to extract the VertexData
  23420. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23421. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23422. * @returns the object VertexData associated to the passed mesh
  23423. */
  23424. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23425. /**
  23426. * Extracts the vertexData from the geometry
  23427. * @param geometry the geometry from which to extract the VertexData
  23428. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23429. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23430. * @returns the object VertexData associated to the passed mesh
  23431. */
  23432. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23433. private static _ExtractFrom;
  23434. /**
  23435. * Creates the VertexData for a Ribbon
  23436. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23437. * * pathArray array of paths, each of which an array of successive Vector3
  23438. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23439. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23440. * * 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
  23441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23442. * * 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)
  23443. * * 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)
  23444. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23445. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23446. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23447. * @returns the VertexData of the ribbon
  23448. */
  23449. static CreateRibbon(options: {
  23450. pathArray: Vector3[][];
  23451. closeArray?: boolean;
  23452. closePath?: boolean;
  23453. offset?: number;
  23454. sideOrientation?: number;
  23455. frontUVs?: Vector4;
  23456. backUVs?: Vector4;
  23457. invertUV?: boolean;
  23458. uvs?: Vector2[];
  23459. colors?: Color4[];
  23460. }): VertexData;
  23461. /**
  23462. * Creates the VertexData for a box
  23463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23464. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23465. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23466. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23467. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23468. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23469. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23471. * * 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)
  23472. * * 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)
  23473. * @returns the VertexData of the box
  23474. */
  23475. static CreateBox(options: {
  23476. size?: number;
  23477. width?: number;
  23478. height?: number;
  23479. depth?: number;
  23480. faceUV?: Vector4[];
  23481. faceColors?: Color4[];
  23482. sideOrientation?: number;
  23483. frontUVs?: Vector4;
  23484. backUVs?: Vector4;
  23485. }): VertexData;
  23486. /**
  23487. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23488. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23489. * * segments sets the number of horizontal strips optional, default 32
  23490. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23491. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23492. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23493. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23494. * * 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
  23495. * * 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
  23496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23497. * * 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)
  23498. * * 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)
  23499. * @returns the VertexData of the ellipsoid
  23500. */
  23501. static CreateSphere(options: {
  23502. segments?: number;
  23503. diameter?: number;
  23504. diameterX?: number;
  23505. diameterY?: number;
  23506. diameterZ?: number;
  23507. arc?: number;
  23508. slice?: number;
  23509. sideOrientation?: number;
  23510. frontUVs?: Vector4;
  23511. backUVs?: Vector4;
  23512. }): VertexData;
  23513. /**
  23514. * Creates the VertexData for a cylinder, cone or prism
  23515. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23516. * * height sets the height (y direction) of the cylinder, optional, default 2
  23517. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23518. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23519. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23520. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23521. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23522. * * 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
  23523. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23524. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23525. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23526. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23528. * * 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)
  23529. * * 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)
  23530. * @returns the VertexData of the cylinder, cone or prism
  23531. */
  23532. static CreateCylinder(options: {
  23533. height?: number;
  23534. diameterTop?: number;
  23535. diameterBottom?: number;
  23536. diameter?: number;
  23537. tessellation?: number;
  23538. subdivisions?: number;
  23539. arc?: number;
  23540. faceColors?: Color4[];
  23541. faceUV?: Vector4[];
  23542. hasRings?: boolean;
  23543. enclose?: boolean;
  23544. sideOrientation?: number;
  23545. frontUVs?: Vector4;
  23546. backUVs?: Vector4;
  23547. }): VertexData;
  23548. /**
  23549. * Creates the VertexData for a torus
  23550. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23551. * * diameter the diameter of the torus, optional default 1
  23552. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23553. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23554. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23555. * * 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)
  23556. * * 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)
  23557. * @returns the VertexData of the torus
  23558. */
  23559. static CreateTorus(options: {
  23560. diameter?: number;
  23561. thickness?: number;
  23562. tessellation?: number;
  23563. sideOrientation?: number;
  23564. frontUVs?: Vector4;
  23565. backUVs?: Vector4;
  23566. }): VertexData;
  23567. /**
  23568. * Creates the VertexData of the LineSystem
  23569. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23570. * - lines an array of lines, each line being an array of successive Vector3
  23571. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23572. * @returns the VertexData of the LineSystem
  23573. */
  23574. static CreateLineSystem(options: {
  23575. lines: Vector3[][];
  23576. colors?: Nullable<Color4[][]>;
  23577. }): VertexData;
  23578. /**
  23579. * Create the VertexData for a DashedLines
  23580. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23581. * - points an array successive Vector3
  23582. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23583. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23584. * - dashNb the intended total number of dashes, optional, default 200
  23585. * @returns the VertexData for the DashedLines
  23586. */
  23587. static CreateDashedLines(options: {
  23588. points: Vector3[];
  23589. dashSize?: number;
  23590. gapSize?: number;
  23591. dashNb?: number;
  23592. }): VertexData;
  23593. /**
  23594. * Creates the VertexData for a Ground
  23595. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23596. * - width the width (x direction) of the ground, optional, default 1
  23597. * - height the height (z direction) of the ground, optional, default 1
  23598. * - subdivisions the number of subdivisions per side, optional, default 1
  23599. * @returns the VertexData of the Ground
  23600. */
  23601. static CreateGround(options: {
  23602. width?: number;
  23603. height?: number;
  23604. subdivisions?: number;
  23605. subdivisionsX?: number;
  23606. subdivisionsY?: number;
  23607. }): VertexData;
  23608. /**
  23609. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23610. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23611. * * xmin the ground minimum X coordinate, optional, default -1
  23612. * * zmin the ground minimum Z coordinate, optional, default -1
  23613. * * xmax the ground maximum X coordinate, optional, default 1
  23614. * * zmax the ground maximum Z coordinate, optional, default 1
  23615. * * 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}
  23616. * * 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}
  23617. * @returns the VertexData of the TiledGround
  23618. */
  23619. static CreateTiledGround(options: {
  23620. xmin: number;
  23621. zmin: number;
  23622. xmax: number;
  23623. zmax: number;
  23624. subdivisions?: {
  23625. w: number;
  23626. h: number;
  23627. };
  23628. precision?: {
  23629. w: number;
  23630. h: number;
  23631. };
  23632. }): VertexData;
  23633. /**
  23634. * Creates the VertexData of the Ground designed from a heightmap
  23635. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23636. * * width the width (x direction) of the ground
  23637. * * height the height (z direction) of the ground
  23638. * * subdivisions the number of subdivisions per side
  23639. * * minHeight the minimum altitude on the ground, optional, default 0
  23640. * * maxHeight the maximum altitude on the ground, optional default 1
  23641. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23642. * * buffer the array holding the image color data
  23643. * * bufferWidth the width of image
  23644. * * bufferHeight the height of image
  23645. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23646. * @returns the VertexData of the Ground designed from a heightmap
  23647. */
  23648. static CreateGroundFromHeightMap(options: {
  23649. width: number;
  23650. height: number;
  23651. subdivisions: number;
  23652. minHeight: number;
  23653. maxHeight: number;
  23654. colorFilter: Color3;
  23655. buffer: Uint8Array;
  23656. bufferWidth: number;
  23657. bufferHeight: number;
  23658. alphaFilter: number;
  23659. }): VertexData;
  23660. /**
  23661. * Creates the VertexData for a Plane
  23662. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23663. * * size sets the width and height of the plane to the value of size, optional default 1
  23664. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23665. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23666. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23667. * * 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)
  23668. * * 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)
  23669. * @returns the VertexData of the box
  23670. */
  23671. static CreatePlane(options: {
  23672. size?: number;
  23673. width?: number;
  23674. height?: number;
  23675. sideOrientation?: number;
  23676. frontUVs?: Vector4;
  23677. backUVs?: Vector4;
  23678. }): VertexData;
  23679. /**
  23680. * Creates the VertexData of the Disc or regular Polygon
  23681. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23682. * * radius the radius of the disc, optional default 0.5
  23683. * * tessellation the number of polygon sides, optional, default 64
  23684. * * 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
  23685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23686. * * 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)
  23687. * * 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)
  23688. * @returns the VertexData of the box
  23689. */
  23690. static CreateDisc(options: {
  23691. radius?: number;
  23692. tessellation?: number;
  23693. arc?: number;
  23694. sideOrientation?: number;
  23695. frontUVs?: Vector4;
  23696. backUVs?: Vector4;
  23697. }): VertexData;
  23698. /**
  23699. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23700. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23701. * @param polygon a mesh built from polygonTriangulation.build()
  23702. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23703. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23704. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23705. * @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)
  23706. * @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)
  23707. * @returns the VertexData of the Polygon
  23708. */
  23709. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23710. /**
  23711. * Creates the VertexData of the IcoSphere
  23712. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23713. * * radius the radius of the IcoSphere, optional default 1
  23714. * * radiusX allows stretching in the x direction, optional, default radius
  23715. * * radiusY allows stretching in the y direction, optional, default radius
  23716. * * radiusZ allows stretching in the z direction, optional, default radius
  23717. * * flat when true creates a flat shaded mesh, optional, default true
  23718. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23720. * * 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)
  23721. * * 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)
  23722. * @returns the VertexData of the IcoSphere
  23723. */
  23724. static CreateIcoSphere(options: {
  23725. radius?: number;
  23726. radiusX?: number;
  23727. radiusY?: number;
  23728. radiusZ?: number;
  23729. flat?: boolean;
  23730. subdivisions?: number;
  23731. sideOrientation?: number;
  23732. frontUVs?: Vector4;
  23733. backUVs?: Vector4;
  23734. }): VertexData;
  23735. /**
  23736. * Creates the VertexData for a Polyhedron
  23737. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23738. * * type provided types are:
  23739. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23740. * * 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)
  23741. * * size the size of the IcoSphere, optional default 1
  23742. * * sizeX allows stretching in the x direction, optional, default size
  23743. * * sizeY allows stretching in the y direction, optional, default size
  23744. * * sizeZ allows stretching in the z direction, optional, default size
  23745. * * 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
  23746. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23747. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23748. * * flat when true creates a flat shaded mesh, optional, default true
  23749. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23750. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23751. * * 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)
  23752. * * 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)
  23753. * @returns the VertexData of the Polyhedron
  23754. */
  23755. static CreatePolyhedron(options: {
  23756. type?: number;
  23757. size?: number;
  23758. sizeX?: number;
  23759. sizeY?: number;
  23760. sizeZ?: number;
  23761. custom?: any;
  23762. faceUV?: Vector4[];
  23763. faceColors?: Color4[];
  23764. flat?: boolean;
  23765. sideOrientation?: number;
  23766. frontUVs?: Vector4;
  23767. backUVs?: Vector4;
  23768. }): VertexData;
  23769. /**
  23770. * Creates the VertexData for a TorusKnot
  23771. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23772. * * radius the radius of the torus knot, optional, default 2
  23773. * * tube the thickness of the tube, optional, default 0.5
  23774. * * radialSegments the number of sides on each tube segments, optional, default 32
  23775. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23776. * * p the number of windings around the z axis, optional, default 2
  23777. * * q the number of windings around the x axis, optional, default 3
  23778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23779. * * 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)
  23780. * * 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)
  23781. * @returns the VertexData of the Torus Knot
  23782. */
  23783. static CreateTorusKnot(options: {
  23784. radius?: number;
  23785. tube?: number;
  23786. radialSegments?: number;
  23787. tubularSegments?: number;
  23788. p?: number;
  23789. q?: number;
  23790. sideOrientation?: number;
  23791. frontUVs?: Vector4;
  23792. backUVs?: Vector4;
  23793. }): VertexData;
  23794. /**
  23795. * Compute normals for given positions and indices
  23796. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23797. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23798. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23799. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23800. * * facetNormals : optional array of facet normals (vector3)
  23801. * * facetPositions : optional array of facet positions (vector3)
  23802. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23803. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23804. * * bInfo : optional bounding info, required for facetPartitioning computation
  23805. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23806. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23807. * * useRightHandedSystem: optional boolean to for right handed system computation
  23808. * * depthSort : optional boolean to enable the facet depth sort computation
  23809. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23810. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23811. */
  23812. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23813. facetNormals?: any;
  23814. facetPositions?: any;
  23815. facetPartitioning?: any;
  23816. ratio?: number;
  23817. bInfo?: any;
  23818. bbSize?: Vector3;
  23819. subDiv?: any;
  23820. useRightHandedSystem?: boolean;
  23821. depthSort?: boolean;
  23822. distanceTo?: Vector3;
  23823. depthSortedFacets?: any;
  23824. }): void;
  23825. /** @hidden */
  23826. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23827. /**
  23828. * Applies VertexData created from the imported parameters to the geometry
  23829. * @param parsedVertexData the parsed data from an imported file
  23830. * @param geometry the geometry to apply the VertexData to
  23831. */
  23832. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23833. }
  23834. }
  23835. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23836. import { Nullable } from "babylonjs/types";
  23837. import { Scene } from "babylonjs/scene";
  23838. import { Vector4 } from "babylonjs/Maths/math";
  23839. import { Mesh } from "babylonjs/Meshes/mesh";
  23840. /**
  23841. * Class containing static functions to help procedurally build meshes
  23842. */
  23843. export class DiscBuilder {
  23844. /**
  23845. * Creates a plane polygonal mesh. By default, this is a disc
  23846. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23847. * * 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
  23848. * * 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
  23849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23852. * @param name defines the name of the mesh
  23853. * @param options defines the options used to create the mesh
  23854. * @param scene defines the hosting scene
  23855. * @returns the plane polygonal mesh
  23856. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23857. */
  23858. static CreateDisc(name: string, options: {
  23859. radius?: number;
  23860. tessellation?: number;
  23861. arc?: number;
  23862. updatable?: boolean;
  23863. sideOrientation?: number;
  23864. frontUVs?: Vector4;
  23865. backUVs?: Vector4;
  23866. }, scene?: Nullable<Scene>): Mesh;
  23867. }
  23868. }
  23869. declare module "babylonjs/Particles/solidParticleSystem" {
  23870. import { Vector3 } from "babylonjs/Maths/math";
  23871. import { Mesh } from "babylonjs/Meshes/mesh";
  23872. import { Scene, IDisposable } from "babylonjs/scene";
  23873. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23874. /**
  23875. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23876. *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.
  23877. * The SPS is also a particle system. It provides some methods to manage the particles.
  23878. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23879. *
  23880. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23881. */
  23882. export class SolidParticleSystem implements IDisposable {
  23883. /**
  23884. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23885. * Example : var p = SPS.particles[i];
  23886. */
  23887. particles: SolidParticle[];
  23888. /**
  23889. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23890. */
  23891. nbParticles: number;
  23892. /**
  23893. * If the particles must ever face the camera (default false). Useful for planar particles.
  23894. */
  23895. billboard: boolean;
  23896. /**
  23897. * Recompute normals when adding a shape
  23898. */
  23899. recomputeNormals: boolean;
  23900. /**
  23901. * This a counter ofr your own usage. It's not set by any SPS functions.
  23902. */
  23903. counter: number;
  23904. /**
  23905. * The SPS name. This name is also given to the underlying mesh.
  23906. */
  23907. name: string;
  23908. /**
  23909. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23910. */
  23911. mesh: Mesh;
  23912. /**
  23913. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23914. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23915. */
  23916. vars: any;
  23917. /**
  23918. * This array is populated when the SPS is set as 'pickable'.
  23919. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23920. * Each element of this array is an object `{idx: int, faceId: int}`.
  23921. * `idx` is the picked particle index in the `SPS.particles` array
  23922. * `faceId` is the picked face index counted within this particle.
  23923. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23924. */
  23925. pickedParticles: {
  23926. idx: number;
  23927. faceId: number;
  23928. }[];
  23929. /**
  23930. * This array is populated when `enableDepthSort` is set to true.
  23931. * Each element of this array is an instance of the class DepthSortedParticle.
  23932. */
  23933. depthSortedParticles: DepthSortedParticle[];
  23934. /**
  23935. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23936. * @hidden
  23937. */
  23938. _bSphereOnly: boolean;
  23939. /**
  23940. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23941. * @hidden
  23942. */
  23943. _bSphereRadiusFactor: number;
  23944. private _scene;
  23945. private _positions;
  23946. private _indices;
  23947. private _normals;
  23948. private _colors;
  23949. private _uvs;
  23950. private _indices32;
  23951. private _positions32;
  23952. private _normals32;
  23953. private _fixedNormal32;
  23954. private _colors32;
  23955. private _uvs32;
  23956. private _index;
  23957. private _updatable;
  23958. private _pickable;
  23959. private _isVisibilityBoxLocked;
  23960. private _alwaysVisible;
  23961. private _depthSort;
  23962. private _shapeCounter;
  23963. private _copy;
  23964. private _color;
  23965. private _computeParticleColor;
  23966. private _computeParticleTexture;
  23967. private _computeParticleRotation;
  23968. private _computeParticleVertex;
  23969. private _computeBoundingBox;
  23970. private _depthSortParticles;
  23971. private _camera;
  23972. private _mustUnrotateFixedNormals;
  23973. private _particlesIntersect;
  23974. private _needs32Bits;
  23975. /**
  23976. * Creates a SPS (Solid Particle System) object.
  23977. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23978. * @param scene (Scene) is the scene in which the SPS is added.
  23979. * @param options defines the options of the sps e.g.
  23980. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23981. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23982. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23983. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23984. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23985. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23986. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23987. */
  23988. constructor(name: string, scene: Scene, options?: {
  23989. updatable?: boolean;
  23990. isPickable?: boolean;
  23991. enableDepthSort?: boolean;
  23992. particleIntersection?: boolean;
  23993. boundingSphereOnly?: boolean;
  23994. bSphereRadiusFactor?: number;
  23995. });
  23996. /**
  23997. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23998. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23999. * @returns the created mesh
  24000. */
  24001. buildMesh(): Mesh;
  24002. /**
  24003. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24004. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24005. * Thus the particles generated from `digest()` have their property `position` set yet.
  24006. * @param mesh ( Mesh ) is the mesh to be digested
  24007. * @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
  24008. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24009. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24010. * @returns the current SPS
  24011. */
  24012. digest(mesh: Mesh, options?: {
  24013. facetNb?: number;
  24014. number?: number;
  24015. delta?: number;
  24016. }): SolidParticleSystem;
  24017. private _unrotateFixedNormals;
  24018. private _resetCopy;
  24019. private _meshBuilder;
  24020. private _posToShape;
  24021. private _uvsToShapeUV;
  24022. private _addParticle;
  24023. /**
  24024. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24025. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24026. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24027. * @param nb (positive integer) the number of particles to be created from this model
  24028. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24029. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24030. * @returns the number of shapes in the system
  24031. */
  24032. addShape(mesh: Mesh, nb: number, options?: {
  24033. positionFunction?: any;
  24034. vertexFunction?: any;
  24035. }): number;
  24036. private _rebuildParticle;
  24037. /**
  24038. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24039. * @returns the SPS.
  24040. */
  24041. rebuildMesh(): SolidParticleSystem;
  24042. /**
  24043. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24044. * This method calls `updateParticle()` for each particle of the SPS.
  24045. * For an animated SPS, it is usually called within the render loop.
  24046. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24047. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24048. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24049. * @returns the SPS.
  24050. */
  24051. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24052. /**
  24053. * Disposes the SPS.
  24054. */
  24055. dispose(): void;
  24056. /**
  24057. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24058. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24059. * @returns the SPS.
  24060. */
  24061. refreshVisibleSize(): SolidParticleSystem;
  24062. /**
  24063. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24064. * @param size the size (float) of the visibility box
  24065. * note : this doesn't lock the SPS mesh bounding box.
  24066. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24067. */
  24068. setVisibilityBox(size: number): void;
  24069. /**
  24070. * Gets whether the SPS as always visible or not
  24071. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24072. */
  24073. /**
  24074. * Sets the SPS as always visible or not
  24075. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24076. */
  24077. isAlwaysVisible: boolean;
  24078. /**
  24079. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24080. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24081. */
  24082. /**
  24083. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24084. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24085. */
  24086. isVisibilityBoxLocked: boolean;
  24087. /**
  24088. * Tells to `setParticles()` to compute the particle rotations or not.
  24089. * Default value : true. The SPS is faster when it's set to false.
  24090. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24091. */
  24092. /**
  24093. * Gets if `setParticles()` computes the particle rotations or not.
  24094. * Default value : true. The SPS is faster when it's set to false.
  24095. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24096. */
  24097. computeParticleRotation: boolean;
  24098. /**
  24099. * Tells to `setParticles()` to compute the particle colors or not.
  24100. * Default value : true. The SPS is faster when it's set to false.
  24101. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24102. */
  24103. /**
  24104. * Gets if `setParticles()` computes the particle colors or not.
  24105. * Default value : true. The SPS is faster when it's set to false.
  24106. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24107. */
  24108. computeParticleColor: boolean;
  24109. /**
  24110. * Gets if `setParticles()` computes the particle textures or not.
  24111. * Default value : true. The SPS is faster when it's set to false.
  24112. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24113. */
  24114. computeParticleTexture: boolean;
  24115. /**
  24116. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24117. * Default value : false. The SPS is faster when it's set to false.
  24118. * Note : the particle custom vertex positions aren't stored values.
  24119. */
  24120. /**
  24121. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24122. * Default value : false. The SPS is faster when it's set to false.
  24123. * Note : the particle custom vertex positions aren't stored values.
  24124. */
  24125. computeParticleVertex: boolean;
  24126. /**
  24127. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24128. */
  24129. /**
  24130. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24131. */
  24132. computeBoundingBox: boolean;
  24133. /**
  24134. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24135. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24136. * Default : `true`
  24137. */
  24138. /**
  24139. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24140. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24141. * Default : `true`
  24142. */
  24143. depthSortParticles: boolean;
  24144. /**
  24145. * This function does nothing. It may be overwritten to set all the particle first values.
  24146. * The SPS doesn't call this function, you may have to call it by your own.
  24147. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24148. */
  24149. initParticles(): void;
  24150. /**
  24151. * This function does nothing. It may be overwritten to recycle a particle.
  24152. * The SPS doesn't call this function, you may have to call it by your own.
  24153. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24154. * @param particle The particle to recycle
  24155. * @returns the recycled particle
  24156. */
  24157. recycleParticle(particle: SolidParticle): SolidParticle;
  24158. /**
  24159. * Updates a particle : this function should be overwritten by the user.
  24160. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24161. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24162. * @example : just set a particle position or velocity and recycle conditions
  24163. * @param particle The particle to update
  24164. * @returns the updated particle
  24165. */
  24166. updateParticle(particle: SolidParticle): SolidParticle;
  24167. /**
  24168. * Updates a vertex of a particle : it can be overwritten by the user.
  24169. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24170. * @param particle the current particle
  24171. * @param vertex the current index of the current particle
  24172. * @param pt the index of the current vertex in the particle shape
  24173. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24174. * @example : just set a vertex particle position
  24175. * @returns the updated vertex
  24176. */
  24177. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24178. /**
  24179. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24180. * This does nothing and may be overwritten by the user.
  24181. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24182. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24183. * @param update the boolean update value actually passed to setParticles()
  24184. */
  24185. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24186. /**
  24187. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24188. * This will be passed three parameters.
  24189. * This does nothing and may be overwritten by the user.
  24190. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24191. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24192. * @param update the boolean update value actually passed to setParticles()
  24193. */
  24194. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24195. }
  24196. }
  24197. declare module "babylonjs/Particles/solidParticle" {
  24198. import { Nullable } from "babylonjs/types";
  24199. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24200. import { Mesh } from "babylonjs/Meshes/mesh";
  24201. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24202. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24203. /**
  24204. * Represents one particle of a solid particle system.
  24205. */
  24206. export class SolidParticle {
  24207. /**
  24208. * particle global index
  24209. */
  24210. idx: number;
  24211. /**
  24212. * The color of the particle
  24213. */
  24214. color: Nullable<Color4>;
  24215. /**
  24216. * The world space position of the particle.
  24217. */
  24218. position: Vector3;
  24219. /**
  24220. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24221. */
  24222. rotation: Vector3;
  24223. /**
  24224. * The world space rotation quaternion of the particle.
  24225. */
  24226. rotationQuaternion: Nullable<Quaternion>;
  24227. /**
  24228. * The scaling of the particle.
  24229. */
  24230. scaling: Vector3;
  24231. /**
  24232. * The uvs of the particle.
  24233. */
  24234. uvs: Vector4;
  24235. /**
  24236. * The current speed of the particle.
  24237. */
  24238. velocity: Vector3;
  24239. /**
  24240. * The pivot point in the particle local space.
  24241. */
  24242. pivot: Vector3;
  24243. /**
  24244. * Must the particle be translated from its pivot point in its local space ?
  24245. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24246. * Default : false
  24247. */
  24248. translateFromPivot: boolean;
  24249. /**
  24250. * Is the particle active or not ?
  24251. */
  24252. alive: boolean;
  24253. /**
  24254. * Is the particle visible or not ?
  24255. */
  24256. isVisible: boolean;
  24257. /**
  24258. * Index of this particle in the global "positions" array (Internal use)
  24259. * @hidden
  24260. */
  24261. _pos: number;
  24262. /**
  24263. * @hidden Index of this particle in the global "indices" array (Internal use)
  24264. */
  24265. _ind: number;
  24266. /**
  24267. * @hidden ModelShape of this particle (Internal use)
  24268. */
  24269. _model: ModelShape;
  24270. /**
  24271. * ModelShape id of this particle
  24272. */
  24273. shapeId: number;
  24274. /**
  24275. * Index of the particle in its shape id (Internal use)
  24276. */
  24277. idxInShape: number;
  24278. /**
  24279. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24280. */
  24281. _modelBoundingInfo: BoundingInfo;
  24282. /**
  24283. * @hidden Particle BoundingInfo object (Internal use)
  24284. */
  24285. _boundingInfo: BoundingInfo;
  24286. /**
  24287. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24288. */
  24289. _sps: SolidParticleSystem;
  24290. /**
  24291. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24292. */
  24293. _stillInvisible: boolean;
  24294. /**
  24295. * @hidden Last computed particle rotation matrix
  24296. */
  24297. _rotationMatrix: number[];
  24298. /**
  24299. * Parent particle Id, if any.
  24300. * Default null.
  24301. */
  24302. parentId: Nullable<number>;
  24303. /**
  24304. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24305. * The possible values are :
  24306. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24307. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24308. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24309. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24310. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24311. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24312. * */
  24313. cullingStrategy: number;
  24314. /**
  24315. * @hidden Internal global position in the SPS.
  24316. */
  24317. _globalPosition: Vector3;
  24318. /**
  24319. * Creates a Solid Particle object.
  24320. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24321. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24322. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24323. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24324. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24325. * @param shapeId (integer) is the model shape identifier in the SPS.
  24326. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24327. * @param sps defines the sps it is associated to
  24328. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24329. */
  24330. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24331. /**
  24332. * Legacy support, changed scale to scaling
  24333. */
  24334. /**
  24335. * Legacy support, changed scale to scaling
  24336. */
  24337. scale: Vector3;
  24338. /**
  24339. * Legacy support, changed quaternion to rotationQuaternion
  24340. */
  24341. /**
  24342. * Legacy support, changed quaternion to rotationQuaternion
  24343. */
  24344. quaternion: Nullable<Quaternion>;
  24345. /**
  24346. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24347. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24348. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24349. * @returns true if it intersects
  24350. */
  24351. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24352. /**
  24353. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24354. * A particle is in the frustum if its bounding box intersects the frustum
  24355. * @param frustumPlanes defines the frustum to test
  24356. * @returns true if the particle is in the frustum planes
  24357. */
  24358. isInFrustum(frustumPlanes: Plane[]): boolean;
  24359. /**
  24360. * get the rotation matrix of the particle
  24361. * @hidden
  24362. */
  24363. getRotationMatrix(m: Matrix): void;
  24364. }
  24365. /**
  24366. * Represents the shape of the model used by one particle of a solid particle system.
  24367. * SPS internal tool, don't use it manually.
  24368. */
  24369. export class ModelShape {
  24370. /**
  24371. * The shape id
  24372. * @hidden
  24373. */
  24374. shapeID: number;
  24375. /**
  24376. * flat array of model positions (internal use)
  24377. * @hidden
  24378. */
  24379. _shape: Vector3[];
  24380. /**
  24381. * flat array of model UVs (internal use)
  24382. * @hidden
  24383. */
  24384. _shapeUV: number[];
  24385. /**
  24386. * length of the shape in the model indices array (internal use)
  24387. * @hidden
  24388. */
  24389. _indicesLength: number;
  24390. /**
  24391. * Custom position function (internal use)
  24392. * @hidden
  24393. */
  24394. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24395. /**
  24396. * Custom vertex function (internal use)
  24397. * @hidden
  24398. */
  24399. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24400. /**
  24401. * 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.
  24402. * SPS internal tool, don't use it manually.
  24403. * @hidden
  24404. */
  24405. 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>);
  24406. }
  24407. /**
  24408. * Represents a Depth Sorted Particle in the solid particle system.
  24409. */
  24410. export class DepthSortedParticle {
  24411. /**
  24412. * Index of the particle in the "indices" array
  24413. */
  24414. ind: number;
  24415. /**
  24416. * Length of the particle shape in the "indices" array
  24417. */
  24418. indicesLength: number;
  24419. /**
  24420. * Squared distance from the particle to the camera
  24421. */
  24422. sqDistance: number;
  24423. }
  24424. }
  24425. declare module "babylonjs/Meshes/abstractMesh" {
  24426. import { Observable } from "babylonjs/Misc/observable";
  24427. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24428. import { Camera } from "babylonjs/Cameras/camera";
  24429. import { Scene, IDisposable } from "babylonjs/scene";
  24430. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24431. import { Node } from "babylonjs/node";
  24432. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24433. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24435. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24436. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24437. import { Material } from "babylonjs/Materials/material";
  24438. import { Light } from "babylonjs/Lights/light";
  24439. import { Skeleton } from "babylonjs/Bones/skeleton";
  24440. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24441. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24442. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24443. import { Ray } from "babylonjs/Culling/ray";
  24444. import { Collider } from "babylonjs/Collisions/collider";
  24445. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24446. /**
  24447. * Class used to store all common mesh properties
  24448. */
  24449. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24450. /** No occlusion */
  24451. static OCCLUSION_TYPE_NONE: number;
  24452. /** Occlusion set to optimisitic */
  24453. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24454. /** Occlusion set to strict */
  24455. static OCCLUSION_TYPE_STRICT: number;
  24456. /** Use an accurante occlusion algorithm */
  24457. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24458. /** Use a conservative occlusion algorithm */
  24459. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24461. * Test order :
  24462. * Is the bounding sphere outside the frustum ?
  24463. * If not, are the bounding box vertices outside the frustum ?
  24464. * It not, then the cullable object is in the frustum.
  24465. */
  24466. static readonly CULLINGSTRATEGY_STANDARD: number;
  24467. /** Culling strategy : Bounding Sphere Only.
  24468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24469. * It's also less accurate than the standard because some not visible objects can still be selected.
  24470. * Test : is the bounding sphere outside the frustum ?
  24471. * If not, then the cullable object is in the frustum.
  24472. */
  24473. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24474. /** Culling strategy : Optimistic Inclusion.
  24475. * This in an inclusion test first, then the standard exclusion test.
  24476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24477. * 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.
  24478. * Anyway, it's as accurate as the standard strategy.
  24479. * Test :
  24480. * Is the cullable object bounding sphere center in the frustum ?
  24481. * If not, apply the default culling strategy.
  24482. */
  24483. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24487. * 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.
  24488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24489. * Test :
  24490. * Is the cullable object bounding sphere center in the frustum ?
  24491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24492. */
  24493. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24494. /**
  24495. * No billboard
  24496. */
  24497. static readonly BILLBOARDMODE_NONE: number;
  24498. /** Billboard on X axis */
  24499. static readonly BILLBOARDMODE_X: number;
  24500. /** Billboard on Y axis */
  24501. static readonly BILLBOARDMODE_Y: number;
  24502. /** Billboard on Z axis */
  24503. static readonly BILLBOARDMODE_Z: number;
  24504. /** Billboard on all axes */
  24505. static readonly BILLBOARDMODE_ALL: number;
  24506. private _facetData;
  24507. /**
  24508. * The culling strategy to use to check whether the mesh must be rendered or not.
  24509. * This value can be changed at any time and will be used on the next render mesh selection.
  24510. * The possible values are :
  24511. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24512. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24513. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24514. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24515. * Please read each static variable documentation to get details about the culling process.
  24516. * */
  24517. cullingStrategy: number;
  24518. /**
  24519. * Gets the number of facets in the mesh
  24520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24521. */
  24522. readonly facetNb: number;
  24523. /**
  24524. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24526. */
  24527. partitioningSubdivisions: number;
  24528. /**
  24529. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24530. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24532. */
  24533. partitioningBBoxRatio: number;
  24534. /**
  24535. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24536. * Works only for updatable meshes.
  24537. * Doesn't work with multi-materials
  24538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24539. */
  24540. mustDepthSortFacets: boolean;
  24541. /**
  24542. * The location (Vector3) where the facet depth sort must be computed from.
  24543. * By default, the active camera position.
  24544. * Used only when facet depth sort is enabled
  24545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24546. */
  24547. facetDepthSortFrom: Vector3;
  24548. /**
  24549. * gets a boolean indicating if facetData is enabled
  24550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24551. */
  24552. readonly isFacetDataEnabled: boolean;
  24553. /** @hidden */
  24554. _updateNonUniformScalingState(value: boolean): boolean;
  24555. /**
  24556. * An event triggered when this mesh collides with another one
  24557. */
  24558. onCollideObservable: Observable<AbstractMesh>;
  24559. private _onCollideObserver;
  24560. /** Set a function to call when this mesh collides with another one */
  24561. onCollide: () => void;
  24562. /**
  24563. * An event triggered when the collision's position changes
  24564. */
  24565. onCollisionPositionChangeObservable: Observable<Vector3>;
  24566. private _onCollisionPositionChangeObserver;
  24567. /** Set a function to call when the collision's position changes */
  24568. onCollisionPositionChange: () => void;
  24569. /**
  24570. * An event triggered when material is changed
  24571. */
  24572. onMaterialChangedObservable: Observable<AbstractMesh>;
  24573. /**
  24574. * Gets or sets the orientation for POV movement & rotation
  24575. */
  24576. definedFacingForward: boolean;
  24577. /** @hidden */
  24578. _occlusionQuery: Nullable<WebGLQuery>;
  24579. private _visibility;
  24580. /**
  24581. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24582. */
  24583. /**
  24584. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24585. */
  24586. visibility: number;
  24587. /** Gets or sets the alpha index used to sort transparent meshes
  24588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24589. */
  24590. alphaIndex: number;
  24591. /**
  24592. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24593. */
  24594. isVisible: boolean;
  24595. /**
  24596. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24597. */
  24598. isPickable: boolean;
  24599. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24600. showSubMeshesBoundingBox: boolean;
  24601. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24602. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24603. */
  24604. isBlocker: boolean;
  24605. /**
  24606. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24607. */
  24608. enablePointerMoveEvents: boolean;
  24609. /**
  24610. * Specifies the rendering group id for this mesh (0 by default)
  24611. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24612. */
  24613. renderingGroupId: number;
  24614. private _material;
  24615. /** Gets or sets current material */
  24616. material: Nullable<Material>;
  24617. private _receiveShadows;
  24618. /**
  24619. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24620. * @see http://doc.babylonjs.com/babylon101/shadows
  24621. */
  24622. receiveShadows: boolean;
  24623. /** Defines color to use when rendering outline */
  24624. outlineColor: Color3;
  24625. /** Define width to use when rendering outline */
  24626. outlineWidth: number;
  24627. /** Defines color to use when rendering overlay */
  24628. overlayColor: Color3;
  24629. /** Defines alpha to use when rendering overlay */
  24630. overlayAlpha: number;
  24631. private _hasVertexAlpha;
  24632. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24633. hasVertexAlpha: boolean;
  24634. private _useVertexColors;
  24635. /** 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) */
  24636. useVertexColors: boolean;
  24637. private _computeBonesUsingShaders;
  24638. /**
  24639. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24640. */
  24641. computeBonesUsingShaders: boolean;
  24642. private _numBoneInfluencers;
  24643. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24644. numBoneInfluencers: number;
  24645. private _applyFog;
  24646. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24647. applyFog: boolean;
  24648. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24649. useOctreeForRenderingSelection: boolean;
  24650. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24651. useOctreeForPicking: boolean;
  24652. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24653. useOctreeForCollisions: boolean;
  24654. private _layerMask;
  24655. /**
  24656. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24657. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24658. */
  24659. layerMask: number;
  24660. /**
  24661. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24662. */
  24663. alwaysSelectAsActiveMesh: boolean;
  24664. /**
  24665. * Gets or sets the current action manager
  24666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24667. */
  24668. actionManager: Nullable<AbstractActionManager>;
  24669. private _checkCollisions;
  24670. private _collisionMask;
  24671. private _collisionGroup;
  24672. /**
  24673. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24674. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24675. */
  24676. ellipsoid: Vector3;
  24677. /**
  24678. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24680. */
  24681. ellipsoidOffset: Vector3;
  24682. private _collider;
  24683. private _oldPositionForCollisions;
  24684. private _diffPositionForCollisions;
  24685. /**
  24686. * Gets or sets a collision mask used to mask collisions (default is -1).
  24687. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24688. */
  24689. collisionMask: number;
  24690. /**
  24691. * Gets or sets the current collision group mask (-1 by default).
  24692. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24693. */
  24694. collisionGroup: number;
  24695. /**
  24696. * Defines edge width used when edgesRenderer is enabled
  24697. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24698. */
  24699. edgesWidth: number;
  24700. /**
  24701. * Defines edge color used when edgesRenderer is enabled
  24702. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24703. */
  24704. edgesColor: Color4;
  24705. /** @hidden */
  24706. _edgesRenderer: Nullable<IEdgesRenderer>;
  24707. /** @hidden */
  24708. _masterMesh: Nullable<AbstractMesh>;
  24709. /** @hidden */
  24710. _boundingInfo: Nullable<BoundingInfo>;
  24711. /** @hidden */
  24712. _renderId: number;
  24713. /**
  24714. * Gets or sets the list of subMeshes
  24715. * @see http://doc.babylonjs.com/how_to/multi_materials
  24716. */
  24717. subMeshes: SubMesh[];
  24718. /** @hidden */
  24719. _intersectionsInProgress: AbstractMesh[];
  24720. /** @hidden */
  24721. _unIndexed: boolean;
  24722. /** @hidden */
  24723. _lightSources: Light[];
  24724. /** @hidden */
  24725. readonly _positions: Nullable<Vector3[]>;
  24726. /** @hidden */
  24727. _waitingActions: any;
  24728. /** @hidden */
  24729. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24730. private _skeleton;
  24731. /** @hidden */
  24732. _bonesTransformMatrices: Nullable<Float32Array>;
  24733. /**
  24734. * Gets or sets a skeleton to apply skining transformations
  24735. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24736. */
  24737. skeleton: Nullable<Skeleton>;
  24738. /**
  24739. * An event triggered when the mesh is rebuilt.
  24740. */
  24741. onRebuildObservable: Observable<AbstractMesh>;
  24742. /**
  24743. * Creates a new AbstractMesh
  24744. * @param name defines the name of the mesh
  24745. * @param scene defines the hosting scene
  24746. */
  24747. constructor(name: string, scene?: Nullable<Scene>);
  24748. /**
  24749. * Returns the string "AbstractMesh"
  24750. * @returns "AbstractMesh"
  24751. */
  24752. getClassName(): string;
  24753. /**
  24754. * Gets a string representation of the current mesh
  24755. * @param fullDetails defines a boolean indicating if full details must be included
  24756. * @returns a string representation of the current mesh
  24757. */
  24758. toString(fullDetails?: boolean): string;
  24759. /** @hidden */
  24760. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24761. /** @hidden */
  24762. _rebuild(): void;
  24763. /** @hidden */
  24764. _resyncLightSources(): void;
  24765. /** @hidden */
  24766. _resyncLighSource(light: Light): void;
  24767. /** @hidden */
  24768. _unBindEffect(): void;
  24769. /** @hidden */
  24770. _removeLightSource(light: Light): void;
  24771. private _markSubMeshesAsDirty;
  24772. /** @hidden */
  24773. _markSubMeshesAsLightDirty(): void;
  24774. /** @hidden */
  24775. _markSubMeshesAsAttributesDirty(): void;
  24776. /** @hidden */
  24777. _markSubMeshesAsMiscDirty(): void;
  24778. /**
  24779. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24780. */
  24781. scaling: Vector3;
  24782. /**
  24783. * Returns true if the mesh is blocked. Implemented by child classes
  24784. */
  24785. readonly isBlocked: boolean;
  24786. /**
  24787. * Returns the mesh itself by default. Implemented by child classes
  24788. * @param camera defines the camera to use to pick the right LOD level
  24789. * @returns the currentAbstractMesh
  24790. */
  24791. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24792. /**
  24793. * Returns 0 by default. Implemented by child classes
  24794. * @returns an integer
  24795. */
  24796. getTotalVertices(): number;
  24797. /**
  24798. * Returns a positive integer : the total number of indices in this mesh geometry.
  24799. * @returns the numner of indices or zero if the mesh has no geometry.
  24800. */
  24801. getTotalIndices(): number;
  24802. /**
  24803. * Returns null by default. Implemented by child classes
  24804. * @returns null
  24805. */
  24806. getIndices(): Nullable<IndicesArray>;
  24807. /**
  24808. * Returns the array of the requested vertex data kind. Implemented by child classes
  24809. * @param kind defines the vertex data kind to use
  24810. * @returns null
  24811. */
  24812. getVerticesData(kind: string): Nullable<FloatArray>;
  24813. /**
  24814. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24815. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24816. * Note that a new underlying VertexBuffer object is created each call.
  24817. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24818. * @param kind defines vertex data kind:
  24819. * * VertexBuffer.PositionKind
  24820. * * VertexBuffer.UVKind
  24821. * * VertexBuffer.UV2Kind
  24822. * * VertexBuffer.UV3Kind
  24823. * * VertexBuffer.UV4Kind
  24824. * * VertexBuffer.UV5Kind
  24825. * * VertexBuffer.UV6Kind
  24826. * * VertexBuffer.ColorKind
  24827. * * VertexBuffer.MatricesIndicesKind
  24828. * * VertexBuffer.MatricesIndicesExtraKind
  24829. * * VertexBuffer.MatricesWeightsKind
  24830. * * VertexBuffer.MatricesWeightsExtraKind
  24831. * @param data defines the data source
  24832. * @param updatable defines if the data must be flagged as updatable (or static)
  24833. * @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
  24834. * @returns the current mesh
  24835. */
  24836. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24837. /**
  24838. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24839. * If the mesh has no geometry, it is simply returned as it is.
  24840. * @param kind defines vertex data kind:
  24841. * * VertexBuffer.PositionKind
  24842. * * VertexBuffer.UVKind
  24843. * * VertexBuffer.UV2Kind
  24844. * * VertexBuffer.UV3Kind
  24845. * * VertexBuffer.UV4Kind
  24846. * * VertexBuffer.UV5Kind
  24847. * * VertexBuffer.UV6Kind
  24848. * * VertexBuffer.ColorKind
  24849. * * VertexBuffer.MatricesIndicesKind
  24850. * * VertexBuffer.MatricesIndicesExtraKind
  24851. * * VertexBuffer.MatricesWeightsKind
  24852. * * VertexBuffer.MatricesWeightsExtraKind
  24853. * @param data defines the data source
  24854. * @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
  24855. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24856. * @returns the current mesh
  24857. */
  24858. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24859. /**
  24860. * Sets the mesh indices,
  24861. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24862. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24863. * @param totalVertices Defines the total number of vertices
  24864. * @returns the current mesh
  24865. */
  24866. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24867. /**
  24868. * Gets a boolean indicating if specific vertex data is present
  24869. * @param kind defines the vertex data kind to use
  24870. * @returns true is data kind is present
  24871. */
  24872. isVerticesDataPresent(kind: string): boolean;
  24873. /**
  24874. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24875. * @returns a BoundingInfo
  24876. */
  24877. getBoundingInfo(): BoundingInfo;
  24878. /**
  24879. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24880. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24881. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24882. * @returns the current mesh
  24883. */
  24884. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24885. /**
  24886. * Overwrite the current bounding info
  24887. * @param boundingInfo defines the new bounding info
  24888. * @returns the current mesh
  24889. */
  24890. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24891. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24892. readonly useBones: boolean;
  24893. /** @hidden */
  24894. _preActivate(): void;
  24895. /** @hidden */
  24896. _preActivateForIntermediateRendering(renderId: number): void;
  24897. /** @hidden */
  24898. _activate(renderId: number): void;
  24899. /**
  24900. * Gets the current world matrix
  24901. * @returns a Matrix
  24902. */
  24903. getWorldMatrix(): Matrix;
  24904. /** @hidden */
  24905. _getWorldMatrixDeterminant(): number;
  24906. /**
  24907. * Perform relative position change from the point of view of behind the front of the mesh.
  24908. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24909. * Supports definition of mesh facing forward or backward
  24910. * @param amountRight defines the distance on the right axis
  24911. * @param amountUp defines the distance on the up axis
  24912. * @param amountForward defines the distance on the forward axis
  24913. * @returns the current mesh
  24914. */
  24915. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24916. /**
  24917. * Calculate relative position change from the point of view of behind the front of the mesh.
  24918. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24919. * Supports definition of mesh facing forward or backward
  24920. * @param amountRight defines the distance on the right axis
  24921. * @param amountUp defines the distance on the up axis
  24922. * @param amountForward defines the distance on the forward axis
  24923. * @returns the new displacement vector
  24924. */
  24925. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24926. /**
  24927. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24928. * Supports definition of mesh facing forward or backward
  24929. * @param flipBack defines the flip
  24930. * @param twirlClockwise defines the twirl
  24931. * @param tiltRight defines the tilt
  24932. * @returns the current mesh
  24933. */
  24934. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24935. /**
  24936. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24937. * Supports definition of mesh facing forward or backward.
  24938. * @param flipBack defines the flip
  24939. * @param twirlClockwise defines the twirl
  24940. * @param tiltRight defines the tilt
  24941. * @returns the new rotation vector
  24942. */
  24943. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24944. /**
  24945. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24946. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24947. * @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
  24948. * @returns the new bounding vectors
  24949. */
  24950. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24951. min: Vector3;
  24952. max: Vector3;
  24953. };
  24954. /**
  24955. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24956. * This means the mesh underlying bounding box and sphere are recomputed.
  24957. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24958. * @returns the current mesh
  24959. */
  24960. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24961. /** @hidden */
  24962. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24963. /** @hidden */
  24964. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24965. /** @hidden */
  24966. _updateBoundingInfo(): AbstractMesh;
  24967. /** @hidden */
  24968. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24969. /** @hidden */
  24970. protected _afterComputeWorldMatrix(): void;
  24971. /** @hidden */
  24972. readonly _effectiveMesh: AbstractMesh;
  24973. /**
  24974. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24975. * A mesh is in the frustum if its bounding box intersects the frustum
  24976. * @param frustumPlanes defines the frustum to test
  24977. * @returns true if the mesh is in the frustum planes
  24978. */
  24979. isInFrustum(frustumPlanes: Plane[]): boolean;
  24980. /**
  24981. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24982. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24983. * @param frustumPlanes defines the frustum to test
  24984. * @returns true if the mesh is completely in the frustum planes
  24985. */
  24986. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24987. /**
  24988. * True if the mesh intersects another mesh or a SolidParticle object
  24989. * @param mesh defines a target mesh or SolidParticle to test
  24990. * @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)
  24991. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24992. * @returns true if there is an intersection
  24993. */
  24994. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24995. /**
  24996. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24997. * @param point defines the point to test
  24998. * @returns true if there is an intersection
  24999. */
  25000. intersectsPoint(point: Vector3): boolean;
  25001. /**
  25002. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25003. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25004. */
  25005. checkCollisions: boolean;
  25006. /**
  25007. * Gets Collider object used to compute collisions (not physics)
  25008. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25009. */
  25010. readonly collider: Collider;
  25011. /**
  25012. * Move the mesh using collision engine
  25013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25014. * @param displacement defines the requested displacement vector
  25015. * @returns the current mesh
  25016. */
  25017. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25018. private _onCollisionPositionChange;
  25019. /** @hidden */
  25020. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25021. /** @hidden */
  25022. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25023. /** @hidden */
  25024. _checkCollision(collider: Collider): AbstractMesh;
  25025. /** @hidden */
  25026. _generatePointsArray(): boolean;
  25027. /**
  25028. * Checks if the passed Ray intersects with the mesh
  25029. * @param ray defines the ray to use
  25030. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25031. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25032. * @returns the picking info
  25033. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25034. */
  25035. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25036. /**
  25037. * Clones the current mesh
  25038. * @param name defines the mesh name
  25039. * @param newParent defines the new mesh parent
  25040. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25041. * @returns the new mesh
  25042. */
  25043. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25044. /**
  25045. * Disposes all the submeshes of the current meshnp
  25046. * @returns the current mesh
  25047. */
  25048. releaseSubMeshes(): AbstractMesh;
  25049. /**
  25050. * Releases resources associated with this abstract mesh.
  25051. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25052. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25053. */
  25054. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25055. /**
  25056. * Adds the passed mesh as a child to the current mesh
  25057. * @param mesh defines the child mesh
  25058. * @returns the current mesh
  25059. */
  25060. addChild(mesh: AbstractMesh): AbstractMesh;
  25061. /**
  25062. * Removes the passed mesh from the current mesh children list
  25063. * @param mesh defines the child mesh
  25064. * @returns the current mesh
  25065. */
  25066. removeChild(mesh: AbstractMesh): AbstractMesh;
  25067. /** @hidden */
  25068. private _initFacetData;
  25069. /**
  25070. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25071. * This method can be called within the render loop.
  25072. * 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
  25073. * @returns the current mesh
  25074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25075. */
  25076. updateFacetData(): AbstractMesh;
  25077. /**
  25078. * Returns the facetLocalNormals array.
  25079. * The normals are expressed in the mesh local spac
  25080. * @returns an array of Vector3
  25081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25082. */
  25083. getFacetLocalNormals(): Vector3[];
  25084. /**
  25085. * Returns the facetLocalPositions array.
  25086. * The facet positions are expressed in the mesh local space
  25087. * @returns an array of Vector3
  25088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25089. */
  25090. getFacetLocalPositions(): Vector3[];
  25091. /**
  25092. * Returns the facetLocalPartioning array
  25093. * @returns an array of array of numbers
  25094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25095. */
  25096. getFacetLocalPartitioning(): number[][];
  25097. /**
  25098. * Returns the i-th facet position in the world system.
  25099. * This method allocates a new Vector3 per call
  25100. * @param i defines the facet index
  25101. * @returns a new Vector3
  25102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25103. */
  25104. getFacetPosition(i: number): Vector3;
  25105. /**
  25106. * Sets the reference Vector3 with the i-th facet position in the world system
  25107. * @param i defines the facet index
  25108. * @param ref defines the target vector
  25109. * @returns the current mesh
  25110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25111. */
  25112. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25113. /**
  25114. * Returns the i-th facet normal in the world system.
  25115. * This method allocates a new Vector3 per call
  25116. * @param i defines the facet index
  25117. * @returns a new Vector3
  25118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25119. */
  25120. getFacetNormal(i: number): Vector3;
  25121. /**
  25122. * Sets the reference Vector3 with the i-th facet normal in the world system
  25123. * @param i defines the facet index
  25124. * @param ref defines the target vector
  25125. * @returns the current mesh
  25126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25127. */
  25128. getFacetNormalToRef(i: number, ref: Vector3): this;
  25129. /**
  25130. * 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)
  25131. * @param x defines x coordinate
  25132. * @param y defines y coordinate
  25133. * @param z defines z coordinate
  25134. * @returns the array of facet indexes
  25135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25136. */
  25137. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25138. /**
  25139. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25140. * @param projected sets as the (x,y,z) world projection on the facet
  25141. * @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
  25142. * @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
  25143. * @param x defines x coordinate
  25144. * @param y defines y coordinate
  25145. * @param z defines z coordinate
  25146. * @returns the face index if found (or null instead)
  25147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25148. */
  25149. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25150. /**
  25151. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25152. * @param projected sets as the (x,y,z) local projection on the facet
  25153. * @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
  25154. * @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
  25155. * @param x defines x coordinate
  25156. * @param y defines y coordinate
  25157. * @param z defines z coordinate
  25158. * @returns the face index if found (or null instead)
  25159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25160. */
  25161. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25162. /**
  25163. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25164. * @returns the parameters
  25165. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25166. */
  25167. getFacetDataParameters(): any;
  25168. /**
  25169. * Disables the feature FacetData and frees the related memory
  25170. * @returns the current mesh
  25171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25172. */
  25173. disableFacetData(): AbstractMesh;
  25174. /**
  25175. * Updates the AbstractMesh indices array
  25176. * @param indices defines the data source
  25177. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25178. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25179. * @returns the current mesh
  25180. */
  25181. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25182. /**
  25183. * Creates new normals data for the mesh
  25184. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25185. * @returns the current mesh
  25186. */
  25187. createNormals(updatable: boolean): AbstractMesh;
  25188. /**
  25189. * Align the mesh with a normal
  25190. * @param normal defines the normal to use
  25191. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25192. * @returns the current mesh
  25193. */
  25194. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25195. /** @hidden */
  25196. _checkOcclusionQuery(): boolean;
  25197. }
  25198. }
  25199. declare module "babylonjs/Actions/actionEvent" {
  25200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25201. import { Nullable } from "babylonjs/types";
  25202. import { Sprite } from "babylonjs/Sprites/sprite";
  25203. import { Scene } from "babylonjs/scene";
  25204. import { Vector2 } from "babylonjs/Maths/math";
  25205. /**
  25206. * Interface used to define ActionEvent
  25207. */
  25208. export interface IActionEvent {
  25209. /** The mesh or sprite that triggered the action */
  25210. source: any;
  25211. /** The X mouse cursor position at the time of the event */
  25212. pointerX: number;
  25213. /** The Y mouse cursor position at the time of the event */
  25214. pointerY: number;
  25215. /** The mesh that is currently pointed at (can be null) */
  25216. meshUnderPointer: Nullable<AbstractMesh>;
  25217. /** the original (browser) event that triggered the ActionEvent */
  25218. sourceEvent?: any;
  25219. /** additional data for the event */
  25220. additionalData?: any;
  25221. }
  25222. /**
  25223. * ActionEvent is the event being sent when an action is triggered.
  25224. */
  25225. export class ActionEvent implements IActionEvent {
  25226. /** The mesh or sprite that triggered the action */
  25227. source: any;
  25228. /** The X mouse cursor position at the time of the event */
  25229. pointerX: number;
  25230. /** The Y mouse cursor position at the time of the event */
  25231. pointerY: number;
  25232. /** The mesh that is currently pointed at (can be null) */
  25233. meshUnderPointer: Nullable<AbstractMesh>;
  25234. /** the original (browser) event that triggered the ActionEvent */
  25235. sourceEvent?: any;
  25236. /** additional data for the event */
  25237. additionalData?: any;
  25238. /**
  25239. * Creates a new ActionEvent
  25240. * @param source The mesh or sprite that triggered the action
  25241. * @param pointerX The X mouse cursor position at the time of the event
  25242. * @param pointerY The Y mouse cursor position at the time of the event
  25243. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25244. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25245. * @param additionalData additional data for the event
  25246. */
  25247. constructor(
  25248. /** The mesh or sprite that triggered the action */
  25249. source: any,
  25250. /** The X mouse cursor position at the time of the event */
  25251. pointerX: number,
  25252. /** The Y mouse cursor position at the time of the event */
  25253. pointerY: number,
  25254. /** The mesh that is currently pointed at (can be null) */
  25255. meshUnderPointer: Nullable<AbstractMesh>,
  25256. /** the original (browser) event that triggered the ActionEvent */
  25257. sourceEvent?: any,
  25258. /** additional data for the event */
  25259. additionalData?: any);
  25260. /**
  25261. * Helper function to auto-create an ActionEvent from a source mesh.
  25262. * @param source The source mesh that triggered the event
  25263. * @param evt The original (browser) event
  25264. * @param additionalData additional data for the event
  25265. * @returns the new ActionEvent
  25266. */
  25267. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25268. /**
  25269. * Helper function to auto-create an ActionEvent from a source sprite
  25270. * @param source The source sprite that triggered the event
  25271. * @param scene Scene associated with the sprite
  25272. * @param evt The original (browser) event
  25273. * @param additionalData additional data for the event
  25274. * @returns the new ActionEvent
  25275. */
  25276. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25277. /**
  25278. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25279. * @param scene the scene where the event occurred
  25280. * @param evt The original (browser) event
  25281. * @returns the new ActionEvent
  25282. */
  25283. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25284. /**
  25285. * Helper function to auto-create an ActionEvent from a primitive
  25286. * @param prim defines the target primitive
  25287. * @param pointerPos defines the pointer position
  25288. * @param evt The original (browser) event
  25289. * @param additionalData additional data for the event
  25290. * @returns the new ActionEvent
  25291. */
  25292. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25293. }
  25294. }
  25295. declare module "babylonjs/Actions/abstractActionManager" {
  25296. import { IDisposable } from "babylonjs/scene";
  25297. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25298. import { IAction } from "babylonjs/Actions/action";
  25299. import { Nullable } from "babylonjs/types";
  25300. /**
  25301. * Abstract class used to decouple action Manager from scene and meshes.
  25302. * Do not instantiate.
  25303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25304. */
  25305. export abstract class AbstractActionManager implements IDisposable {
  25306. /** Gets the list of active triggers */
  25307. static Triggers: {
  25308. [key: string]: number;
  25309. };
  25310. /** Gets the cursor to use when hovering items */
  25311. hoverCursor: string;
  25312. /** Gets the list of actions */
  25313. actions: IAction[];
  25314. /**
  25315. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25316. */
  25317. isRecursive: boolean;
  25318. /**
  25319. * Releases all associated resources
  25320. */
  25321. abstract dispose(): void;
  25322. /**
  25323. * Does this action manager has pointer triggers
  25324. */
  25325. abstract readonly hasPointerTriggers: boolean;
  25326. /**
  25327. * Does this action manager has pick triggers
  25328. */
  25329. abstract readonly hasPickTriggers: boolean;
  25330. /**
  25331. * Process a specific trigger
  25332. * @param trigger defines the trigger to process
  25333. * @param evt defines the event details to be processed
  25334. */
  25335. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25336. /**
  25337. * Does this action manager handles actions of any of the given triggers
  25338. * @param triggers defines the triggers to be tested
  25339. * @return a boolean indicating whether one (or more) of the triggers is handled
  25340. */
  25341. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25342. /**
  25343. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25344. * speed.
  25345. * @param triggerA defines the trigger to be tested
  25346. * @param triggerB defines the trigger to be tested
  25347. * @return a boolean indicating whether one (or more) of the triggers is handled
  25348. */
  25349. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25350. /**
  25351. * Does this action manager handles actions of a given trigger
  25352. * @param trigger defines the trigger to be tested
  25353. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25354. * @return whether the trigger is handled
  25355. */
  25356. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25357. /**
  25358. * Serialize this manager to a JSON object
  25359. * @param name defines the property name to store this manager
  25360. * @returns a JSON representation of this manager
  25361. */
  25362. abstract serialize(name: string): any;
  25363. /**
  25364. * Registers an action to this action manager
  25365. * @param action defines the action to be registered
  25366. * @return the action amended (prepared) after registration
  25367. */
  25368. abstract registerAction(action: IAction): Nullable<IAction>;
  25369. /**
  25370. * Unregisters an action to this action manager
  25371. * @param action defines the action to be unregistered
  25372. * @return a boolean indicating whether the action has been unregistered
  25373. */
  25374. abstract unregisterAction(action: IAction): Boolean;
  25375. /**
  25376. * Does exist one action manager with at least one trigger
  25377. **/
  25378. static readonly HasTriggers: boolean;
  25379. /**
  25380. * Does exist one action manager with at least one pick trigger
  25381. **/
  25382. static readonly HasPickTriggers: boolean;
  25383. /**
  25384. * Does exist one action manager that handles actions of a given trigger
  25385. * @param trigger defines the trigger to be tested
  25386. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25387. **/
  25388. static HasSpecificTrigger(trigger: number): boolean;
  25389. }
  25390. }
  25391. declare module "babylonjs/node" {
  25392. import { Scene } from "babylonjs/scene";
  25393. import { Nullable } from "babylonjs/types";
  25394. import { Matrix } from "babylonjs/Maths/math";
  25395. import { Engine } from "babylonjs/Engines/engine";
  25396. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25397. import { Observable } from "babylonjs/Misc/observable";
  25398. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25399. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25400. import { Animatable } from "babylonjs/Animations/animatable";
  25401. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25402. import { Animation } from "babylonjs/Animations/animation";
  25403. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25405. /**
  25406. * Defines how a node can be built from a string name.
  25407. */
  25408. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25409. /**
  25410. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25411. */
  25412. export class Node implements IBehaviorAware<Node> {
  25413. /** @hidden */
  25414. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25415. private static _NodeConstructors;
  25416. /**
  25417. * Add a new node constructor
  25418. * @param type defines the type name of the node to construct
  25419. * @param constructorFunc defines the constructor function
  25420. */
  25421. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25422. /**
  25423. * Returns a node constructor based on type name
  25424. * @param type defines the type name
  25425. * @param name defines the new node name
  25426. * @param scene defines the hosting scene
  25427. * @param options defines optional options to transmit to constructors
  25428. * @returns the new constructor or null
  25429. */
  25430. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25431. /**
  25432. * Gets or sets the name of the node
  25433. */
  25434. name: string;
  25435. /**
  25436. * Gets or sets the id of the node
  25437. */
  25438. id: string;
  25439. /**
  25440. * Gets or sets the unique id of the node
  25441. */
  25442. uniqueId: number;
  25443. /**
  25444. * Gets or sets a string used to store user defined state for the node
  25445. */
  25446. state: string;
  25447. /**
  25448. * Gets or sets an object used to store user defined information for the node
  25449. */
  25450. metadata: any;
  25451. /**
  25452. * For internal use only. Please do not use.
  25453. */
  25454. reservedDataStore: any;
  25455. /**
  25456. * List of inspectable custom properties (used by the Inspector)
  25457. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25458. */
  25459. inspectableCustomProperties: IInspectable[];
  25460. /**
  25461. * Gets or sets a boolean used to define if the node must be serialized
  25462. */
  25463. doNotSerialize: boolean;
  25464. /** @hidden */
  25465. _isDisposed: boolean;
  25466. /**
  25467. * Gets a list of Animations associated with the node
  25468. */
  25469. animations: import("babylonjs/Animations/animation").Animation[];
  25470. protected _ranges: {
  25471. [name: string]: Nullable<AnimationRange>;
  25472. };
  25473. /**
  25474. * Callback raised when the node is ready to be used
  25475. */
  25476. onReady: (node: Node) => void;
  25477. private _isEnabled;
  25478. private _isParentEnabled;
  25479. private _isReady;
  25480. /** @hidden */
  25481. _currentRenderId: number;
  25482. private _parentRenderId;
  25483. protected _childRenderId: number;
  25484. /** @hidden */
  25485. _waitingParentId: Nullable<string>;
  25486. /** @hidden */
  25487. _scene: Scene;
  25488. /** @hidden */
  25489. _cache: any;
  25490. private _parentNode;
  25491. private _children;
  25492. /** @hidden */
  25493. _worldMatrix: Matrix;
  25494. /** @hidden */
  25495. _worldMatrixDeterminant: number;
  25496. /** @hidden */
  25497. private _sceneRootNodesIndex;
  25498. /**
  25499. * Gets a boolean indicating if the node has been disposed
  25500. * @returns true if the node was disposed
  25501. */
  25502. isDisposed(): boolean;
  25503. /**
  25504. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25505. * @see https://doc.babylonjs.com/how_to/parenting
  25506. */
  25507. parent: Nullable<Node>;
  25508. private addToSceneRootNodes;
  25509. private removeFromSceneRootNodes;
  25510. private _animationPropertiesOverride;
  25511. /**
  25512. * Gets or sets the animation properties override
  25513. */
  25514. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25515. /**
  25516. * Gets a string idenfifying the name of the class
  25517. * @returns "Node" string
  25518. */
  25519. getClassName(): string;
  25520. /** @hidden */
  25521. readonly _isNode: boolean;
  25522. /**
  25523. * An event triggered when the mesh is disposed
  25524. */
  25525. onDisposeObservable: Observable<Node>;
  25526. private _onDisposeObserver;
  25527. /**
  25528. * Sets a callback that will be raised when the node will be disposed
  25529. */
  25530. onDispose: () => void;
  25531. /**
  25532. * Creates a new Node
  25533. * @param name the name and id to be given to this node
  25534. * @param scene the scene this node will be added to
  25535. * @param addToRootNodes the node will be added to scene.rootNodes
  25536. */
  25537. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25538. /**
  25539. * Gets the scene of the node
  25540. * @returns a scene
  25541. */
  25542. getScene(): Scene;
  25543. /**
  25544. * Gets the engine of the node
  25545. * @returns a Engine
  25546. */
  25547. getEngine(): Engine;
  25548. private _behaviors;
  25549. /**
  25550. * Attach a behavior to the node
  25551. * @see http://doc.babylonjs.com/features/behaviour
  25552. * @param behavior defines the behavior to attach
  25553. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25554. * @returns the current Node
  25555. */
  25556. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25557. /**
  25558. * Remove an attached behavior
  25559. * @see http://doc.babylonjs.com/features/behaviour
  25560. * @param behavior defines the behavior to attach
  25561. * @returns the current Node
  25562. */
  25563. removeBehavior(behavior: Behavior<Node>): Node;
  25564. /**
  25565. * Gets the list of attached behaviors
  25566. * @see http://doc.babylonjs.com/features/behaviour
  25567. */
  25568. readonly behaviors: Behavior<Node>[];
  25569. /**
  25570. * Gets an attached behavior by name
  25571. * @param name defines the name of the behavior to look for
  25572. * @see http://doc.babylonjs.com/features/behaviour
  25573. * @returns null if behavior was not found else the requested behavior
  25574. */
  25575. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25576. /**
  25577. * Returns the latest update of the World matrix
  25578. * @returns a Matrix
  25579. */
  25580. getWorldMatrix(): Matrix;
  25581. /** @hidden */
  25582. _getWorldMatrixDeterminant(): number;
  25583. /**
  25584. * Returns directly the latest state of the mesh World matrix.
  25585. * A Matrix is returned.
  25586. */
  25587. readonly worldMatrixFromCache: Matrix;
  25588. /** @hidden */
  25589. _initCache(): void;
  25590. /** @hidden */
  25591. updateCache(force?: boolean): void;
  25592. /** @hidden */
  25593. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25594. /** @hidden */
  25595. _updateCache(ignoreParentClass?: boolean): void;
  25596. /** @hidden */
  25597. _isSynchronized(): boolean;
  25598. /** @hidden */
  25599. _markSyncedWithParent(): void;
  25600. /** @hidden */
  25601. isSynchronizedWithParent(): boolean;
  25602. /** @hidden */
  25603. isSynchronized(): boolean;
  25604. /**
  25605. * Is this node ready to be used/rendered
  25606. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25607. * @return true if the node is ready
  25608. */
  25609. isReady(completeCheck?: boolean): boolean;
  25610. /**
  25611. * Is this node enabled?
  25612. * 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
  25613. * @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
  25614. * @return whether this node (and its parent) is enabled
  25615. */
  25616. isEnabled(checkAncestors?: boolean): boolean;
  25617. /** @hidden */
  25618. protected _syncParentEnabledState(): void;
  25619. /**
  25620. * Set the enabled state of this node
  25621. * @param value defines the new enabled state
  25622. */
  25623. setEnabled(value: boolean): void;
  25624. /**
  25625. * Is this node a descendant of the given node?
  25626. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25627. * @param ancestor defines the parent node to inspect
  25628. * @returns a boolean indicating if this node is a descendant of the given node
  25629. */
  25630. isDescendantOf(ancestor: Node): boolean;
  25631. /** @hidden */
  25632. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25633. /**
  25634. * Will return all nodes that have this node as ascendant
  25635. * @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
  25636. * @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
  25637. * @return all children nodes of all types
  25638. */
  25639. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25640. /**
  25641. * Get all child-meshes of this node
  25642. * @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)
  25643. * @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
  25644. * @returns an array of AbstractMesh
  25645. */
  25646. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25647. /**
  25648. * Get all direct children of this node
  25649. * @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
  25650. * @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)
  25651. * @returns an array of Node
  25652. */
  25653. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25654. /** @hidden */
  25655. _setReady(state: boolean): void;
  25656. /**
  25657. * Get an animation by name
  25658. * @param name defines the name of the animation to look for
  25659. * @returns null if not found else the requested animation
  25660. */
  25661. getAnimationByName(name: string): Nullable<Animation>;
  25662. /**
  25663. * Creates an animation range for this node
  25664. * @param name defines the name of the range
  25665. * @param from defines the starting key
  25666. * @param to defines the end key
  25667. */
  25668. createAnimationRange(name: string, from: number, to: number): void;
  25669. /**
  25670. * Delete a specific animation range
  25671. * @param name defines the name of the range to delete
  25672. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25673. */
  25674. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25675. /**
  25676. * Get an animation range by name
  25677. * @param name defines the name of the animation range to look for
  25678. * @returns null if not found else the requested animation range
  25679. */
  25680. getAnimationRange(name: string): Nullable<AnimationRange>;
  25681. /**
  25682. * Gets the list of all animation ranges defined on this node
  25683. * @returns an array
  25684. */
  25685. getAnimationRanges(): Nullable<AnimationRange>[];
  25686. /**
  25687. * Will start the animation sequence
  25688. * @param name defines the range frames for animation sequence
  25689. * @param loop defines if the animation should loop (false by default)
  25690. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25691. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25692. * @returns the object created for this animation. If range does not exist, it will return null
  25693. */
  25694. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25695. /**
  25696. * Serialize animation ranges into a JSON compatible object
  25697. * @returns serialization object
  25698. */
  25699. serializeAnimationRanges(): any;
  25700. /**
  25701. * Computes the world matrix of the node
  25702. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25703. * @returns the world matrix
  25704. */
  25705. computeWorldMatrix(force?: boolean): Matrix;
  25706. /**
  25707. * Releases resources associated with this node.
  25708. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25709. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25710. */
  25711. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25712. /**
  25713. * Parse animation range data from a serialization object and store them into a given node
  25714. * @param node defines where to store the animation ranges
  25715. * @param parsedNode defines the serialization object to read data from
  25716. * @param scene defines the hosting scene
  25717. */
  25718. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25719. }
  25720. }
  25721. declare module "babylonjs/Animations/animation" {
  25722. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25723. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25724. import { Nullable } from "babylonjs/types";
  25725. import { Scene } from "babylonjs/scene";
  25726. import { IAnimatable } from "babylonjs/Misc/tools";
  25727. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25728. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25729. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25730. import { Node } from "babylonjs/node";
  25731. import { Animatable } from "babylonjs/Animations/animatable";
  25732. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25733. /**
  25734. * Class used to store any kind of animation
  25735. */
  25736. export class Animation {
  25737. /**Name of the animation */
  25738. name: string;
  25739. /**Property to animate */
  25740. targetProperty: string;
  25741. /**The frames per second of the animation */
  25742. framePerSecond: number;
  25743. /**The data type of the animation */
  25744. dataType: number;
  25745. /**The loop mode of the animation */
  25746. loopMode?: number | undefined;
  25747. /**Specifies if blending should be enabled */
  25748. enableBlending?: boolean | undefined;
  25749. /**
  25750. * Use matrix interpolation instead of using direct key value when animating matrices
  25751. */
  25752. static AllowMatricesInterpolation: boolean;
  25753. /**
  25754. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25755. */
  25756. static AllowMatrixDecomposeForInterpolation: boolean;
  25757. /**
  25758. * Stores the key frames of the animation
  25759. */
  25760. private _keys;
  25761. /**
  25762. * Stores the easing function of the animation
  25763. */
  25764. private _easingFunction;
  25765. /**
  25766. * @hidden Internal use only
  25767. */
  25768. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25769. /**
  25770. * The set of event that will be linked to this animation
  25771. */
  25772. private _events;
  25773. /**
  25774. * Stores an array of target property paths
  25775. */
  25776. targetPropertyPath: string[];
  25777. /**
  25778. * Stores the blending speed of the animation
  25779. */
  25780. blendingSpeed: number;
  25781. /**
  25782. * Stores the animation ranges for the animation
  25783. */
  25784. private _ranges;
  25785. /**
  25786. * @hidden Internal use
  25787. */
  25788. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25789. /**
  25790. * Sets up an animation
  25791. * @param property The property to animate
  25792. * @param animationType The animation type to apply
  25793. * @param framePerSecond The frames per second of the animation
  25794. * @param easingFunction The easing function used in the animation
  25795. * @returns The created animation
  25796. */
  25797. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25798. /**
  25799. * Create and start an animation on a node
  25800. * @param name defines the name of the global animation that will be run on all nodes
  25801. * @param node defines the root node where the animation will take place
  25802. * @param targetProperty defines property to animate
  25803. * @param framePerSecond defines the number of frame per second yo use
  25804. * @param totalFrame defines the number of frames in total
  25805. * @param from defines the initial value
  25806. * @param to defines the final value
  25807. * @param loopMode defines which loop mode you want to use (off by default)
  25808. * @param easingFunction defines the easing function to use (linear by default)
  25809. * @param onAnimationEnd defines the callback to call when animation end
  25810. * @returns the animatable created for this animation
  25811. */
  25812. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25813. /**
  25814. * Create and start an animation on a node and its descendants
  25815. * @param name defines the name of the global animation that will be run on all nodes
  25816. * @param node defines the root node where the animation will take place
  25817. * @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
  25818. * @param targetProperty defines property to animate
  25819. * @param framePerSecond defines the number of frame per second to use
  25820. * @param totalFrame defines the number of frames in total
  25821. * @param from defines the initial value
  25822. * @param to defines the final value
  25823. * @param loopMode defines which loop mode you want to use (off by default)
  25824. * @param easingFunction defines the easing function to use (linear by default)
  25825. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25826. * @returns the list of animatables created for all nodes
  25827. * @example https://www.babylonjs-playground.com/#MH0VLI
  25828. */
  25829. 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[]>;
  25830. /**
  25831. * Creates a new animation, merges it with the existing animations and starts it
  25832. * @param name Name of the animation
  25833. * @param node Node which contains the scene that begins the animations
  25834. * @param targetProperty Specifies which property to animate
  25835. * @param framePerSecond The frames per second of the animation
  25836. * @param totalFrame The total number of frames
  25837. * @param from The frame at the beginning of the animation
  25838. * @param to The frame at the end of the animation
  25839. * @param loopMode Specifies the loop mode of the animation
  25840. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25841. * @param onAnimationEnd Callback to run once the animation is complete
  25842. * @returns Nullable animation
  25843. */
  25844. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25845. /**
  25846. * Transition property of an host to the target Value
  25847. * @param property The property to transition
  25848. * @param targetValue The target Value of the property
  25849. * @param host The object where the property to animate belongs
  25850. * @param scene Scene used to run the animation
  25851. * @param frameRate Framerate (in frame/s) to use
  25852. * @param transition The transition type we want to use
  25853. * @param duration The duration of the animation, in milliseconds
  25854. * @param onAnimationEnd Callback trigger at the end of the animation
  25855. * @returns Nullable animation
  25856. */
  25857. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25858. /**
  25859. * Return the array of runtime animations currently using this animation
  25860. */
  25861. readonly runtimeAnimations: RuntimeAnimation[];
  25862. /**
  25863. * Specifies if any of the runtime animations are currently running
  25864. */
  25865. readonly hasRunningRuntimeAnimations: boolean;
  25866. /**
  25867. * Initializes the animation
  25868. * @param name Name of the animation
  25869. * @param targetProperty Property to animate
  25870. * @param framePerSecond The frames per second of the animation
  25871. * @param dataType The data type of the animation
  25872. * @param loopMode The loop mode of the animation
  25873. * @param enableBlending Specifies if blending should be enabled
  25874. */
  25875. constructor(
  25876. /**Name of the animation */
  25877. name: string,
  25878. /**Property to animate */
  25879. targetProperty: string,
  25880. /**The frames per second of the animation */
  25881. framePerSecond: number,
  25882. /**The data type of the animation */
  25883. dataType: number,
  25884. /**The loop mode of the animation */
  25885. loopMode?: number | undefined,
  25886. /**Specifies if blending should be enabled */
  25887. enableBlending?: boolean | undefined);
  25888. /**
  25889. * Converts the animation to a string
  25890. * @param fullDetails support for multiple levels of logging within scene loading
  25891. * @returns String form of the animation
  25892. */
  25893. toString(fullDetails?: boolean): string;
  25894. /**
  25895. * Add an event to this animation
  25896. * @param event Event to add
  25897. */
  25898. addEvent(event: AnimationEvent): void;
  25899. /**
  25900. * Remove all events found at the given frame
  25901. * @param frame The frame to remove events from
  25902. */
  25903. removeEvents(frame: number): void;
  25904. /**
  25905. * Retrieves all the events from the animation
  25906. * @returns Events from the animation
  25907. */
  25908. getEvents(): AnimationEvent[];
  25909. /**
  25910. * Creates an animation range
  25911. * @param name Name of the animation range
  25912. * @param from Starting frame of the animation range
  25913. * @param to Ending frame of the animation
  25914. */
  25915. createRange(name: string, from: number, to: number): void;
  25916. /**
  25917. * Deletes an animation range by name
  25918. * @param name Name of the animation range to delete
  25919. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25920. */
  25921. deleteRange(name: string, deleteFrames?: boolean): void;
  25922. /**
  25923. * Gets the animation range by name, or null if not defined
  25924. * @param name Name of the animation range
  25925. * @returns Nullable animation range
  25926. */
  25927. getRange(name: string): Nullable<AnimationRange>;
  25928. /**
  25929. * Gets the key frames from the animation
  25930. * @returns The key frames of the animation
  25931. */
  25932. getKeys(): Array<IAnimationKey>;
  25933. /**
  25934. * Gets the highest frame rate of the animation
  25935. * @returns Highest frame rate of the animation
  25936. */
  25937. getHighestFrame(): number;
  25938. /**
  25939. * Gets the easing function of the animation
  25940. * @returns Easing function of the animation
  25941. */
  25942. getEasingFunction(): IEasingFunction;
  25943. /**
  25944. * Sets the easing function of the animation
  25945. * @param easingFunction A custom mathematical formula for animation
  25946. */
  25947. setEasingFunction(easingFunction: EasingFunction): void;
  25948. /**
  25949. * Interpolates a scalar linearly
  25950. * @param startValue Start value of the animation curve
  25951. * @param endValue End value of the animation curve
  25952. * @param gradient Scalar amount to interpolate
  25953. * @returns Interpolated scalar value
  25954. */
  25955. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25956. /**
  25957. * Interpolates a scalar cubically
  25958. * @param startValue Start value of the animation curve
  25959. * @param outTangent End tangent of the animation
  25960. * @param endValue End value of the animation curve
  25961. * @param inTangent Start tangent of the animation curve
  25962. * @param gradient Scalar amount to interpolate
  25963. * @returns Interpolated scalar value
  25964. */
  25965. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25966. /**
  25967. * Interpolates a quaternion using a spherical linear interpolation
  25968. * @param startValue Start value of the animation curve
  25969. * @param endValue End value of the animation curve
  25970. * @param gradient Scalar amount to interpolate
  25971. * @returns Interpolated quaternion value
  25972. */
  25973. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25974. /**
  25975. * Interpolates a quaternion cubically
  25976. * @param startValue Start value of the animation curve
  25977. * @param outTangent End tangent of the animation curve
  25978. * @param endValue End value of the animation curve
  25979. * @param inTangent Start tangent of the animation curve
  25980. * @param gradient Scalar amount to interpolate
  25981. * @returns Interpolated quaternion value
  25982. */
  25983. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25984. /**
  25985. * Interpolates a Vector3 linearl
  25986. * @param startValue Start value of the animation curve
  25987. * @param endValue End value of the animation curve
  25988. * @param gradient Scalar amount to interpolate
  25989. * @returns Interpolated scalar value
  25990. */
  25991. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25992. /**
  25993. * Interpolates a Vector3 cubically
  25994. * @param startValue Start value of the animation curve
  25995. * @param outTangent End tangent of the animation
  25996. * @param endValue End value of the animation curve
  25997. * @param inTangent Start tangent of the animation curve
  25998. * @param gradient Scalar amount to interpolate
  25999. * @returns InterpolatedVector3 value
  26000. */
  26001. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26002. /**
  26003. * Interpolates a Vector2 linearly
  26004. * @param startValue Start value of the animation curve
  26005. * @param endValue End value of the animation curve
  26006. * @param gradient Scalar amount to interpolate
  26007. * @returns Interpolated Vector2 value
  26008. */
  26009. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26010. /**
  26011. * Interpolates a Vector2 cubically
  26012. * @param startValue Start value of the animation curve
  26013. * @param outTangent End tangent of the animation
  26014. * @param endValue End value of the animation curve
  26015. * @param inTangent Start tangent of the animation curve
  26016. * @param gradient Scalar amount to interpolate
  26017. * @returns Interpolated Vector2 value
  26018. */
  26019. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26020. /**
  26021. * Interpolates a size linearly
  26022. * @param startValue Start value of the animation curve
  26023. * @param endValue End value of the animation curve
  26024. * @param gradient Scalar amount to interpolate
  26025. * @returns Interpolated Size value
  26026. */
  26027. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26028. /**
  26029. * Interpolates a Color3 linearly
  26030. * @param startValue Start value of the animation curve
  26031. * @param endValue End value of the animation curve
  26032. * @param gradient Scalar amount to interpolate
  26033. * @returns Interpolated Color3 value
  26034. */
  26035. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26036. /**
  26037. * @hidden Internal use only
  26038. */
  26039. _getKeyValue(value: any): any;
  26040. /**
  26041. * @hidden Internal use only
  26042. */
  26043. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26044. /**
  26045. * Defines the function to use to interpolate matrices
  26046. * @param startValue defines the start matrix
  26047. * @param endValue defines the end matrix
  26048. * @param gradient defines the gradient between both matrices
  26049. * @param result defines an optional target matrix where to store the interpolation
  26050. * @returns the interpolated matrix
  26051. */
  26052. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26053. /**
  26054. * Makes a copy of the animation
  26055. * @returns Cloned animation
  26056. */
  26057. clone(): Animation;
  26058. /**
  26059. * Sets the key frames of the animation
  26060. * @param values The animation key frames to set
  26061. */
  26062. setKeys(values: Array<IAnimationKey>): void;
  26063. /**
  26064. * Serializes the animation to an object
  26065. * @returns Serialized object
  26066. */
  26067. serialize(): any;
  26068. /**
  26069. * Float animation type
  26070. */
  26071. private static _ANIMATIONTYPE_FLOAT;
  26072. /**
  26073. * Vector3 animation type
  26074. */
  26075. private static _ANIMATIONTYPE_VECTOR3;
  26076. /**
  26077. * Quaternion animation type
  26078. */
  26079. private static _ANIMATIONTYPE_QUATERNION;
  26080. /**
  26081. * Matrix animation type
  26082. */
  26083. private static _ANIMATIONTYPE_MATRIX;
  26084. /**
  26085. * Color3 animation type
  26086. */
  26087. private static _ANIMATIONTYPE_COLOR3;
  26088. /**
  26089. * Vector2 animation type
  26090. */
  26091. private static _ANIMATIONTYPE_VECTOR2;
  26092. /**
  26093. * Size animation type
  26094. */
  26095. private static _ANIMATIONTYPE_SIZE;
  26096. /**
  26097. * Relative Loop Mode
  26098. */
  26099. private static _ANIMATIONLOOPMODE_RELATIVE;
  26100. /**
  26101. * Cycle Loop Mode
  26102. */
  26103. private static _ANIMATIONLOOPMODE_CYCLE;
  26104. /**
  26105. * Constant Loop Mode
  26106. */
  26107. private static _ANIMATIONLOOPMODE_CONSTANT;
  26108. /**
  26109. * Get the float animation type
  26110. */
  26111. static readonly ANIMATIONTYPE_FLOAT: number;
  26112. /**
  26113. * Get the Vector3 animation type
  26114. */
  26115. static readonly ANIMATIONTYPE_VECTOR3: number;
  26116. /**
  26117. * Get the Vector2 animation type
  26118. */
  26119. static readonly ANIMATIONTYPE_VECTOR2: number;
  26120. /**
  26121. * Get the Size animation type
  26122. */
  26123. static readonly ANIMATIONTYPE_SIZE: number;
  26124. /**
  26125. * Get the Quaternion animation type
  26126. */
  26127. static readonly ANIMATIONTYPE_QUATERNION: number;
  26128. /**
  26129. * Get the Matrix animation type
  26130. */
  26131. static readonly ANIMATIONTYPE_MATRIX: number;
  26132. /**
  26133. * Get the Color3 animation type
  26134. */
  26135. static readonly ANIMATIONTYPE_COLOR3: number;
  26136. /**
  26137. * Get the Relative Loop Mode
  26138. */
  26139. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26140. /**
  26141. * Get the Cycle Loop Mode
  26142. */
  26143. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26144. /**
  26145. * Get the Constant Loop Mode
  26146. */
  26147. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26148. /** @hidden */
  26149. static _UniversalLerp(left: any, right: any, amount: number): any;
  26150. /**
  26151. * Parses an animation object and creates an animation
  26152. * @param parsedAnimation Parsed animation object
  26153. * @returns Animation object
  26154. */
  26155. static Parse(parsedAnimation: any): Animation;
  26156. /**
  26157. * Appends the serialized animations from the source animations
  26158. * @param source Source containing the animations
  26159. * @param destination Target to store the animations
  26160. */
  26161. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26162. }
  26163. }
  26164. declare module "babylonjs/Materials/Textures/baseTexture" {
  26165. import { Observable } from "babylonjs/Misc/observable";
  26166. import { IAnimatable } from "babylonjs/Misc/tools";
  26167. import { Nullable } from "babylonjs/types";
  26168. import { Scene } from "babylonjs/scene";
  26169. import { Matrix, ISize } from "babylonjs/Maths/math";
  26170. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26171. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26172. /**
  26173. * Base class of all the textures in babylon.
  26174. * It groups all the common properties the materials, post process, lights... might need
  26175. * in order to make a correct use of the texture.
  26176. */
  26177. export class BaseTexture implements IAnimatable {
  26178. /**
  26179. * Default anisotropic filtering level for the application.
  26180. * It is set to 4 as a good tradeoff between perf and quality.
  26181. */
  26182. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26183. /**
  26184. * Gets or sets the unique id of the texture
  26185. */
  26186. uniqueId: number;
  26187. /**
  26188. * Define the name of the texture.
  26189. */
  26190. name: string;
  26191. /**
  26192. * Gets or sets an object used to store user defined information.
  26193. */
  26194. metadata: any;
  26195. /**
  26196. * For internal use only. Please do not use.
  26197. */
  26198. reservedDataStore: any;
  26199. private _hasAlpha;
  26200. /**
  26201. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26202. */
  26203. hasAlpha: boolean;
  26204. /**
  26205. * Defines if the alpha value should be determined via the rgb values.
  26206. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26207. */
  26208. getAlphaFromRGB: boolean;
  26209. /**
  26210. * Intensity or strength of the texture.
  26211. * It is commonly used by materials to fine tune the intensity of the texture
  26212. */
  26213. level: number;
  26214. /**
  26215. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26216. * This is part of the texture as textures usually maps to one uv set.
  26217. */
  26218. coordinatesIndex: number;
  26219. private _coordinatesMode;
  26220. /**
  26221. * How a texture is mapped.
  26222. *
  26223. * | Value | Type | Description |
  26224. * | ----- | ----------------------------------- | ----------- |
  26225. * | 0 | EXPLICIT_MODE | |
  26226. * | 1 | SPHERICAL_MODE | |
  26227. * | 2 | PLANAR_MODE | |
  26228. * | 3 | CUBIC_MODE | |
  26229. * | 4 | PROJECTION_MODE | |
  26230. * | 5 | SKYBOX_MODE | |
  26231. * | 6 | INVCUBIC_MODE | |
  26232. * | 7 | EQUIRECTANGULAR_MODE | |
  26233. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26234. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26235. */
  26236. coordinatesMode: number;
  26237. /**
  26238. * | Value | Type | Description |
  26239. * | ----- | ------------------ | ----------- |
  26240. * | 0 | CLAMP_ADDRESSMODE | |
  26241. * | 1 | WRAP_ADDRESSMODE | |
  26242. * | 2 | MIRROR_ADDRESSMODE | |
  26243. */
  26244. wrapU: number;
  26245. /**
  26246. * | Value | Type | Description |
  26247. * | ----- | ------------------ | ----------- |
  26248. * | 0 | CLAMP_ADDRESSMODE | |
  26249. * | 1 | WRAP_ADDRESSMODE | |
  26250. * | 2 | MIRROR_ADDRESSMODE | |
  26251. */
  26252. wrapV: number;
  26253. /**
  26254. * | Value | Type | Description |
  26255. * | ----- | ------------------ | ----------- |
  26256. * | 0 | CLAMP_ADDRESSMODE | |
  26257. * | 1 | WRAP_ADDRESSMODE | |
  26258. * | 2 | MIRROR_ADDRESSMODE | |
  26259. */
  26260. wrapR: number;
  26261. /**
  26262. * With compliant hardware and browser (supporting anisotropic filtering)
  26263. * this defines the level of anisotropic filtering in the texture.
  26264. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26265. */
  26266. anisotropicFilteringLevel: number;
  26267. /**
  26268. * Define if the texture is a cube texture or if false a 2d texture.
  26269. */
  26270. isCube: boolean;
  26271. /**
  26272. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26273. */
  26274. is3D: boolean;
  26275. /**
  26276. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26277. * HDR texture are usually stored in linear space.
  26278. * This only impacts the PBR and Background materials
  26279. */
  26280. gammaSpace: boolean;
  26281. /**
  26282. * Gets whether or not the texture contains RGBD data.
  26283. */
  26284. readonly isRGBD: boolean;
  26285. /**
  26286. * Is Z inverted in the texture (useful in a cube texture).
  26287. */
  26288. invertZ: boolean;
  26289. /**
  26290. * Are mip maps generated for this texture or not.
  26291. */
  26292. readonly noMipmap: boolean;
  26293. /**
  26294. * @hidden
  26295. */
  26296. lodLevelInAlpha: boolean;
  26297. /**
  26298. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26299. */
  26300. lodGenerationOffset: number;
  26301. /**
  26302. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26303. */
  26304. lodGenerationScale: number;
  26305. /**
  26306. * Define if the texture is a render target.
  26307. */
  26308. isRenderTarget: boolean;
  26309. /**
  26310. * Define the unique id of the texture in the scene.
  26311. */
  26312. readonly uid: string;
  26313. /**
  26314. * Return a string representation of the texture.
  26315. * @returns the texture as a string
  26316. */
  26317. toString(): string;
  26318. /**
  26319. * Get the class name of the texture.
  26320. * @returns "BaseTexture"
  26321. */
  26322. getClassName(): string;
  26323. /**
  26324. * Define the list of animation attached to the texture.
  26325. */
  26326. animations: import("babylonjs/Animations/animation").Animation[];
  26327. /**
  26328. * An event triggered when the texture is disposed.
  26329. */
  26330. onDisposeObservable: Observable<BaseTexture>;
  26331. private _onDisposeObserver;
  26332. /**
  26333. * Callback triggered when the texture has been disposed.
  26334. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26335. */
  26336. onDispose: () => void;
  26337. /**
  26338. * Define the current state of the loading sequence when in delayed load mode.
  26339. */
  26340. delayLoadState: number;
  26341. private _scene;
  26342. /** @hidden */
  26343. _texture: Nullable<InternalTexture>;
  26344. private _uid;
  26345. /**
  26346. * Define if the texture is preventinga material to render or not.
  26347. * If not and the texture is not ready, the engine will use a default black texture instead.
  26348. */
  26349. readonly isBlocking: boolean;
  26350. /**
  26351. * Instantiates a new BaseTexture.
  26352. * Base class of all the textures in babylon.
  26353. * It groups all the common properties the materials, post process, lights... might need
  26354. * in order to make a correct use of the texture.
  26355. * @param scene Define the scene the texture blongs to
  26356. */
  26357. constructor(scene: Nullable<Scene>);
  26358. /**
  26359. * Get the scene the texture belongs to.
  26360. * @returns the scene or null if undefined
  26361. */
  26362. getScene(): Nullable<Scene>;
  26363. /**
  26364. * Get the texture transform matrix used to offset tile the texture for istance.
  26365. * @returns the transformation matrix
  26366. */
  26367. getTextureMatrix(): Matrix;
  26368. /**
  26369. * Get the texture reflection matrix used to rotate/transform the reflection.
  26370. * @returns the reflection matrix
  26371. */
  26372. getReflectionTextureMatrix(): Matrix;
  26373. /**
  26374. * Get the underlying lower level texture from Babylon.
  26375. * @returns the insternal texture
  26376. */
  26377. getInternalTexture(): Nullable<InternalTexture>;
  26378. /**
  26379. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26380. * @returns true if ready or not blocking
  26381. */
  26382. isReadyOrNotBlocking(): boolean;
  26383. /**
  26384. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26385. * @returns true if fully ready
  26386. */
  26387. isReady(): boolean;
  26388. private _cachedSize;
  26389. /**
  26390. * Get the size of the texture.
  26391. * @returns the texture size.
  26392. */
  26393. getSize(): ISize;
  26394. /**
  26395. * Get the base size of the texture.
  26396. * It can be different from the size if the texture has been resized for POT for instance
  26397. * @returns the base size
  26398. */
  26399. getBaseSize(): ISize;
  26400. /**
  26401. * Update the sampling mode of the texture.
  26402. * Default is Trilinear mode.
  26403. *
  26404. * | Value | Type | Description |
  26405. * | ----- | ------------------ | ----------- |
  26406. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26407. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26408. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26409. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26410. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26411. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26412. * | 7 | NEAREST_LINEAR | |
  26413. * | 8 | NEAREST_NEAREST | |
  26414. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26415. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26416. * | 11 | LINEAR_LINEAR | |
  26417. * | 12 | LINEAR_NEAREST | |
  26418. *
  26419. * > _mag_: magnification filter (close to the viewer)
  26420. * > _min_: minification filter (far from the viewer)
  26421. * > _mip_: filter used between mip map levels
  26422. *@param samplingMode Define the new sampling mode of the texture
  26423. */
  26424. updateSamplingMode(samplingMode: number): void;
  26425. /**
  26426. * Scales the texture if is `canRescale()`
  26427. * @param ratio the resize factor we want to use to rescale
  26428. */
  26429. scale(ratio: number): void;
  26430. /**
  26431. * Get if the texture can rescale.
  26432. */
  26433. readonly canRescale: boolean;
  26434. /** @hidden */
  26435. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26436. /** @hidden */
  26437. _rebuild(): void;
  26438. /**
  26439. * Triggers the load sequence in delayed load mode.
  26440. */
  26441. delayLoad(): void;
  26442. /**
  26443. * Clones the texture.
  26444. * @returns the cloned texture
  26445. */
  26446. clone(): Nullable<BaseTexture>;
  26447. /**
  26448. * Get the texture underlying type (INT, FLOAT...)
  26449. */
  26450. readonly textureType: number;
  26451. /**
  26452. * Get the texture underlying format (RGB, RGBA...)
  26453. */
  26454. readonly textureFormat: number;
  26455. /**
  26456. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26457. * This will returns an RGBA array buffer containing either in values (0-255) or
  26458. * float values (0-1) depending of the underlying buffer type.
  26459. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26460. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26461. * @param buffer defines a user defined buffer to fill with data (can be null)
  26462. * @returns The Array buffer containing the pixels data.
  26463. */
  26464. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26465. /**
  26466. * Release and destroy the underlying lower level texture aka internalTexture.
  26467. */
  26468. releaseInternalTexture(): void;
  26469. /**
  26470. * Get the polynomial representation of the texture data.
  26471. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26472. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26473. */
  26474. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26475. /** @hidden */
  26476. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26477. /** @hidden */
  26478. readonly _lodTextureMid: Nullable<BaseTexture>;
  26479. /** @hidden */
  26480. readonly _lodTextureLow: Nullable<BaseTexture>;
  26481. /**
  26482. * Dispose the texture and release its associated resources.
  26483. */
  26484. dispose(): void;
  26485. /**
  26486. * Serialize the texture into a JSON representation that can be parsed later on.
  26487. * @returns the JSON representation of the texture
  26488. */
  26489. serialize(): any;
  26490. /**
  26491. * Helper function to be called back once a list of texture contains only ready textures.
  26492. * @param textures Define the list of textures to wait for
  26493. * @param callback Define the callback triggered once the entire list will be ready
  26494. */
  26495. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26496. }
  26497. }
  26498. declare module "babylonjs/Materials/uniformBuffer" {
  26499. import { Nullable, FloatArray } from "babylonjs/types";
  26500. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26501. import { Engine } from "babylonjs/Engines/engine";
  26502. import { Effect } from "babylonjs/Materials/effect";
  26503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26504. /**
  26505. * Uniform buffer objects.
  26506. *
  26507. * Handles blocks of uniform on the GPU.
  26508. *
  26509. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26510. *
  26511. * For more information, please refer to :
  26512. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26513. */
  26514. export class UniformBuffer {
  26515. private _engine;
  26516. private _buffer;
  26517. private _data;
  26518. private _bufferData;
  26519. private _dynamic?;
  26520. private _uniformLocations;
  26521. private _uniformSizes;
  26522. private _uniformLocationPointer;
  26523. private _needSync;
  26524. private _noUBO;
  26525. private _currentEffect;
  26526. private static _MAX_UNIFORM_SIZE;
  26527. private static _tempBuffer;
  26528. /**
  26529. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26530. * This is dynamic to allow compat with webgl 1 and 2.
  26531. * You will need to pass the name of the uniform as well as the value.
  26532. */
  26533. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26534. /**
  26535. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26536. * This is dynamic to allow compat with webgl 1 and 2.
  26537. * You will need to pass the name of the uniform as well as the value.
  26538. */
  26539. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26540. /**
  26541. * Lambda to Update a single float in a uniform buffer.
  26542. * This is dynamic to allow compat with webgl 1 and 2.
  26543. * You will need to pass the name of the uniform as well as the value.
  26544. */
  26545. updateFloat: (name: string, x: number) => void;
  26546. /**
  26547. * Lambda to Update a vec2 of float in a uniform buffer.
  26548. * This is dynamic to allow compat with webgl 1 and 2.
  26549. * You will need to pass the name of the uniform as well as the value.
  26550. */
  26551. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26552. /**
  26553. * Lambda to Update a vec3 of float in a uniform buffer.
  26554. * This is dynamic to allow compat with webgl 1 and 2.
  26555. * You will need to pass the name of the uniform as well as the value.
  26556. */
  26557. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26558. /**
  26559. * Lambda to Update a vec4 of float in a uniform buffer.
  26560. * This is dynamic to allow compat with webgl 1 and 2.
  26561. * You will need to pass the name of the uniform as well as the value.
  26562. */
  26563. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26564. /**
  26565. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26566. * This is dynamic to allow compat with webgl 1 and 2.
  26567. * You will need to pass the name of the uniform as well as the value.
  26568. */
  26569. updateMatrix: (name: string, mat: Matrix) => void;
  26570. /**
  26571. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26572. * This is dynamic to allow compat with webgl 1 and 2.
  26573. * You will need to pass the name of the uniform as well as the value.
  26574. */
  26575. updateVector3: (name: string, vector: Vector3) => void;
  26576. /**
  26577. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26578. * This is dynamic to allow compat with webgl 1 and 2.
  26579. * You will need to pass the name of the uniform as well as the value.
  26580. */
  26581. updateVector4: (name: string, vector: Vector4) => void;
  26582. /**
  26583. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26584. * This is dynamic to allow compat with webgl 1 and 2.
  26585. * You will need to pass the name of the uniform as well as the value.
  26586. */
  26587. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26588. /**
  26589. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26590. * This is dynamic to allow compat with webgl 1 and 2.
  26591. * You will need to pass the name of the uniform as well as the value.
  26592. */
  26593. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26594. /**
  26595. * Instantiates a new Uniform buffer objects.
  26596. *
  26597. * Handles blocks of uniform on the GPU.
  26598. *
  26599. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26600. *
  26601. * For more information, please refer to :
  26602. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26603. * @param engine Define the engine the buffer is associated with
  26604. * @param data Define the data contained in the buffer
  26605. * @param dynamic Define if the buffer is updatable
  26606. */
  26607. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26608. /**
  26609. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26610. * or just falling back on setUniformXXX calls.
  26611. */
  26612. readonly useUbo: boolean;
  26613. /**
  26614. * Indicates if the WebGL underlying uniform buffer is in sync
  26615. * with the javascript cache data.
  26616. */
  26617. readonly isSync: boolean;
  26618. /**
  26619. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26620. * Also, a dynamic UniformBuffer will disable cache verification and always
  26621. * update the underlying WebGL uniform buffer to the GPU.
  26622. * @returns if Dynamic, otherwise false
  26623. */
  26624. isDynamic(): boolean;
  26625. /**
  26626. * The data cache on JS side.
  26627. * @returns the underlying data as a float array
  26628. */
  26629. getData(): Float32Array;
  26630. /**
  26631. * The underlying WebGL Uniform buffer.
  26632. * @returns the webgl buffer
  26633. */
  26634. getBuffer(): Nullable<WebGLBuffer>;
  26635. /**
  26636. * std140 layout specifies how to align data within an UBO structure.
  26637. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26638. * for specs.
  26639. */
  26640. private _fillAlignment;
  26641. /**
  26642. * Adds an uniform in the buffer.
  26643. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26644. * for the layout to be correct !
  26645. * @param name Name of the uniform, as used in the uniform block in the shader.
  26646. * @param size Data size, or data directly.
  26647. */
  26648. addUniform(name: string, size: number | number[]): void;
  26649. /**
  26650. * Adds a Matrix 4x4 to the uniform buffer.
  26651. * @param name Name of the uniform, as used in the uniform block in the shader.
  26652. * @param mat A 4x4 matrix.
  26653. */
  26654. addMatrix(name: string, mat: Matrix): void;
  26655. /**
  26656. * Adds a vec2 to the uniform buffer.
  26657. * @param name Name of the uniform, as used in the uniform block in the shader.
  26658. * @param x Define the x component value of the vec2
  26659. * @param y Define the y component value of the vec2
  26660. */
  26661. addFloat2(name: string, x: number, y: number): void;
  26662. /**
  26663. * Adds a vec3 to the uniform buffer.
  26664. * @param name Name of the uniform, as used in the uniform block in the shader.
  26665. * @param x Define the x component value of the vec3
  26666. * @param y Define the y component value of the vec3
  26667. * @param z Define the z component value of the vec3
  26668. */
  26669. addFloat3(name: string, x: number, y: number, z: number): void;
  26670. /**
  26671. * Adds a vec3 to the uniform buffer.
  26672. * @param name Name of the uniform, as used in the uniform block in the shader.
  26673. * @param color Define the vec3 from a Color
  26674. */
  26675. addColor3(name: string, color: Color3): void;
  26676. /**
  26677. * Adds a vec4 to the uniform buffer.
  26678. * @param name Name of the uniform, as used in the uniform block in the shader.
  26679. * @param color Define the rgb components from a Color
  26680. * @param alpha Define the a component of the vec4
  26681. */
  26682. addColor4(name: string, color: Color3, alpha: number): void;
  26683. /**
  26684. * Adds a vec3 to the uniform buffer.
  26685. * @param name Name of the uniform, as used in the uniform block in the shader.
  26686. * @param vector Define the vec3 components from a Vector
  26687. */
  26688. addVector3(name: string, vector: Vector3): void;
  26689. /**
  26690. * Adds a Matrix 3x3 to the uniform buffer.
  26691. * @param name Name of the uniform, as used in the uniform block in the shader.
  26692. */
  26693. addMatrix3x3(name: string): void;
  26694. /**
  26695. * Adds a Matrix 2x2 to the uniform buffer.
  26696. * @param name Name of the uniform, as used in the uniform block in the shader.
  26697. */
  26698. addMatrix2x2(name: string): void;
  26699. /**
  26700. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26701. */
  26702. create(): void;
  26703. /** @hidden */
  26704. _rebuild(): void;
  26705. /**
  26706. * Updates the WebGL Uniform Buffer on the GPU.
  26707. * If the `dynamic` flag is set to true, no cache comparison is done.
  26708. * Otherwise, the buffer will be updated only if the cache differs.
  26709. */
  26710. update(): void;
  26711. /**
  26712. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26713. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26714. * @param data Define the flattened data
  26715. * @param size Define the size of the data.
  26716. */
  26717. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26718. private _updateMatrix3x3ForUniform;
  26719. private _updateMatrix3x3ForEffect;
  26720. private _updateMatrix2x2ForEffect;
  26721. private _updateMatrix2x2ForUniform;
  26722. private _updateFloatForEffect;
  26723. private _updateFloatForUniform;
  26724. private _updateFloat2ForEffect;
  26725. private _updateFloat2ForUniform;
  26726. private _updateFloat3ForEffect;
  26727. private _updateFloat3ForUniform;
  26728. private _updateFloat4ForEffect;
  26729. private _updateFloat4ForUniform;
  26730. private _updateMatrixForEffect;
  26731. private _updateMatrixForUniform;
  26732. private _updateVector3ForEffect;
  26733. private _updateVector3ForUniform;
  26734. private _updateVector4ForEffect;
  26735. private _updateVector4ForUniform;
  26736. private _updateColor3ForEffect;
  26737. private _updateColor3ForUniform;
  26738. private _updateColor4ForEffect;
  26739. private _updateColor4ForUniform;
  26740. /**
  26741. * Sets a sampler uniform on the effect.
  26742. * @param name Define the name of the sampler.
  26743. * @param texture Define the texture to set in the sampler
  26744. */
  26745. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26746. /**
  26747. * Directly updates the value of the uniform in the cache AND on the GPU.
  26748. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26749. * @param data Define the flattened data
  26750. */
  26751. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26752. /**
  26753. * Binds this uniform buffer to an effect.
  26754. * @param effect Define the effect to bind the buffer to
  26755. * @param name Name of the uniform block in the shader.
  26756. */
  26757. bindToEffect(effect: Effect, name: string): void;
  26758. /**
  26759. * Disposes the uniform buffer.
  26760. */
  26761. dispose(): void;
  26762. }
  26763. }
  26764. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26765. import { Nullable } from "babylonjs/types";
  26766. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26767. /**
  26768. * This represents the required contract to create a new type of texture loader.
  26769. */
  26770. export interface IInternalTextureLoader {
  26771. /**
  26772. * Defines wether the loader supports cascade loading the different faces.
  26773. */
  26774. supportCascades: boolean;
  26775. /**
  26776. * This returns if the loader support the current file information.
  26777. * @param extension defines the file extension of the file being loaded
  26778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26779. * @param fallback defines the fallback internal texture if any
  26780. * @param isBase64 defines whether the texture is encoded as a base64
  26781. * @param isBuffer defines whether the texture data are stored as a buffer
  26782. * @returns true if the loader can load the specified file
  26783. */
  26784. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26785. /**
  26786. * Transform the url before loading if required.
  26787. * @param rootUrl the url of the texture
  26788. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26789. * @returns the transformed texture
  26790. */
  26791. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26792. /**
  26793. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26794. * @param rootUrl the url of the texture
  26795. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26796. * @returns the fallback texture
  26797. */
  26798. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26799. /**
  26800. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26801. * @param data contains the texture data
  26802. * @param texture defines the BabylonJS internal texture
  26803. * @param createPolynomials will be true if polynomials have been requested
  26804. * @param onLoad defines the callback to trigger once the texture is ready
  26805. * @param onError defines the callback to trigger in case of error
  26806. */
  26807. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26808. /**
  26809. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26810. * @param data contains the texture data
  26811. * @param texture defines the BabylonJS internal texture
  26812. * @param callback defines the method to call once ready to upload
  26813. */
  26814. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26815. }
  26816. }
  26817. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26818. import { Scene } from "babylonjs/scene";
  26819. import { Engine } from "babylonjs/Engines/engine";
  26820. import { Texture } from "babylonjs/Materials/Textures/texture";
  26821. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26822. /**
  26823. * Creation options of the multi render target texture.
  26824. */
  26825. export interface IMultiRenderTargetOptions {
  26826. /**
  26827. * Define if the texture needs to create mip maps after render.
  26828. */
  26829. generateMipMaps?: boolean;
  26830. /**
  26831. * Define the types of all the draw buffers we want to create
  26832. */
  26833. types?: number[];
  26834. /**
  26835. * Define the sampling modes of all the draw buffers we want to create
  26836. */
  26837. samplingModes?: number[];
  26838. /**
  26839. * Define if a depth buffer is required
  26840. */
  26841. generateDepthBuffer?: boolean;
  26842. /**
  26843. * Define if a stencil buffer is required
  26844. */
  26845. generateStencilBuffer?: boolean;
  26846. /**
  26847. * Define if a depth texture is required instead of a depth buffer
  26848. */
  26849. generateDepthTexture?: boolean;
  26850. /**
  26851. * Define the number of desired draw buffers
  26852. */
  26853. textureCount?: number;
  26854. /**
  26855. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26856. */
  26857. doNotChangeAspectRatio?: boolean;
  26858. /**
  26859. * Define the default type of the buffers we are creating
  26860. */
  26861. defaultType?: number;
  26862. }
  26863. /**
  26864. * A multi render target, like a render target provides the ability to render to a texture.
  26865. * Unlike the render target, it can render to several draw buffers in one draw.
  26866. * This is specially interesting in deferred rendering or for any effects requiring more than
  26867. * just one color from a single pass.
  26868. */
  26869. export class MultiRenderTarget extends RenderTargetTexture {
  26870. private _internalTextures;
  26871. private _textures;
  26872. private _multiRenderTargetOptions;
  26873. /**
  26874. * Get if draw buffers are currently supported by the used hardware and browser.
  26875. */
  26876. readonly isSupported: boolean;
  26877. /**
  26878. * Get the list of textures generated by the multi render target.
  26879. */
  26880. readonly textures: Texture[];
  26881. /**
  26882. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26883. */
  26884. readonly depthTexture: Texture;
  26885. /**
  26886. * Set the wrapping mode on U of all the textures we are rendering to.
  26887. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26888. */
  26889. wrapU: number;
  26890. /**
  26891. * Set the wrapping mode on V of all the textures we are rendering to.
  26892. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26893. */
  26894. wrapV: number;
  26895. /**
  26896. * Instantiate a new multi render target texture.
  26897. * A multi render target, like a render target provides the ability to render to a texture.
  26898. * Unlike the render target, it can render to several draw buffers in one draw.
  26899. * This is specially interesting in deferred rendering or for any effects requiring more than
  26900. * just one color from a single pass.
  26901. * @param name Define the name of the texture
  26902. * @param size Define the size of the buffers to render to
  26903. * @param count Define the number of target we are rendering into
  26904. * @param scene Define the scene the texture belongs to
  26905. * @param options Define the options used to create the multi render target
  26906. */
  26907. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26908. /** @hidden */
  26909. _rebuild(): void;
  26910. private _createInternalTextures;
  26911. private _createTextures;
  26912. /**
  26913. * Define the number of samples used if MSAA is enabled.
  26914. */
  26915. samples: number;
  26916. /**
  26917. * Resize all the textures in the multi render target.
  26918. * Be carrefull as it will recreate all the data in the new texture.
  26919. * @param size Define the new size
  26920. */
  26921. resize(size: any): void;
  26922. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26923. /**
  26924. * Dispose the render targets and their associated resources
  26925. */
  26926. dispose(): void;
  26927. /**
  26928. * Release all the underlying texture used as draw buffers.
  26929. */
  26930. releaseInternalTextures(): void;
  26931. }
  26932. }
  26933. declare module "babylonjs/Audio/analyser" {
  26934. import { Scene } from "babylonjs/scene";
  26935. /**
  26936. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26938. */
  26939. export class Analyser {
  26940. /**
  26941. * Gets or sets the smoothing
  26942. * @ignorenaming
  26943. */
  26944. SMOOTHING: number;
  26945. /**
  26946. * Gets or sets the FFT table size
  26947. * @ignorenaming
  26948. */
  26949. FFT_SIZE: number;
  26950. /**
  26951. * Gets or sets the bar graph amplitude
  26952. * @ignorenaming
  26953. */
  26954. BARGRAPHAMPLITUDE: number;
  26955. /**
  26956. * Gets or sets the position of the debug canvas
  26957. * @ignorenaming
  26958. */
  26959. DEBUGCANVASPOS: {
  26960. x: number;
  26961. y: number;
  26962. };
  26963. /**
  26964. * Gets or sets the debug canvas size
  26965. * @ignorenaming
  26966. */
  26967. DEBUGCANVASSIZE: {
  26968. width: number;
  26969. height: number;
  26970. };
  26971. private _byteFreqs;
  26972. private _byteTime;
  26973. private _floatFreqs;
  26974. private _webAudioAnalyser;
  26975. private _debugCanvas;
  26976. private _debugCanvasContext;
  26977. private _scene;
  26978. private _registerFunc;
  26979. private _audioEngine;
  26980. /**
  26981. * Creates a new analyser
  26982. * @param scene defines hosting scene
  26983. */
  26984. constructor(scene: Scene);
  26985. /**
  26986. * Get the number of data values you will have to play with for the visualization
  26987. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26988. * @returns a number
  26989. */
  26990. getFrequencyBinCount(): number;
  26991. /**
  26992. * Gets the current frequency data as a byte array
  26993. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26994. * @returns a Uint8Array
  26995. */
  26996. getByteFrequencyData(): Uint8Array;
  26997. /**
  26998. * Gets the current waveform as a byte array
  26999. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27000. * @returns a Uint8Array
  27001. */
  27002. getByteTimeDomainData(): Uint8Array;
  27003. /**
  27004. * Gets the current frequency data as a float array
  27005. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27006. * @returns a Float32Array
  27007. */
  27008. getFloatFrequencyData(): Float32Array;
  27009. /**
  27010. * Renders the debug canvas
  27011. */
  27012. drawDebugCanvas(): void;
  27013. /**
  27014. * Stops rendering the debug canvas and removes it
  27015. */
  27016. stopDebugCanvas(): void;
  27017. /**
  27018. * Connects two audio nodes
  27019. * @param inputAudioNode defines first node to connect
  27020. * @param outputAudioNode defines second node to connect
  27021. */
  27022. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27023. /**
  27024. * Releases all associated resources
  27025. */
  27026. dispose(): void;
  27027. }
  27028. }
  27029. declare module "babylonjs/Audio/audioEngine" {
  27030. import { IDisposable } from "babylonjs/scene";
  27031. import { Analyser } from "babylonjs/Audio/analyser";
  27032. import { Nullable } from "babylonjs/types";
  27033. import { Observable } from "babylonjs/Misc/observable";
  27034. /**
  27035. * This represents an audio engine and it is responsible
  27036. * to play, synchronize and analyse sounds throughout the application.
  27037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27038. */
  27039. export interface IAudioEngine extends IDisposable {
  27040. /**
  27041. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27042. */
  27043. readonly canUseWebAudio: boolean;
  27044. /**
  27045. * Gets the current AudioContext if available.
  27046. */
  27047. readonly audioContext: Nullable<AudioContext>;
  27048. /**
  27049. * The master gain node defines the global audio volume of your audio engine.
  27050. */
  27051. readonly masterGain: GainNode;
  27052. /**
  27053. * Gets whether or not mp3 are supported by your browser.
  27054. */
  27055. readonly isMP3supported: boolean;
  27056. /**
  27057. * Gets whether or not ogg are supported by your browser.
  27058. */
  27059. readonly isOGGsupported: boolean;
  27060. /**
  27061. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27062. * @ignoreNaming
  27063. */
  27064. WarnedWebAudioUnsupported: boolean;
  27065. /**
  27066. * Defines if the audio engine relies on a custom unlocked button.
  27067. * In this case, the embedded button will not be displayed.
  27068. */
  27069. useCustomUnlockedButton: boolean;
  27070. /**
  27071. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27072. */
  27073. readonly unlocked: boolean;
  27074. /**
  27075. * Event raised when audio has been unlocked on the browser.
  27076. */
  27077. onAudioUnlockedObservable: Observable<AudioEngine>;
  27078. /**
  27079. * Event raised when audio has been locked on the browser.
  27080. */
  27081. onAudioLockedObservable: Observable<AudioEngine>;
  27082. /**
  27083. * Flags the audio engine in Locked state.
  27084. * This happens due to new browser policies preventing audio to autoplay.
  27085. */
  27086. lock(): void;
  27087. /**
  27088. * Unlocks the audio engine once a user action has been done on the dom.
  27089. * This is helpful to resume play once browser policies have been satisfied.
  27090. */
  27091. unlock(): void;
  27092. }
  27093. /**
  27094. * This represents the default audio engine used in babylon.
  27095. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27097. */
  27098. export class AudioEngine implements IAudioEngine {
  27099. private _audioContext;
  27100. private _audioContextInitialized;
  27101. private _muteButton;
  27102. private _hostElement;
  27103. /**
  27104. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27105. */
  27106. canUseWebAudio: boolean;
  27107. /**
  27108. * The master gain node defines the global audio volume of your audio engine.
  27109. */
  27110. masterGain: GainNode;
  27111. /**
  27112. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27113. * @ignoreNaming
  27114. */
  27115. WarnedWebAudioUnsupported: boolean;
  27116. /**
  27117. * Gets whether or not mp3 are supported by your browser.
  27118. */
  27119. isMP3supported: boolean;
  27120. /**
  27121. * Gets whether or not ogg are supported by your browser.
  27122. */
  27123. isOGGsupported: boolean;
  27124. /**
  27125. * Gets whether audio has been unlocked on the device.
  27126. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27127. * a user interaction has happened.
  27128. */
  27129. unlocked: boolean;
  27130. /**
  27131. * Defines if the audio engine relies on a custom unlocked button.
  27132. * In this case, the embedded button will not be displayed.
  27133. */
  27134. useCustomUnlockedButton: boolean;
  27135. /**
  27136. * Event raised when audio has been unlocked on the browser.
  27137. */
  27138. onAudioUnlockedObservable: Observable<AudioEngine>;
  27139. /**
  27140. * Event raised when audio has been locked on the browser.
  27141. */
  27142. onAudioLockedObservable: Observable<AudioEngine>;
  27143. /**
  27144. * Gets the current AudioContext if available.
  27145. */
  27146. readonly audioContext: Nullable<AudioContext>;
  27147. private _connectedAnalyser;
  27148. /**
  27149. * Instantiates a new audio engine.
  27150. *
  27151. * There should be only one per page as some browsers restrict the number
  27152. * of audio contexts you can create.
  27153. * @param hostElement defines the host element where to display the mute icon if necessary
  27154. */
  27155. constructor(hostElement?: Nullable<HTMLElement>);
  27156. /**
  27157. * Flags the audio engine in Locked state.
  27158. * This happens due to new browser policies preventing audio to autoplay.
  27159. */
  27160. lock(): void;
  27161. /**
  27162. * Unlocks the audio engine once a user action has been done on the dom.
  27163. * This is helpful to resume play once browser policies have been satisfied.
  27164. */
  27165. unlock(): void;
  27166. private _resumeAudioContext;
  27167. private _initializeAudioContext;
  27168. private _tryToRun;
  27169. private _triggerRunningState;
  27170. private _triggerSuspendedState;
  27171. private _displayMuteButton;
  27172. private _moveButtonToTopLeft;
  27173. private _onResize;
  27174. private _hideMuteButton;
  27175. /**
  27176. * Destroy and release the resources associated with the audio ccontext.
  27177. */
  27178. dispose(): void;
  27179. /**
  27180. * Gets the global volume sets on the master gain.
  27181. * @returns the global volume if set or -1 otherwise
  27182. */
  27183. getGlobalVolume(): number;
  27184. /**
  27185. * Sets the global volume of your experience (sets on the master gain).
  27186. * @param newVolume Defines the new global volume of the application
  27187. */
  27188. setGlobalVolume(newVolume: number): void;
  27189. /**
  27190. * Connect the audio engine to an audio analyser allowing some amazing
  27191. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27193. * @param analyser The analyser to connect to the engine
  27194. */
  27195. connectToAnalyser(analyser: Analyser): void;
  27196. }
  27197. }
  27198. declare module "babylonjs/Loading/loadingScreen" {
  27199. /**
  27200. * Interface used to present a loading screen while loading a scene
  27201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27202. */
  27203. export interface ILoadingScreen {
  27204. /**
  27205. * Function called to display the loading screen
  27206. */
  27207. displayLoadingUI: () => void;
  27208. /**
  27209. * Function called to hide the loading screen
  27210. */
  27211. hideLoadingUI: () => void;
  27212. /**
  27213. * Gets or sets the color to use for the background
  27214. */
  27215. loadingUIBackgroundColor: string;
  27216. /**
  27217. * Gets or sets the text to display while loading
  27218. */
  27219. loadingUIText: string;
  27220. }
  27221. /**
  27222. * Class used for the default loading screen
  27223. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27224. */
  27225. export class DefaultLoadingScreen implements ILoadingScreen {
  27226. private _renderingCanvas;
  27227. private _loadingText;
  27228. private _loadingDivBackgroundColor;
  27229. private _loadingDiv;
  27230. private _loadingTextDiv;
  27231. /**
  27232. * Creates a new default loading screen
  27233. * @param _renderingCanvas defines the canvas used to render the scene
  27234. * @param _loadingText defines the default text to display
  27235. * @param _loadingDivBackgroundColor defines the default background color
  27236. */
  27237. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27238. /**
  27239. * Function called to display the loading screen
  27240. */
  27241. displayLoadingUI(): void;
  27242. /**
  27243. * Function called to hide the loading screen
  27244. */
  27245. hideLoadingUI(): void;
  27246. /**
  27247. * Gets or sets the text to display while loading
  27248. */
  27249. loadingUIText: string;
  27250. /**
  27251. * Gets or sets the color to use for the background
  27252. */
  27253. loadingUIBackgroundColor: string;
  27254. private _resizeLoadingUI;
  27255. }
  27256. }
  27257. declare module "babylonjs/Materials/Textures/videoTexture" {
  27258. import { Observable } from "babylonjs/Misc/observable";
  27259. import { Nullable } from "babylonjs/types";
  27260. import { Scene } from "babylonjs/scene";
  27261. import { Texture } from "babylonjs/Materials/Textures/texture";
  27262. /**
  27263. * Settings for finer control over video usage
  27264. */
  27265. export interface VideoTextureSettings {
  27266. /**
  27267. * Applies `autoplay` to video, if specified
  27268. */
  27269. autoPlay?: boolean;
  27270. /**
  27271. * Applies `loop` to video, if specified
  27272. */
  27273. loop?: boolean;
  27274. /**
  27275. * Automatically updates internal texture from video at every frame in the render loop
  27276. */
  27277. autoUpdateTexture: boolean;
  27278. /**
  27279. * Image src displayed during the video loading or until the user interacts with the video.
  27280. */
  27281. poster?: string;
  27282. }
  27283. /**
  27284. * If you want to display a video in your scene, this is the special texture for that.
  27285. * This special texture works similar to other textures, with the exception of a few parameters.
  27286. * @see https://doc.babylonjs.com/how_to/video_texture
  27287. */
  27288. export class VideoTexture extends Texture {
  27289. /**
  27290. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27291. */
  27292. readonly autoUpdateTexture: boolean;
  27293. /**
  27294. * The video instance used by the texture internally
  27295. */
  27296. readonly video: HTMLVideoElement;
  27297. private _onUserActionRequestedObservable;
  27298. /**
  27299. * Event triggerd when a dom action is required by the user to play the video.
  27300. * This happens due to recent changes in browser policies preventing video to auto start.
  27301. */
  27302. readonly onUserActionRequestedObservable: Observable<Texture>;
  27303. private _generateMipMaps;
  27304. private _engine;
  27305. private _stillImageCaptured;
  27306. private _displayingPosterTexture;
  27307. private _settings;
  27308. private _createInternalTextureOnEvent;
  27309. /**
  27310. * Creates a video texture.
  27311. * If you want to display a video in your scene, this is the special texture for that.
  27312. * This special texture works similar to other textures, with the exception of a few parameters.
  27313. * @see https://doc.babylonjs.com/how_to/video_texture
  27314. * @param name optional name, will detect from video source, if not defined
  27315. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27316. * @param scene is obviously the current scene.
  27317. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27318. * @param invertY is false by default but can be used to invert video on Y axis
  27319. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27320. * @param settings allows finer control over video usage
  27321. */
  27322. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27323. private _getName;
  27324. private _getVideo;
  27325. private _createInternalTexture;
  27326. private reset;
  27327. /**
  27328. * @hidden Internal method to initiate `update`.
  27329. */
  27330. _rebuild(): void;
  27331. /**
  27332. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27333. */
  27334. update(): void;
  27335. /**
  27336. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27337. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27338. */
  27339. updateTexture(isVisible: boolean): void;
  27340. protected _updateInternalTexture: () => void;
  27341. /**
  27342. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27343. * @param url New url.
  27344. */
  27345. updateURL(url: string): void;
  27346. /**
  27347. * Dispose the texture and release its associated resources.
  27348. */
  27349. dispose(): void;
  27350. /**
  27351. * Creates a video texture straight from a stream.
  27352. * @param scene Define the scene the texture should be created in
  27353. * @param stream Define the stream the texture should be created from
  27354. * @returns The created video texture as a promise
  27355. */
  27356. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27357. /**
  27358. * Creates a video texture straight from your WebCam video feed.
  27359. * @param scene Define the scene the texture should be created in
  27360. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27361. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27362. * @returns The created video texture as a promise
  27363. */
  27364. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27365. minWidth: number;
  27366. maxWidth: number;
  27367. minHeight: number;
  27368. maxHeight: number;
  27369. deviceId: string;
  27370. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27371. /**
  27372. * Creates a video texture straight from your WebCam video feed.
  27373. * @param scene Define the scene the texture should be created in
  27374. * @param onReady Define a callback to triggered once the texture will be ready
  27375. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27376. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27377. */
  27378. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27379. minWidth: number;
  27380. maxWidth: number;
  27381. minHeight: number;
  27382. maxHeight: number;
  27383. deviceId: string;
  27384. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27385. }
  27386. }
  27387. declare module "babylonjs/Engines/engine" {
  27388. import { Observable } from "babylonjs/Misc/observable";
  27389. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27390. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27391. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27392. import { Camera } from "babylonjs/Cameras/camera";
  27393. import { Scene } from "babylonjs/scene";
  27394. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27395. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27396. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27397. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27398. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27399. import { Material } from "babylonjs/Materials/material";
  27400. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27401. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27403. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27404. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27405. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27406. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27407. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27408. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27409. import { WebRequest } from "babylonjs/Misc/webRequest";
  27410. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27411. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27412. /**
  27413. * Interface for attribute information associated with buffer instanciation
  27414. */
  27415. export class InstancingAttributeInfo {
  27416. /**
  27417. * Index/offset of the attribute in the vertex shader
  27418. */
  27419. index: number;
  27420. /**
  27421. * size of the attribute, 1, 2, 3 or 4
  27422. */
  27423. attributeSize: number;
  27424. /**
  27425. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27426. * default is FLOAT
  27427. */
  27428. attribyteType: number;
  27429. /**
  27430. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27431. */
  27432. normalized: boolean;
  27433. /**
  27434. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27435. */
  27436. offset: number;
  27437. /**
  27438. * Name of the GLSL attribute, for debugging purpose only
  27439. */
  27440. attributeName: string;
  27441. }
  27442. /**
  27443. * Define options used to create a depth texture
  27444. */
  27445. export class DepthTextureCreationOptions {
  27446. /** Specifies whether or not a stencil should be allocated in the texture */
  27447. generateStencil?: boolean;
  27448. /** Specifies whether or not bilinear filtering is enable on the texture */
  27449. bilinearFiltering?: boolean;
  27450. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27451. comparisonFunction?: number;
  27452. /** Specifies if the created texture is a cube texture */
  27453. isCube?: boolean;
  27454. }
  27455. /**
  27456. * Class used to describe the capabilities of the engine relatively to the current browser
  27457. */
  27458. export class EngineCapabilities {
  27459. /** Maximum textures units per fragment shader */
  27460. maxTexturesImageUnits: number;
  27461. /** Maximum texture units per vertex shader */
  27462. maxVertexTextureImageUnits: number;
  27463. /** Maximum textures units in the entire pipeline */
  27464. maxCombinedTexturesImageUnits: number;
  27465. /** Maximum texture size */
  27466. maxTextureSize: number;
  27467. /** Maximum cube texture size */
  27468. maxCubemapTextureSize: number;
  27469. /** Maximum render texture size */
  27470. maxRenderTextureSize: number;
  27471. /** Maximum number of vertex attributes */
  27472. maxVertexAttribs: number;
  27473. /** Maximum number of varyings */
  27474. maxVaryingVectors: number;
  27475. /** Maximum number of uniforms per vertex shader */
  27476. maxVertexUniformVectors: number;
  27477. /** Maximum number of uniforms per fragment shader */
  27478. maxFragmentUniformVectors: number;
  27479. /** Defines if standard derivates (dx/dy) are supported */
  27480. standardDerivatives: boolean;
  27481. /** Defines if s3tc texture compression is supported */
  27482. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27483. /** Defines if pvrtc texture compression is supported */
  27484. pvrtc: any;
  27485. /** Defines if etc1 texture compression is supported */
  27486. etc1: any;
  27487. /** Defines if etc2 texture compression is supported */
  27488. etc2: any;
  27489. /** Defines if astc texture compression is supported */
  27490. astc: any;
  27491. /** Defines if float textures are supported */
  27492. textureFloat: boolean;
  27493. /** Defines if vertex array objects are supported */
  27494. vertexArrayObject: boolean;
  27495. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27496. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27497. /** Gets the maximum level of anisotropy supported */
  27498. maxAnisotropy: number;
  27499. /** Defines if instancing is supported */
  27500. instancedArrays: boolean;
  27501. /** Defines if 32 bits indices are supported */
  27502. uintIndices: boolean;
  27503. /** Defines if high precision shaders are supported */
  27504. highPrecisionShaderSupported: boolean;
  27505. /** Defines if depth reading in the fragment shader is supported */
  27506. fragmentDepthSupported: boolean;
  27507. /** Defines if float texture linear filtering is supported*/
  27508. textureFloatLinearFiltering: boolean;
  27509. /** Defines if rendering to float textures is supported */
  27510. textureFloatRender: boolean;
  27511. /** Defines if half float textures are supported*/
  27512. textureHalfFloat: boolean;
  27513. /** Defines if half float texture linear filtering is supported*/
  27514. textureHalfFloatLinearFiltering: boolean;
  27515. /** Defines if rendering to half float textures is supported */
  27516. textureHalfFloatRender: boolean;
  27517. /** Defines if textureLOD shader command is supported */
  27518. textureLOD: boolean;
  27519. /** Defines if draw buffers extension is supported */
  27520. drawBuffersExtension: boolean;
  27521. /** Defines if depth textures are supported */
  27522. depthTextureExtension: boolean;
  27523. /** Defines if float color buffer are supported */
  27524. colorBufferFloat: boolean;
  27525. /** Gets disjoint timer query extension (null if not supported) */
  27526. timerQuery: EXT_disjoint_timer_query;
  27527. /** Defines if timestamp can be used with timer query */
  27528. canUseTimestampForTimerQuery: boolean;
  27529. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27530. multiview: any;
  27531. /** Function used to let the system compiles shaders in background */
  27532. parallelShaderCompile: {
  27533. COMPLETION_STATUS_KHR: number;
  27534. };
  27535. }
  27536. /** Interface defining initialization parameters for Engine class */
  27537. export interface EngineOptions extends WebGLContextAttributes {
  27538. /**
  27539. * Defines if the engine should no exceed a specified device ratio
  27540. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27541. */
  27542. limitDeviceRatio?: number;
  27543. /**
  27544. * Defines if webvr should be enabled automatically
  27545. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27546. */
  27547. autoEnableWebVR?: boolean;
  27548. /**
  27549. * Defines if webgl2 should be turned off even if supported
  27550. * @see http://doc.babylonjs.com/features/webgl2
  27551. */
  27552. disableWebGL2Support?: boolean;
  27553. /**
  27554. * Defines if webaudio should be initialized as well
  27555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27556. */
  27557. audioEngine?: boolean;
  27558. /**
  27559. * Defines if animations should run using a deterministic lock step
  27560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27561. */
  27562. deterministicLockstep?: boolean;
  27563. /** Defines the maximum steps to use with deterministic lock step mode */
  27564. lockstepMaxSteps?: number;
  27565. /**
  27566. * Defines that engine should ignore context lost events
  27567. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27568. */
  27569. doNotHandleContextLost?: boolean;
  27570. /**
  27571. * Defines that engine should ignore modifying touch action attribute and style
  27572. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27573. */
  27574. doNotHandleTouchAction?: boolean;
  27575. /**
  27576. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27577. */
  27578. useHighPrecisionFloats?: boolean;
  27579. }
  27580. /**
  27581. * Defines the interface used by display changed events
  27582. */
  27583. export interface IDisplayChangedEventArgs {
  27584. /** Gets the vrDisplay object (if any) */
  27585. vrDisplay: Nullable<any>;
  27586. /** Gets a boolean indicating if webVR is supported */
  27587. vrSupported: boolean;
  27588. }
  27589. /**
  27590. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27591. */
  27592. export class Engine {
  27593. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27594. static ExceptionList: ({
  27595. key: string;
  27596. capture: string;
  27597. captureConstraint: number;
  27598. targets: string[];
  27599. } | {
  27600. key: string;
  27601. capture: null;
  27602. captureConstraint: null;
  27603. targets: string[];
  27604. })[];
  27605. /** Gets the list of created engines */
  27606. static readonly Instances: Engine[];
  27607. /**
  27608. * Gets the latest created engine
  27609. */
  27610. static readonly LastCreatedEngine: Nullable<Engine>;
  27611. /**
  27612. * Gets the latest created scene
  27613. */
  27614. static readonly LastCreatedScene: Nullable<Scene>;
  27615. /**
  27616. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27617. * @param flag defines which part of the materials must be marked as dirty
  27618. * @param predicate defines a predicate used to filter which materials should be affected
  27619. */
  27620. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27621. /**
  27622. * Hidden
  27623. */
  27624. static _TextureLoaders: IInternalTextureLoader[];
  27625. /** Defines that alpha blending is disabled */
  27626. static readonly ALPHA_DISABLE: number;
  27627. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27628. static readonly ALPHA_ADD: number;
  27629. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27630. static readonly ALPHA_COMBINE: number;
  27631. /** Defines that alpha blending to DEST - SRC * DEST */
  27632. static readonly ALPHA_SUBTRACT: number;
  27633. /** Defines that alpha blending to SRC * DEST */
  27634. static readonly ALPHA_MULTIPLY: number;
  27635. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27636. static readonly ALPHA_MAXIMIZED: number;
  27637. /** Defines that alpha blending to SRC + DEST */
  27638. static readonly ALPHA_ONEONE: number;
  27639. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27640. static readonly ALPHA_PREMULTIPLIED: number;
  27641. /**
  27642. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27643. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27644. */
  27645. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27646. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27647. static readonly ALPHA_INTERPOLATE: number;
  27648. /**
  27649. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27650. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27651. */
  27652. static readonly ALPHA_SCREENMODE: number;
  27653. /** Defines that the ressource is not delayed*/
  27654. static readonly DELAYLOADSTATE_NONE: number;
  27655. /** Defines that the ressource was successfully delay loaded */
  27656. static readonly DELAYLOADSTATE_LOADED: number;
  27657. /** Defines that the ressource is currently delay loading */
  27658. static readonly DELAYLOADSTATE_LOADING: number;
  27659. /** Defines that the ressource is delayed and has not started loading */
  27660. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27661. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27662. static readonly NEVER: number;
  27663. /** 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 */
  27664. static readonly ALWAYS: number;
  27665. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27666. static readonly LESS: number;
  27667. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27668. static readonly EQUAL: number;
  27669. /** 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 */
  27670. static readonly LEQUAL: number;
  27671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27672. static readonly GREATER: number;
  27673. /** 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 */
  27674. static readonly GEQUAL: number;
  27675. /** 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 */
  27676. static readonly NOTEQUAL: number;
  27677. /** Passed to stencilOperation to specify that stencil value must be kept */
  27678. static readonly KEEP: number;
  27679. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27680. static readonly REPLACE: number;
  27681. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27682. static readonly INCR: number;
  27683. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27684. static readonly DECR: number;
  27685. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27686. static readonly INVERT: number;
  27687. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27688. static readonly INCR_WRAP: number;
  27689. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27690. static readonly DECR_WRAP: number;
  27691. /** Texture is not repeating outside of 0..1 UVs */
  27692. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27693. /** Texture is repeating outside of 0..1 UVs */
  27694. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27695. /** Texture is repeating and mirrored */
  27696. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27697. /** ALPHA */
  27698. static readonly TEXTUREFORMAT_ALPHA: number;
  27699. /** LUMINANCE */
  27700. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27701. /** LUMINANCE_ALPHA */
  27702. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27703. /** RGB */
  27704. static readonly TEXTUREFORMAT_RGB: number;
  27705. /** RGBA */
  27706. static readonly TEXTUREFORMAT_RGBA: number;
  27707. /** RED */
  27708. static readonly TEXTUREFORMAT_RED: number;
  27709. /** RED (2nd reference) */
  27710. static readonly TEXTUREFORMAT_R: number;
  27711. /** RG */
  27712. static readonly TEXTUREFORMAT_RG: number;
  27713. /** RED_INTEGER */
  27714. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27715. /** RED_INTEGER (2nd reference) */
  27716. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27717. /** RG_INTEGER */
  27718. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27719. /** RGB_INTEGER */
  27720. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27721. /** RGBA_INTEGER */
  27722. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27723. /** UNSIGNED_BYTE */
  27724. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27725. /** UNSIGNED_BYTE (2nd reference) */
  27726. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27727. /** FLOAT */
  27728. static readonly TEXTURETYPE_FLOAT: number;
  27729. /** HALF_FLOAT */
  27730. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27731. /** BYTE */
  27732. static readonly TEXTURETYPE_BYTE: number;
  27733. /** SHORT */
  27734. static readonly TEXTURETYPE_SHORT: number;
  27735. /** UNSIGNED_SHORT */
  27736. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27737. /** INT */
  27738. static readonly TEXTURETYPE_INT: number;
  27739. /** UNSIGNED_INT */
  27740. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27741. /** UNSIGNED_SHORT_4_4_4_4 */
  27742. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27743. /** UNSIGNED_SHORT_5_5_5_1 */
  27744. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27745. /** UNSIGNED_SHORT_5_6_5 */
  27746. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27747. /** UNSIGNED_INT_2_10_10_10_REV */
  27748. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27749. /** UNSIGNED_INT_24_8 */
  27750. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27751. /** UNSIGNED_INT_10F_11F_11F_REV */
  27752. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27753. /** UNSIGNED_INT_5_9_9_9_REV */
  27754. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27755. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27756. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27757. /** nearest is mag = nearest and min = nearest and mip = linear */
  27758. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27759. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27760. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27761. /** Trilinear is mag = linear and min = linear and mip = linear */
  27762. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27763. /** nearest is mag = nearest and min = nearest and mip = linear */
  27764. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27765. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27766. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27767. /** Trilinear is mag = linear and min = linear and mip = linear */
  27768. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27769. /** mag = nearest and min = nearest and mip = nearest */
  27770. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27771. /** mag = nearest and min = linear and mip = nearest */
  27772. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27773. /** mag = nearest and min = linear and mip = linear */
  27774. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27775. /** mag = nearest and min = linear and mip = none */
  27776. static readonly TEXTURE_NEAREST_LINEAR: number;
  27777. /** mag = nearest and min = nearest and mip = none */
  27778. static readonly TEXTURE_NEAREST_NEAREST: number;
  27779. /** mag = linear and min = nearest and mip = nearest */
  27780. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27781. /** mag = linear and min = nearest and mip = linear */
  27782. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27783. /** mag = linear and min = linear and mip = none */
  27784. static readonly TEXTURE_LINEAR_LINEAR: number;
  27785. /** mag = linear and min = nearest and mip = none */
  27786. static readonly TEXTURE_LINEAR_NEAREST: number;
  27787. /** Explicit coordinates mode */
  27788. static readonly TEXTURE_EXPLICIT_MODE: number;
  27789. /** Spherical coordinates mode */
  27790. static readonly TEXTURE_SPHERICAL_MODE: number;
  27791. /** Planar coordinates mode */
  27792. static readonly TEXTURE_PLANAR_MODE: number;
  27793. /** Cubic coordinates mode */
  27794. static readonly TEXTURE_CUBIC_MODE: number;
  27795. /** Projection coordinates mode */
  27796. static readonly TEXTURE_PROJECTION_MODE: number;
  27797. /** Skybox coordinates mode */
  27798. static readonly TEXTURE_SKYBOX_MODE: number;
  27799. /** Inverse Cubic coordinates mode */
  27800. static readonly TEXTURE_INVCUBIC_MODE: number;
  27801. /** Equirectangular coordinates mode */
  27802. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27803. /** Equirectangular Fixed coordinates mode */
  27804. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27805. /** Equirectangular Fixed Mirrored coordinates mode */
  27806. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27807. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27808. static readonly SCALEMODE_FLOOR: number;
  27809. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27810. static readonly SCALEMODE_NEAREST: number;
  27811. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27812. static readonly SCALEMODE_CEILING: number;
  27813. /**
  27814. * Returns the current npm package of the sdk
  27815. */
  27816. static readonly NpmPackage: string;
  27817. /**
  27818. * Returns the current version of the framework
  27819. */
  27820. static readonly Version: string;
  27821. /**
  27822. * Returns a string describing the current engine
  27823. */
  27824. readonly description: string;
  27825. /**
  27826. * Gets or sets the epsilon value used by collision engine
  27827. */
  27828. static CollisionsEpsilon: number;
  27829. /**
  27830. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27831. */
  27832. static ShadersRepository: string;
  27833. /**
  27834. * Method called to create the default loading screen.
  27835. * This can be overriden in your own app.
  27836. * @param canvas The rendering canvas element
  27837. * @returns The loading screen
  27838. */
  27839. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27840. /**
  27841. * Method called to create the default rescale post process on each engine.
  27842. */
  27843. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27844. /**
  27845. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27846. */
  27847. forcePOTTextures: boolean;
  27848. /**
  27849. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27850. */
  27851. isFullscreen: boolean;
  27852. /**
  27853. * Gets a boolean indicating if the pointer is currently locked
  27854. */
  27855. isPointerLock: boolean;
  27856. /**
  27857. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27858. */
  27859. cullBackFaces: boolean;
  27860. /**
  27861. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27862. */
  27863. renderEvenInBackground: boolean;
  27864. /**
  27865. * Gets or sets a boolean indicating that cache can be kept between frames
  27866. */
  27867. preventCacheWipeBetweenFrames: boolean;
  27868. /**
  27869. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27870. **/
  27871. enableOfflineSupport: boolean;
  27872. /**
  27873. * 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)
  27874. **/
  27875. disableManifestCheck: boolean;
  27876. /**
  27877. * Gets the list of created scenes
  27878. */
  27879. scenes: Scene[];
  27880. /**
  27881. * Event raised when a new scene is created
  27882. */
  27883. onNewSceneAddedObservable: Observable<Scene>;
  27884. /**
  27885. * Gets the list of created postprocesses
  27886. */
  27887. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27888. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27889. validateShaderPrograms: boolean;
  27890. /**
  27891. * Observable event triggered each time the rendering canvas is resized
  27892. */
  27893. onResizeObservable: Observable<Engine>;
  27894. /**
  27895. * Observable event triggered each time the canvas loses focus
  27896. */
  27897. onCanvasBlurObservable: Observable<Engine>;
  27898. /**
  27899. * Observable event triggered each time the canvas gains focus
  27900. */
  27901. onCanvasFocusObservable: Observable<Engine>;
  27902. /**
  27903. * Observable event triggered each time the canvas receives pointerout event
  27904. */
  27905. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27906. /**
  27907. * Observable event triggered before each texture is initialized
  27908. */
  27909. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27910. private _vrDisplay;
  27911. private _vrSupported;
  27912. private _oldSize;
  27913. private _oldHardwareScaleFactor;
  27914. private _vrExclusivePointerMode;
  27915. private _webVRInitPromise;
  27916. /**
  27917. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27918. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27919. */
  27920. readonly isInVRExclusivePointerMode: boolean;
  27921. /**
  27922. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27923. */
  27924. disableUniformBuffers: boolean;
  27925. /** @hidden */
  27926. _uniformBuffers: UniformBuffer[];
  27927. /**
  27928. * Gets a boolean indicating that the engine supports uniform buffers
  27929. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27930. */
  27931. readonly supportsUniformBuffers: boolean;
  27932. /**
  27933. * Observable raised when the engine begins a new frame
  27934. */
  27935. onBeginFrameObservable: Observable<Engine>;
  27936. /**
  27937. * If set, will be used to request the next animation frame for the render loop
  27938. */
  27939. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27940. /**
  27941. * Observable raised when the engine ends the current frame
  27942. */
  27943. onEndFrameObservable: Observable<Engine>;
  27944. /**
  27945. * Observable raised when the engine is about to compile a shader
  27946. */
  27947. onBeforeShaderCompilationObservable: Observable<Engine>;
  27948. /**
  27949. * Observable raised when the engine has jsut compiled a shader
  27950. */
  27951. onAfterShaderCompilationObservable: Observable<Engine>;
  27952. /** @hidden */
  27953. _gl: WebGLRenderingContext;
  27954. private _renderingCanvas;
  27955. private _windowIsBackground;
  27956. private _webGLVersion;
  27957. protected _highPrecisionShadersAllowed: boolean;
  27958. /** @hidden */
  27959. readonly _shouldUseHighPrecisionShader: boolean;
  27960. /**
  27961. * Gets a boolean indicating that only power of 2 textures are supported
  27962. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27963. */
  27964. readonly needPOTTextures: boolean;
  27965. /** @hidden */
  27966. _badOS: boolean;
  27967. /** @hidden */
  27968. _badDesktopOS: boolean;
  27969. /**
  27970. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27971. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27972. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27973. */
  27974. disableTextureBindingOptimization: boolean;
  27975. /**
  27976. * Gets the audio engine
  27977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27978. * @ignorenaming
  27979. */
  27980. static audioEngine: IAudioEngine;
  27981. /**
  27982. * Default AudioEngine factory responsible of creating the Audio Engine.
  27983. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27984. */
  27985. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27986. /**
  27987. * Default offline support factory responsible of creating a tool used to store data locally.
  27988. * By default, this will create a Database object if the workload has been embedded.
  27989. */
  27990. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27991. private _onFocus;
  27992. private _onBlur;
  27993. private _onCanvasPointerOut;
  27994. private _onCanvasBlur;
  27995. private _onCanvasFocus;
  27996. private _onFullscreenChange;
  27997. private _onPointerLockChange;
  27998. private _onVRDisplayPointerRestricted;
  27999. private _onVRDisplayPointerUnrestricted;
  28000. private _onVrDisplayConnect;
  28001. private _onVrDisplayDisconnect;
  28002. private _onVrDisplayPresentChange;
  28003. /**
  28004. * Observable signaled when VR display mode changes
  28005. */
  28006. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28007. /**
  28008. * Observable signaled when VR request present is complete
  28009. */
  28010. onVRRequestPresentComplete: Observable<boolean>;
  28011. /**
  28012. * Observable signaled when VR request present starts
  28013. */
  28014. onVRRequestPresentStart: Observable<Engine>;
  28015. private _hardwareScalingLevel;
  28016. /** @hidden */
  28017. protected _caps: EngineCapabilities;
  28018. private _pointerLockRequested;
  28019. private _isStencilEnable;
  28020. private _colorWrite;
  28021. private _loadingScreen;
  28022. /** @hidden */
  28023. _drawCalls: PerfCounter;
  28024. /** @hidden */
  28025. _textureCollisions: PerfCounter;
  28026. private _glVersion;
  28027. private _glRenderer;
  28028. private _glVendor;
  28029. private _videoTextureSupported;
  28030. private _renderingQueueLaunched;
  28031. private _activeRenderLoops;
  28032. private _deterministicLockstep;
  28033. private _lockstepMaxSteps;
  28034. /**
  28035. * Observable signaled when a context lost event is raised
  28036. */
  28037. onContextLostObservable: Observable<Engine>;
  28038. /**
  28039. * Observable signaled when a context restored event is raised
  28040. */
  28041. onContextRestoredObservable: Observable<Engine>;
  28042. private _onContextLost;
  28043. private _onContextRestored;
  28044. private _contextWasLost;
  28045. private _doNotHandleContextLost;
  28046. /**
  28047. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28049. */
  28050. doNotHandleContextLost: boolean;
  28051. private _performanceMonitor;
  28052. private _fps;
  28053. private _deltaTime;
  28054. /**
  28055. * Turn this value on if you want to pause FPS computation when in background
  28056. */
  28057. disablePerformanceMonitorInBackground: boolean;
  28058. /**
  28059. * Gets the performance monitor attached to this engine
  28060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28061. */
  28062. readonly performanceMonitor: PerformanceMonitor;
  28063. /** @hidden */
  28064. protected _depthCullingState: _DepthCullingState;
  28065. /** @hidden */
  28066. protected _stencilState: _StencilState;
  28067. /** @hidden */
  28068. protected _alphaState: _AlphaState;
  28069. /** @hidden */
  28070. protected _alphaMode: number;
  28071. protected _internalTexturesCache: InternalTexture[];
  28072. /** @hidden */
  28073. protected _activeChannel: number;
  28074. private _currentTextureChannel;
  28075. /** @hidden */
  28076. protected _boundTexturesCache: {
  28077. [key: string]: Nullable<InternalTexture>;
  28078. };
  28079. /** @hidden */
  28080. protected _currentEffect: Nullable<Effect>;
  28081. /** @hidden */
  28082. protected _currentProgram: Nullable<WebGLProgram>;
  28083. private _compiledEffects;
  28084. private _vertexAttribArraysEnabled;
  28085. /** @hidden */
  28086. protected _cachedViewport: Nullable<Viewport>;
  28087. private _cachedVertexArrayObject;
  28088. /** @hidden */
  28089. protected _cachedVertexBuffers: any;
  28090. /** @hidden */
  28091. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28092. /** @hidden */
  28093. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28094. /** @hidden */
  28095. protected _currentRenderTarget: Nullable<InternalTexture>;
  28096. private _uintIndicesCurrentlySet;
  28097. private _currentBoundBuffer;
  28098. /** @hidden */
  28099. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28100. private _currentBufferPointers;
  28101. private _currentInstanceLocations;
  28102. private _currentInstanceBuffers;
  28103. private _textureUnits;
  28104. private _firstBoundInternalTextureTracker;
  28105. private _lastBoundInternalTextureTracker;
  28106. private _workingCanvas;
  28107. private _workingContext;
  28108. private _rescalePostProcess;
  28109. private _dummyFramebuffer;
  28110. private _externalData;
  28111. private _bindedRenderFunction;
  28112. private _vaoRecordInProgress;
  28113. private _mustWipeVertexAttributes;
  28114. private _emptyTexture;
  28115. private _emptyCubeTexture;
  28116. private _emptyTexture3D;
  28117. /** @hidden */
  28118. _frameHandler: number;
  28119. private _nextFreeTextureSlots;
  28120. private _maxSimultaneousTextures;
  28121. private _activeRequests;
  28122. private _texturesSupported;
  28123. private _textureFormatInUse;
  28124. /**
  28125. * Gets the list of texture formats supported
  28126. */
  28127. readonly texturesSupported: Array<string>;
  28128. /**
  28129. * Gets the list of texture formats in use
  28130. */
  28131. readonly textureFormatInUse: Nullable<string>;
  28132. /**
  28133. * Gets the current viewport
  28134. */
  28135. readonly currentViewport: Nullable<Viewport>;
  28136. /**
  28137. * Gets the default empty texture
  28138. */
  28139. readonly emptyTexture: InternalTexture;
  28140. /**
  28141. * Gets the default empty 3D texture
  28142. */
  28143. readonly emptyTexture3D: InternalTexture;
  28144. /**
  28145. * Gets the default empty cube texture
  28146. */
  28147. readonly emptyCubeTexture: InternalTexture;
  28148. /**
  28149. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28150. */
  28151. readonly premultipliedAlpha: boolean;
  28152. /**
  28153. * Creates a new engine
  28154. * @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
  28155. * @param antialias defines enable antialiasing (default: false)
  28156. * @param options defines further options to be sent to the getContext() function
  28157. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28158. */
  28159. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28160. private _disableTouchAction;
  28161. private _rebuildInternalTextures;
  28162. private _rebuildEffects;
  28163. /**
  28164. * Gets a boolean indicating if all created effects are ready
  28165. * @returns true if all effects are ready
  28166. */
  28167. areAllEffectsReady(): boolean;
  28168. private _rebuildBuffers;
  28169. private _initGLContext;
  28170. /**
  28171. * Gets version of the current webGL context
  28172. */
  28173. readonly webGLVersion: number;
  28174. /**
  28175. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28176. */
  28177. readonly isStencilEnable: boolean;
  28178. private _prepareWorkingCanvas;
  28179. /**
  28180. * Reset the texture cache to empty state
  28181. */
  28182. resetTextureCache(): void;
  28183. /**
  28184. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28186. * @returns true if engine is in deterministic lock step mode
  28187. */
  28188. isDeterministicLockStep(): boolean;
  28189. /**
  28190. * Gets the max steps when engine is running in deterministic lock step
  28191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28192. * @returns the max steps
  28193. */
  28194. getLockstepMaxSteps(): number;
  28195. /**
  28196. * Gets an object containing information about the current webGL context
  28197. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28198. */
  28199. getGlInfo(): {
  28200. vendor: string;
  28201. renderer: string;
  28202. version: string;
  28203. };
  28204. /**
  28205. * Gets current aspect ratio
  28206. * @param camera defines the camera to use to get the aspect ratio
  28207. * @param useScreen defines if screen size must be used (or the current render target if any)
  28208. * @returns a number defining the aspect ratio
  28209. */
  28210. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28211. /**
  28212. * Gets current screen aspect ratio
  28213. * @returns a number defining the aspect ratio
  28214. */
  28215. getScreenAspectRatio(): number;
  28216. /**
  28217. * Gets the current render width
  28218. * @param useScreen defines if screen size must be used (or the current render target if any)
  28219. * @returns a number defining the current render width
  28220. */
  28221. getRenderWidth(useScreen?: boolean): number;
  28222. /**
  28223. * Gets the current render height
  28224. * @param useScreen defines if screen size must be used (or the current render target if any)
  28225. * @returns a number defining the current render height
  28226. */
  28227. getRenderHeight(useScreen?: boolean): number;
  28228. /**
  28229. * Gets the HTML canvas attached with the current webGL context
  28230. * @returns a HTML canvas
  28231. */
  28232. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28233. /**
  28234. * Gets the client rect of the HTML canvas attached with the current webGL context
  28235. * @returns a client rectanglee
  28236. */
  28237. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28238. /**
  28239. * Defines the hardware scaling level.
  28240. * By default the hardware scaling level is computed from the window device ratio.
  28241. * 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.
  28242. * @param level defines the level to use
  28243. */
  28244. setHardwareScalingLevel(level: number): void;
  28245. /**
  28246. * Gets the current hardware scaling level.
  28247. * By default the hardware scaling level is computed from the window device ratio.
  28248. * 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.
  28249. * @returns a number indicating the current hardware scaling level
  28250. */
  28251. getHardwareScalingLevel(): number;
  28252. /**
  28253. * Gets the list of loaded textures
  28254. * @returns an array containing all loaded textures
  28255. */
  28256. getLoadedTexturesCache(): InternalTexture[];
  28257. /**
  28258. * Gets the object containing all engine capabilities
  28259. * @returns the EngineCapabilities object
  28260. */
  28261. getCaps(): EngineCapabilities;
  28262. /**
  28263. * Gets the current depth function
  28264. * @returns a number defining the depth function
  28265. */
  28266. getDepthFunction(): Nullable<number>;
  28267. /**
  28268. * Sets the current depth function
  28269. * @param depthFunc defines the function to use
  28270. */
  28271. setDepthFunction(depthFunc: number): void;
  28272. /**
  28273. * Sets the current depth function to GREATER
  28274. */
  28275. setDepthFunctionToGreater(): void;
  28276. /**
  28277. * Sets the current depth function to GEQUAL
  28278. */
  28279. setDepthFunctionToGreaterOrEqual(): void;
  28280. /**
  28281. * Sets the current depth function to LESS
  28282. */
  28283. setDepthFunctionToLess(): void;
  28284. private _cachedStencilBuffer;
  28285. private _cachedStencilFunction;
  28286. private _cachedStencilMask;
  28287. private _cachedStencilOperationPass;
  28288. private _cachedStencilOperationFail;
  28289. private _cachedStencilOperationDepthFail;
  28290. private _cachedStencilReference;
  28291. /**
  28292. * Caches the the state of the stencil buffer
  28293. */
  28294. cacheStencilState(): void;
  28295. /**
  28296. * Restores the state of the stencil buffer
  28297. */
  28298. restoreStencilState(): void;
  28299. /**
  28300. * Sets the current depth function to LEQUAL
  28301. */
  28302. setDepthFunctionToLessOrEqual(): void;
  28303. /**
  28304. * Gets a boolean indicating if stencil buffer is enabled
  28305. * @returns the current stencil buffer state
  28306. */
  28307. getStencilBuffer(): boolean;
  28308. /**
  28309. * Enable or disable the stencil buffer
  28310. * @param enable defines if the stencil buffer must be enabled or disabled
  28311. */
  28312. setStencilBuffer(enable: boolean): void;
  28313. /**
  28314. * Gets the current stencil mask
  28315. * @returns a number defining the new stencil mask to use
  28316. */
  28317. getStencilMask(): number;
  28318. /**
  28319. * Sets the current stencil mask
  28320. * @param mask defines the new stencil mask to use
  28321. */
  28322. setStencilMask(mask: number): void;
  28323. /**
  28324. * Gets the current stencil function
  28325. * @returns a number defining the stencil function to use
  28326. */
  28327. getStencilFunction(): number;
  28328. /**
  28329. * Gets the current stencil reference value
  28330. * @returns a number defining the stencil reference value to use
  28331. */
  28332. getStencilFunctionReference(): number;
  28333. /**
  28334. * Gets the current stencil mask
  28335. * @returns a number defining the stencil mask to use
  28336. */
  28337. getStencilFunctionMask(): number;
  28338. /**
  28339. * Sets the current stencil function
  28340. * @param stencilFunc defines the new stencil function to use
  28341. */
  28342. setStencilFunction(stencilFunc: number): void;
  28343. /**
  28344. * Sets the current stencil reference
  28345. * @param reference defines the new stencil reference to use
  28346. */
  28347. setStencilFunctionReference(reference: number): void;
  28348. /**
  28349. * Sets the current stencil mask
  28350. * @param mask defines the new stencil mask to use
  28351. */
  28352. setStencilFunctionMask(mask: number): void;
  28353. /**
  28354. * Gets the current stencil operation when stencil fails
  28355. * @returns a number defining stencil operation to use when stencil fails
  28356. */
  28357. getStencilOperationFail(): number;
  28358. /**
  28359. * Gets the current stencil operation when depth fails
  28360. * @returns a number defining stencil operation to use when depth fails
  28361. */
  28362. getStencilOperationDepthFail(): number;
  28363. /**
  28364. * Gets the current stencil operation when stencil passes
  28365. * @returns a number defining stencil operation to use when stencil passes
  28366. */
  28367. getStencilOperationPass(): number;
  28368. /**
  28369. * Sets the stencil operation to use when stencil fails
  28370. * @param operation defines the stencil operation to use when stencil fails
  28371. */
  28372. setStencilOperationFail(operation: number): void;
  28373. /**
  28374. * Sets the stencil operation to use when depth fails
  28375. * @param operation defines the stencil operation to use when depth fails
  28376. */
  28377. setStencilOperationDepthFail(operation: number): void;
  28378. /**
  28379. * Sets the stencil operation to use when stencil passes
  28380. * @param operation defines the stencil operation to use when stencil passes
  28381. */
  28382. setStencilOperationPass(operation: number): void;
  28383. /**
  28384. * Sets a boolean indicating if the dithering state is enabled or disabled
  28385. * @param value defines the dithering state
  28386. */
  28387. setDitheringState(value: boolean): void;
  28388. /**
  28389. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28390. * @param value defines the rasterizer state
  28391. */
  28392. setRasterizerState(value: boolean): void;
  28393. /**
  28394. * stop executing a render loop function and remove it from the execution array
  28395. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28396. */
  28397. stopRenderLoop(renderFunction?: () => void): void;
  28398. /** @hidden */
  28399. _renderLoop(): void;
  28400. /**
  28401. * Register and execute a render loop. The engine can have more than one render function
  28402. * @param renderFunction defines the function to continuously execute
  28403. */
  28404. runRenderLoop(renderFunction: () => void): void;
  28405. /**
  28406. * Toggle full screen mode
  28407. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28408. */
  28409. switchFullscreen(requestPointerLock: boolean): void;
  28410. /**
  28411. * Enters full screen mode
  28412. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28413. */
  28414. enterFullscreen(requestPointerLock: boolean): void;
  28415. /**
  28416. * Exits full screen mode
  28417. */
  28418. exitFullscreen(): void;
  28419. /**
  28420. * Clear the current render buffer or the current render target (if any is set up)
  28421. * @param color defines the color to use
  28422. * @param backBuffer defines if the back buffer must be cleared
  28423. * @param depth defines if the depth buffer must be cleared
  28424. * @param stencil defines if the stencil buffer must be cleared
  28425. */
  28426. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28427. /**
  28428. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28429. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28430. * @param y defines the y-coordinate of the corner of the clear rectangle
  28431. * @param width defines the width of the clear rectangle
  28432. * @param height defines the height of the clear rectangle
  28433. * @param clearColor defines the clear color
  28434. */
  28435. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28436. /**
  28437. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28438. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28439. * @param y defines the y-coordinate of the corner of the clear rectangle
  28440. * @param width defines the width of the clear rectangle
  28441. * @param height defines the height of the clear rectangle
  28442. */
  28443. enableScissor(x: number, y: number, width: number, height: number): void;
  28444. /**
  28445. * Disable previously set scissor test rectangle
  28446. */
  28447. disableScissor(): void;
  28448. private _viewportCached;
  28449. /** @hidden */
  28450. _viewport(x: number, y: number, width: number, height: number): void;
  28451. /**
  28452. * Set the WebGL's viewport
  28453. * @param viewport defines the viewport element to be used
  28454. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28455. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28456. */
  28457. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28458. /**
  28459. * Directly set the WebGL Viewport
  28460. * @param x defines the x coordinate of the viewport (in screen space)
  28461. * @param y defines the y coordinate of the viewport (in screen space)
  28462. * @param width defines the width of the viewport (in screen space)
  28463. * @param height defines the height of the viewport (in screen space)
  28464. * @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
  28465. */
  28466. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28467. /**
  28468. * Begin a new frame
  28469. */
  28470. beginFrame(): void;
  28471. /**
  28472. * Enf the current frame
  28473. */
  28474. endFrame(): void;
  28475. /**
  28476. * Resize the view according to the canvas' size
  28477. */
  28478. resize(): void;
  28479. /**
  28480. * Force a specific size of the canvas
  28481. * @param width defines the new canvas' width
  28482. * @param height defines the new canvas' height
  28483. */
  28484. setSize(width: number, height: number): void;
  28485. /**
  28486. * Gets a boolean indicating if a webVR device was detected
  28487. * @returns true if a webVR device was detected
  28488. */
  28489. isVRDevicePresent(): boolean;
  28490. /**
  28491. * Gets the current webVR device
  28492. * @returns the current webVR device (or null)
  28493. */
  28494. getVRDevice(): any;
  28495. /**
  28496. * Initializes a webVR display and starts listening to display change events
  28497. * The onVRDisplayChangedObservable will be notified upon these changes
  28498. * @returns The onVRDisplayChangedObservable
  28499. */
  28500. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28501. /**
  28502. * Initializes a webVR display and starts listening to display change events
  28503. * The onVRDisplayChangedObservable will be notified upon these changes
  28504. * @returns A promise containing a VRDisplay and if vr is supported
  28505. */
  28506. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28507. /**
  28508. * Call this function to switch to webVR mode
  28509. * Will do nothing if webVR is not supported or if there is no webVR device
  28510. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28511. */
  28512. enableVR(): void;
  28513. /**
  28514. * Call this function to leave webVR mode
  28515. * Will do nothing if webVR is not supported or if there is no webVR device
  28516. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28517. */
  28518. disableVR(): void;
  28519. private _onVRFullScreenTriggered;
  28520. private _getVRDisplaysAsync;
  28521. /**
  28522. * Binds the frame buffer to the specified texture.
  28523. * @param texture The texture to render to or null for the default canvas
  28524. * @param faceIndex The face of the texture to render to in case of cube texture
  28525. * @param requiredWidth The width of the target to render to
  28526. * @param requiredHeight The height of the target to render to
  28527. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28528. * @param depthStencilTexture The depth stencil texture to use to render
  28529. * @param lodLevel defines le lod level to bind to the frame buffer
  28530. */
  28531. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28532. private bindUnboundFramebuffer;
  28533. /**
  28534. * Unbind the current render target texture from the webGL context
  28535. * @param texture defines the render target texture to unbind
  28536. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28537. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28538. */
  28539. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28540. /**
  28541. * Unbind a list of render target textures from the webGL context
  28542. * This is used only when drawBuffer extension or webGL2 are active
  28543. * @param textures defines the render target textures to unbind
  28544. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28545. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28546. */
  28547. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28548. /**
  28549. * Force the mipmap generation for the given render target texture
  28550. * @param texture defines the render target texture to use
  28551. */
  28552. generateMipMapsForCubemap(texture: InternalTexture): void;
  28553. /**
  28554. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28555. */
  28556. flushFramebuffer(): void;
  28557. /**
  28558. * Unbind the current render target and bind the default framebuffer
  28559. */
  28560. restoreDefaultFramebuffer(): void;
  28561. /**
  28562. * Create an uniform buffer
  28563. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28564. * @param elements defines the content of the uniform buffer
  28565. * @returns the webGL uniform buffer
  28566. */
  28567. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28568. /**
  28569. * Create a dynamic uniform buffer
  28570. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28571. * @param elements defines the content of the uniform buffer
  28572. * @returns the webGL uniform buffer
  28573. */
  28574. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28575. /**
  28576. * Update an existing uniform buffer
  28577. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28578. * @param uniformBuffer defines the target uniform buffer
  28579. * @param elements defines the content to update
  28580. * @param offset defines the offset in the uniform buffer where update should start
  28581. * @param count defines the size of the data to update
  28582. */
  28583. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28584. private _resetVertexBufferBinding;
  28585. /**
  28586. * Creates a vertex buffer
  28587. * @param data the data for the vertex buffer
  28588. * @returns the new WebGL static buffer
  28589. */
  28590. createVertexBuffer(data: DataArray): WebGLBuffer;
  28591. /**
  28592. * Creates a dynamic vertex buffer
  28593. * @param data the data for the dynamic vertex buffer
  28594. * @returns the new WebGL dynamic buffer
  28595. */
  28596. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28597. /**
  28598. * Update a dynamic index buffer
  28599. * @param indexBuffer defines the target index buffer
  28600. * @param indices defines the data to update
  28601. * @param offset defines the offset in the target index buffer where update should start
  28602. */
  28603. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28604. /**
  28605. * Updates a dynamic vertex buffer.
  28606. * @param vertexBuffer the vertex buffer to update
  28607. * @param data the data used to update the vertex buffer
  28608. * @param byteOffset the byte offset of the data
  28609. * @param byteLength the byte length of the data
  28610. */
  28611. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28612. private _resetIndexBufferBinding;
  28613. /**
  28614. * Creates a new index buffer
  28615. * @param indices defines the content of the index buffer
  28616. * @param updatable defines if the index buffer must be updatable
  28617. * @returns a new webGL buffer
  28618. */
  28619. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28620. /**
  28621. * Bind a webGL buffer to the webGL context
  28622. * @param buffer defines the buffer to bind
  28623. */
  28624. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28625. /**
  28626. * Bind an uniform buffer to the current webGL context
  28627. * @param buffer defines the buffer to bind
  28628. */
  28629. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28630. /**
  28631. * Bind a buffer to the current webGL context at a given location
  28632. * @param buffer defines the buffer to bind
  28633. * @param location defines the index where to bind the buffer
  28634. */
  28635. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28636. /**
  28637. * Bind a specific block at a given index in a specific shader program
  28638. * @param shaderProgram defines the shader program
  28639. * @param blockName defines the block name
  28640. * @param index defines the index where to bind the block
  28641. */
  28642. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28643. private bindIndexBuffer;
  28644. private bindBuffer;
  28645. /**
  28646. * update the bound buffer with the given data
  28647. * @param data defines the data to update
  28648. */
  28649. updateArrayBuffer(data: Float32Array): void;
  28650. private _vertexAttribPointer;
  28651. private _bindIndexBufferWithCache;
  28652. private _bindVertexBuffersAttributes;
  28653. /**
  28654. * Records a vertex array object
  28655. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28656. * @param vertexBuffers defines the list of vertex buffers to store
  28657. * @param indexBuffer defines the index buffer to store
  28658. * @param effect defines the effect to store
  28659. * @returns the new vertex array object
  28660. */
  28661. recordVertexArrayObject(vertexBuffers: {
  28662. [key: string]: VertexBuffer;
  28663. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28664. /**
  28665. * Bind a specific vertex array object
  28666. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28667. * @param vertexArrayObject defines the vertex array object to bind
  28668. * @param indexBuffer defines the index buffer to bind
  28669. */
  28670. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28671. /**
  28672. * Bind webGl buffers directly to the webGL context
  28673. * @param vertexBuffer defines the vertex buffer to bind
  28674. * @param indexBuffer defines the index buffer to bind
  28675. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28676. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28677. * @param effect defines the effect associated with the vertex buffer
  28678. */
  28679. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28680. private _unbindVertexArrayObject;
  28681. /**
  28682. * Bind a list of vertex buffers to the webGL context
  28683. * @param vertexBuffers defines the list of vertex buffers to bind
  28684. * @param indexBuffer defines the index buffer to bind
  28685. * @param effect defines the effect associated with the vertex buffers
  28686. */
  28687. bindBuffers(vertexBuffers: {
  28688. [key: string]: Nullable<VertexBuffer>;
  28689. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28690. /**
  28691. * Unbind all instance attributes
  28692. */
  28693. unbindInstanceAttributes(): void;
  28694. /**
  28695. * Release and free the memory of a vertex array object
  28696. * @param vao defines the vertex array object to delete
  28697. */
  28698. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28699. /** @hidden */
  28700. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28701. /**
  28702. * Creates a webGL buffer to use with instanciation
  28703. * @param capacity defines the size of the buffer
  28704. * @returns the webGL buffer
  28705. */
  28706. createInstancesBuffer(capacity: number): WebGLBuffer;
  28707. /**
  28708. * Delete a webGL buffer used with instanciation
  28709. * @param buffer defines the webGL buffer to delete
  28710. */
  28711. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28712. /**
  28713. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28714. * @param instancesBuffer defines the webGL buffer to update and bind
  28715. * @param data defines the data to store in the buffer
  28716. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28717. */
  28718. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28719. /**
  28720. * Apply all cached states (depth, culling, stencil and alpha)
  28721. */
  28722. applyStates(): void;
  28723. /**
  28724. * Send a draw order
  28725. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28726. * @param indexStart defines the starting index
  28727. * @param indexCount defines the number of index to draw
  28728. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28729. */
  28730. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28731. /**
  28732. * Draw a list of points
  28733. * @param verticesStart defines the index of first vertex to draw
  28734. * @param verticesCount defines the count of vertices to draw
  28735. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28736. */
  28737. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28738. /**
  28739. * Draw a list of unindexed primitives
  28740. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28741. * @param verticesStart defines the index of first vertex to draw
  28742. * @param verticesCount defines the count of vertices to draw
  28743. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28744. */
  28745. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28746. /**
  28747. * Draw a list of indexed primitives
  28748. * @param fillMode defines the primitive to use
  28749. * @param indexStart defines the starting index
  28750. * @param indexCount defines the number of index to draw
  28751. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28752. */
  28753. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28754. /**
  28755. * Draw a list of unindexed primitives
  28756. * @param fillMode defines the primitive to use
  28757. * @param verticesStart defines the index of first vertex to draw
  28758. * @param verticesCount defines the count of vertices to draw
  28759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28760. */
  28761. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28762. private _drawMode;
  28763. /** @hidden */
  28764. _releaseEffect(effect: Effect): void;
  28765. /** @hidden */
  28766. _deleteProgram(program: WebGLProgram): void;
  28767. /**
  28768. * Create a new effect (used to store vertex/fragment shaders)
  28769. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28770. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28771. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28772. * @param samplers defines an array of string used to represent textures
  28773. * @param defines defines the string containing the defines to use to compile the shaders
  28774. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28775. * @param onCompiled defines a function to call when the effect creation is successful
  28776. * @param onError defines a function to call when the effect creation has failed
  28777. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28778. * @returns the new Effect
  28779. */
  28780. 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;
  28781. private _compileShader;
  28782. private _compileRawShader;
  28783. /**
  28784. * Directly creates a webGL program
  28785. * @param vertexCode defines the vertex shader code to use
  28786. * @param fragmentCode defines the fragment shader code to use
  28787. * @param context defines the webGL context to use (if not set, the current one will be used)
  28788. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28789. * @returns the new webGL program
  28790. */
  28791. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28792. /**
  28793. * Creates a webGL program
  28794. * @param vertexCode defines the vertex shader code to use
  28795. * @param fragmentCode defines the fragment shader code to use
  28796. * @param defines defines the string containing the defines to use to compile the shaders
  28797. * @param context defines the webGL context to use (if not set, the current one will be used)
  28798. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28799. * @returns the new webGL program
  28800. */
  28801. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28802. private _createShaderProgram;
  28803. private _finalizeProgram;
  28804. /** @hidden */
  28805. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28806. /** @hidden */
  28807. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28808. /**
  28809. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28810. * @param shaderProgram defines the webGL program to use
  28811. * @param uniformsNames defines the list of uniform names
  28812. * @returns an array of webGL uniform locations
  28813. */
  28814. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28815. /**
  28816. * Gets the lsit of active attributes for a given webGL program
  28817. * @param shaderProgram defines the webGL program to use
  28818. * @param attributesNames defines the list of attribute names to get
  28819. * @returns an array of indices indicating the offset of each attribute
  28820. */
  28821. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28822. /**
  28823. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28824. * @param effect defines the effect to activate
  28825. */
  28826. enableEffect(effect: Nullable<Effect>): void;
  28827. /**
  28828. * Set the value of an uniform to an array of int32
  28829. * @param uniform defines the webGL uniform location where to store the value
  28830. * @param array defines the array of int32 to store
  28831. */
  28832. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28833. /**
  28834. * Set the value of an uniform to an array of int32 (stored as vec2)
  28835. * @param uniform defines the webGL uniform location where to store the value
  28836. * @param array defines the array of int32 to store
  28837. */
  28838. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28839. /**
  28840. * Set the value of an uniform to an array of int32 (stored as vec3)
  28841. * @param uniform defines the webGL uniform location where to store the value
  28842. * @param array defines the array of int32 to store
  28843. */
  28844. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28845. /**
  28846. * Set the value of an uniform to an array of int32 (stored as vec4)
  28847. * @param uniform defines the webGL uniform location where to store the value
  28848. * @param array defines the array of int32 to store
  28849. */
  28850. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28851. /**
  28852. * Set the value of an uniform to an array of float32
  28853. * @param uniform defines the webGL uniform location where to store the value
  28854. * @param array defines the array of float32 to store
  28855. */
  28856. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28857. /**
  28858. * Set the value of an uniform to an array of float32 (stored as vec2)
  28859. * @param uniform defines the webGL uniform location where to store the value
  28860. * @param array defines the array of float32 to store
  28861. */
  28862. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28863. /**
  28864. * Set the value of an uniform to an array of float32 (stored as vec3)
  28865. * @param uniform defines the webGL uniform location where to store the value
  28866. * @param array defines the array of float32 to store
  28867. */
  28868. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28869. /**
  28870. * Set the value of an uniform to an array of float32 (stored as vec4)
  28871. * @param uniform defines the webGL uniform location where to store the value
  28872. * @param array defines the array of float32 to store
  28873. */
  28874. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28875. /**
  28876. * Set the value of an uniform to an array of number
  28877. * @param uniform defines the webGL uniform location where to store the value
  28878. * @param array defines the array of number to store
  28879. */
  28880. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28881. /**
  28882. * Set the value of an uniform to an array of number (stored as vec2)
  28883. * @param uniform defines the webGL uniform location where to store the value
  28884. * @param array defines the array of number to store
  28885. */
  28886. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28887. /**
  28888. * Set the value of an uniform to an array of number (stored as vec3)
  28889. * @param uniform defines the webGL uniform location where to store the value
  28890. * @param array defines the array of number to store
  28891. */
  28892. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28893. /**
  28894. * Set the value of an uniform to an array of number (stored as vec4)
  28895. * @param uniform defines the webGL uniform location where to store the value
  28896. * @param array defines the array of number to store
  28897. */
  28898. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28899. /**
  28900. * Set the value of an uniform to an array of float32 (stored as matrices)
  28901. * @param uniform defines the webGL uniform location where to store the value
  28902. * @param matrices defines the array of float32 to store
  28903. */
  28904. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28905. /**
  28906. * Set the value of an uniform to a matrix
  28907. * @param uniform defines the webGL uniform location where to store the value
  28908. * @param matrix defines the matrix to store
  28909. */
  28910. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28911. /**
  28912. * Set the value of an uniform to a matrix (3x3)
  28913. * @param uniform defines the webGL uniform location where to store the value
  28914. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28915. */
  28916. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28917. /**
  28918. * Set the value of an uniform to a matrix (2x2)
  28919. * @param uniform defines the webGL uniform location where to store the value
  28920. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28921. */
  28922. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28923. /**
  28924. * Set the value of an uniform to a number (int)
  28925. * @param uniform defines the webGL uniform location where to store the value
  28926. * @param value defines the int number to store
  28927. */
  28928. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28929. /**
  28930. * Set the value of an uniform to a number (float)
  28931. * @param uniform defines the webGL uniform location where to store the value
  28932. * @param value defines the float number to store
  28933. */
  28934. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28935. /**
  28936. * Set the value of an uniform to a vec2
  28937. * @param uniform defines the webGL uniform location where to store the value
  28938. * @param x defines the 1st component of the value
  28939. * @param y defines the 2nd component of the value
  28940. */
  28941. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28942. /**
  28943. * Set the value of an uniform to a vec3
  28944. * @param uniform defines the webGL uniform location where to store the value
  28945. * @param x defines the 1st component of the value
  28946. * @param y defines the 2nd component of the value
  28947. * @param z defines the 3rd component of the value
  28948. */
  28949. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28950. /**
  28951. * Set the value of an uniform to a boolean
  28952. * @param uniform defines the webGL uniform location where to store the value
  28953. * @param bool defines the boolean to store
  28954. */
  28955. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28956. /**
  28957. * Set the value of an uniform to a vec4
  28958. * @param uniform defines the webGL uniform location where to store the value
  28959. * @param x defines the 1st component of the value
  28960. * @param y defines the 2nd component of the value
  28961. * @param z defines the 3rd component of the value
  28962. * @param w defines the 4th component of the value
  28963. */
  28964. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28965. /**
  28966. * Set the value of an uniform to a Color3
  28967. * @param uniform defines the webGL uniform location where to store the value
  28968. * @param color3 defines the color to store
  28969. */
  28970. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28971. /**
  28972. * Set the value of an uniform to a Color3 and an alpha value
  28973. * @param uniform defines the webGL uniform location where to store the value
  28974. * @param color3 defines the color to store
  28975. * @param alpha defines the alpha component to store
  28976. */
  28977. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28978. /**
  28979. * Sets a Color4 on a uniform variable
  28980. * @param uniform defines the uniform location
  28981. * @param color4 defines the value to be set
  28982. */
  28983. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28984. /**
  28985. * Set various states to the webGL context
  28986. * @param culling defines backface culling state
  28987. * @param zOffset defines the value to apply to zOffset (0 by default)
  28988. * @param force defines if states must be applied even if cache is up to date
  28989. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28990. */
  28991. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28992. /**
  28993. * Set the z offset to apply to current rendering
  28994. * @param value defines the offset to apply
  28995. */
  28996. setZOffset(value: number): void;
  28997. /**
  28998. * Gets the current value of the zOffset
  28999. * @returns the current zOffset state
  29000. */
  29001. getZOffset(): number;
  29002. /**
  29003. * Enable or disable depth buffering
  29004. * @param enable defines the state to set
  29005. */
  29006. setDepthBuffer(enable: boolean): void;
  29007. /**
  29008. * Gets a boolean indicating if depth writing is enabled
  29009. * @returns the current depth writing state
  29010. */
  29011. getDepthWrite(): boolean;
  29012. /**
  29013. * Enable or disable depth writing
  29014. * @param enable defines the state to set
  29015. */
  29016. setDepthWrite(enable: boolean): void;
  29017. /**
  29018. * Enable or disable color writing
  29019. * @param enable defines the state to set
  29020. */
  29021. setColorWrite(enable: boolean): void;
  29022. /**
  29023. * Gets a boolean indicating if color writing is enabled
  29024. * @returns the current color writing state
  29025. */
  29026. getColorWrite(): boolean;
  29027. /**
  29028. * Sets alpha constants used by some alpha blending modes
  29029. * @param r defines the red component
  29030. * @param g defines the green component
  29031. * @param b defines the blue component
  29032. * @param a defines the alpha component
  29033. */
  29034. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29035. /**
  29036. * Sets the current alpha mode
  29037. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29038. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29039. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29040. */
  29041. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29042. /**
  29043. * Gets the current alpha mode
  29044. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29045. * @returns the current alpha mode
  29046. */
  29047. getAlphaMode(): number;
  29048. /**
  29049. * Clears the list of texture accessible through engine.
  29050. * This can help preventing texture load conflict due to name collision.
  29051. */
  29052. clearInternalTexturesCache(): void;
  29053. /**
  29054. * Force the entire cache to be cleared
  29055. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29056. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29057. */
  29058. wipeCaches(bruteForce?: boolean): void;
  29059. /**
  29060. * Set the compressed texture format to use, based on the formats you have, and the formats
  29061. * supported by the hardware / browser.
  29062. *
  29063. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29064. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29065. * to API arguments needed to compressed textures. This puts the burden on the container
  29066. * generator to house the arcane code for determining these for current & future formats.
  29067. *
  29068. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29069. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29070. *
  29071. * Note: The result of this call is not taken into account when a texture is base64.
  29072. *
  29073. * @param formatsAvailable defines the list of those format families you have created
  29074. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29075. *
  29076. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29077. * @returns The extension selected.
  29078. */
  29079. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29080. private _getSamplingParameters;
  29081. private _partialLoadImg;
  29082. private _cascadeLoadImgs;
  29083. /** @hidden */
  29084. _createTexture(): WebGLTexture;
  29085. /**
  29086. * Usually called from Texture.ts.
  29087. * Passed information to create a WebGLTexture
  29088. * @param urlArg defines a value which contains one of the following:
  29089. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29090. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29091. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29092. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29093. * @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)
  29094. * @param scene needed for loading to the correct scene
  29095. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29096. * @param onLoad optional callback to be called upon successful completion
  29097. * @param onError optional callback to be called upon failure
  29098. * @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
  29099. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29100. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29101. * @param forcedExtension defines the extension to use to pick the right loader
  29102. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29103. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29104. */
  29105. 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;
  29106. private _rescaleTexture;
  29107. /**
  29108. * Update a raw texture
  29109. * @param texture defines the texture to update
  29110. * @param data defines the data to store in the texture
  29111. * @param format defines the format of the data
  29112. * @param invertY defines if data must be stored with Y axis inverted
  29113. * @param compression defines the compression used (null by default)
  29114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29115. */
  29116. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29117. /**
  29118. * Creates a raw texture
  29119. * @param data defines the data to store in the texture
  29120. * @param width defines the width of the texture
  29121. * @param height defines the height of the texture
  29122. * @param format defines the format of the data
  29123. * @param generateMipMaps defines if the engine should generate the mip levels
  29124. * @param invertY defines if data must be stored with Y axis inverted
  29125. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29126. * @param compression defines the compression used (null by default)
  29127. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29128. * @returns the raw texture inside an InternalTexture
  29129. */
  29130. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29131. private _unpackFlipYCached;
  29132. /**
  29133. * In case you are sharing the context with other applications, it might
  29134. * be interested to not cache the unpack flip y state to ensure a consistent
  29135. * value would be set.
  29136. */
  29137. enableUnpackFlipYCached: boolean;
  29138. /** @hidden */
  29139. _unpackFlipY(value: boolean): void;
  29140. /** @hidden */
  29141. _getUnpackAlignement(): number;
  29142. /**
  29143. * Creates a dynamic texture
  29144. * @param width defines the width of the texture
  29145. * @param height defines the height of the texture
  29146. * @param generateMipMaps defines if the engine should generate the mip levels
  29147. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29148. * @returns the dynamic texture inside an InternalTexture
  29149. */
  29150. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29151. /**
  29152. * Update the sampling mode of a given texture
  29153. * @param samplingMode defines the required sampling mode
  29154. * @param texture defines the texture to update
  29155. */
  29156. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29157. /**
  29158. * Update the content of a dynamic texture
  29159. * @param texture defines the texture to update
  29160. * @param canvas defines the canvas containing the source
  29161. * @param invertY defines if data must be stored with Y axis inverted
  29162. * @param premulAlpha defines if alpha is stored as premultiplied
  29163. * @param format defines the format of the data
  29164. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29165. */
  29166. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29167. /**
  29168. * Update a video texture
  29169. * @param texture defines the texture to update
  29170. * @param video defines the video element to use
  29171. * @param invertY defines if data must be stored with Y axis inverted
  29172. */
  29173. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29174. /**
  29175. * Updates a depth texture Comparison Mode and Function.
  29176. * If the comparison Function is equal to 0, the mode will be set to none.
  29177. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29178. * @param texture The texture to set the comparison function for
  29179. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29180. */
  29181. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29182. private _setupDepthStencilTexture;
  29183. /**
  29184. * Creates a depth stencil texture.
  29185. * This is only available in WebGL 2 or with the depth texture extension available.
  29186. * @param size The size of face edge in the texture.
  29187. * @param options The options defining the texture.
  29188. * @returns The texture
  29189. */
  29190. createDepthStencilTexture(size: number | {
  29191. width: number;
  29192. height: number;
  29193. }, options: DepthTextureCreationOptions): InternalTexture;
  29194. /**
  29195. * Creates a depth stencil texture.
  29196. * This is only available in WebGL 2 or with the depth texture extension available.
  29197. * @param size The size of face edge in the texture.
  29198. * @param options The options defining the texture.
  29199. * @returns The texture
  29200. */
  29201. private _createDepthStencilTexture;
  29202. /**
  29203. * Creates a depth stencil cube texture.
  29204. * This is only available in WebGL 2.
  29205. * @param size The size of face edge in the cube texture.
  29206. * @param options The options defining the cube texture.
  29207. * @returns The cube texture
  29208. */
  29209. private _createDepthStencilCubeTexture;
  29210. /**
  29211. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29212. * @param renderTarget The render target to set the frame buffer for
  29213. */
  29214. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29215. /**
  29216. * Creates a new render target texture
  29217. * @param size defines the size of the texture
  29218. * @param options defines the options used to create the texture
  29219. * @returns a new render target texture stored in an InternalTexture
  29220. */
  29221. createRenderTargetTexture(size: number | {
  29222. width: number;
  29223. height: number;
  29224. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29225. /**
  29226. * Create a multi render target texture
  29227. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29228. * @param size defines the size of the texture
  29229. * @param options defines the creation options
  29230. * @returns the cube texture as an InternalTexture
  29231. */
  29232. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29233. private _setupFramebufferDepthAttachments;
  29234. /**
  29235. * Updates the sample count of a render target texture
  29236. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29237. * @param texture defines the texture to update
  29238. * @param samples defines the sample count to set
  29239. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29240. */
  29241. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29242. /**
  29243. * Update the sample count for a given multiple render target texture
  29244. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29245. * @param textures defines the textures to update
  29246. * @param samples defines the sample count to set
  29247. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29248. */
  29249. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29250. /** @hidden */
  29251. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29252. /** @hidden */
  29253. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29254. /** @hidden */
  29255. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29256. /** @hidden */
  29257. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29258. /**
  29259. * Creates a new multiview render target
  29260. * @param width defines the width of the texture
  29261. * @param height defines the height of the texture
  29262. * @returns the created multiview texture
  29263. */
  29264. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  29265. /**
  29266. * Binds a multiview framebuffer to be drawn to
  29267. * @param multiviewTexture texture to bind
  29268. */
  29269. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  29270. /**
  29271. * Creates a new render target cube texture
  29272. * @param size defines the size of the texture
  29273. * @param options defines the options used to create the texture
  29274. * @returns a new render target cube texture stored in an InternalTexture
  29275. */
  29276. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29277. /**
  29278. * Creates a cube texture
  29279. * @param rootUrl defines the url where the files to load is located
  29280. * @param scene defines the current scene
  29281. * @param files defines the list of files to load (1 per face)
  29282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29283. * @param onLoad defines an optional callback raised when the texture is loaded
  29284. * @param onError defines an optional callback raised if there is an issue to load the texture
  29285. * @param format defines the format of the data
  29286. * @param forcedExtension defines the extension to use to pick the right loader
  29287. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29288. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29289. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29290. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29291. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29292. * @returns the cube texture as an InternalTexture
  29293. */
  29294. 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;
  29295. /**
  29296. * @hidden
  29297. */
  29298. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29299. /**
  29300. * Update a raw cube texture
  29301. * @param texture defines the texture to udpdate
  29302. * @param data defines the data to store
  29303. * @param format defines the data format
  29304. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29305. * @param invertY defines if data must be stored with Y axis inverted
  29306. * @param compression defines the compression used (null by default)
  29307. * @param level defines which level of the texture to update
  29308. */
  29309. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29310. /**
  29311. * Creates a new raw cube texture
  29312. * @param data defines the array of data to use to create each face
  29313. * @param size defines the size of the textures
  29314. * @param format defines the format of the data
  29315. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29316. * @param generateMipMaps defines if the engine should generate the mip levels
  29317. * @param invertY defines if data must be stored with Y axis inverted
  29318. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29319. * @param compression defines the compression used (null by default)
  29320. * @returns the cube texture as an InternalTexture
  29321. */
  29322. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29323. /**
  29324. * Creates a new raw cube texture from a specified url
  29325. * @param url defines the url where the data is located
  29326. * @param scene defines the current scene
  29327. * @param size defines the size of the textures
  29328. * @param format defines the format of the data
  29329. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29330. * @param noMipmap defines if the engine should avoid generating the mip levels
  29331. * @param callback defines a callback used to extract texture data from loaded data
  29332. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29333. * @param onLoad defines a callback called when texture is loaded
  29334. * @param onError defines a callback called if there is an error
  29335. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29336. * @param invertY defines if data must be stored with Y axis inverted
  29337. * @returns the cube texture as an InternalTexture
  29338. */
  29339. 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;
  29340. /**
  29341. * Update a raw 3D texture
  29342. * @param texture defines the texture to update
  29343. * @param data defines the data to store
  29344. * @param format defines the data format
  29345. * @param invertY defines if data must be stored with Y axis inverted
  29346. * @param compression defines the used compression (can be null)
  29347. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29348. */
  29349. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29350. /**
  29351. * Creates a new raw 3D texture
  29352. * @param data defines the data used to create the texture
  29353. * @param width defines the width of the texture
  29354. * @param height defines the height of the texture
  29355. * @param depth defines the depth of the texture
  29356. * @param format defines the format of the texture
  29357. * @param generateMipMaps defines if the engine must generate mip levels
  29358. * @param invertY defines if data must be stored with Y axis inverted
  29359. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29360. * @param compression defines the compressed used (can be null)
  29361. * @param textureType defines the compressed used (can be null)
  29362. * @returns a new raw 3D texture (stored in an InternalTexture)
  29363. */
  29364. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29365. private _prepareWebGLTextureContinuation;
  29366. private _prepareWebGLTexture;
  29367. private _convertRGBtoRGBATextureData;
  29368. /** @hidden */
  29369. _releaseFramebufferObjects(texture: InternalTexture): void;
  29370. /** @hidden */
  29371. _releaseTexture(texture: InternalTexture): void;
  29372. private setProgram;
  29373. private _boundUniforms;
  29374. /**
  29375. * Binds an effect to the webGL context
  29376. * @param effect defines the effect to bind
  29377. */
  29378. bindSamplers(effect: Effect): void;
  29379. private _moveBoundTextureOnTop;
  29380. private _getCorrectTextureChannel;
  29381. private _linkTrackers;
  29382. private _removeDesignatedSlot;
  29383. private _activateCurrentTexture;
  29384. /** @hidden */
  29385. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29386. /** @hidden */
  29387. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29388. /**
  29389. * Sets a texture to the webGL context from a postprocess
  29390. * @param channel defines the channel to use
  29391. * @param postProcess defines the source postprocess
  29392. */
  29393. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29394. /**
  29395. * Binds the output of the passed in post process to the texture channel specified
  29396. * @param channel The channel the texture should be bound to
  29397. * @param postProcess The post process which's output should be bound
  29398. */
  29399. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29400. /**
  29401. * Unbind all textures from the webGL context
  29402. */
  29403. unbindAllTextures(): void;
  29404. /**
  29405. * Sets a texture to the according uniform.
  29406. * @param channel The texture channel
  29407. * @param uniform The uniform to set
  29408. * @param texture The texture to apply
  29409. */
  29410. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29411. /**
  29412. * Sets a depth stencil texture from a render target to the according uniform.
  29413. * @param channel The texture channel
  29414. * @param uniform The uniform to set
  29415. * @param texture The render target texture containing the depth stencil texture to apply
  29416. */
  29417. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29418. private _bindSamplerUniformToChannel;
  29419. private _getTextureWrapMode;
  29420. private _setTexture;
  29421. /**
  29422. * Sets an array of texture to the webGL context
  29423. * @param channel defines the channel where the texture array must be set
  29424. * @param uniform defines the associated uniform location
  29425. * @param textures defines the array of textures to bind
  29426. */
  29427. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29428. /** @hidden */
  29429. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29430. private _setTextureParameterFloat;
  29431. private _setTextureParameterInteger;
  29432. /**
  29433. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29434. * @param x defines the x coordinate of the rectangle where pixels must be read
  29435. * @param y defines the y coordinate of the rectangle where pixels must be read
  29436. * @param width defines the width of the rectangle where pixels must be read
  29437. * @param height defines the height of the rectangle where pixels must be read
  29438. * @returns a Uint8Array containing RGBA colors
  29439. */
  29440. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29441. /**
  29442. * Add an externaly attached data from its key.
  29443. * This method call will fail and return false, if such key already exists.
  29444. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29445. * @param key the unique key that identifies the data
  29446. * @param data the data object to associate to the key for this Engine instance
  29447. * @return true if no such key were already present and the data was added successfully, false otherwise
  29448. */
  29449. addExternalData<T>(key: string, data: T): boolean;
  29450. /**
  29451. * Get an externaly attached data from its key
  29452. * @param key the unique key that identifies the data
  29453. * @return the associated data, if present (can be null), or undefined if not present
  29454. */
  29455. getExternalData<T>(key: string): T;
  29456. /**
  29457. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29458. * @param key the unique key that identifies the data
  29459. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29460. * @return the associated data, can be null if the factory returned null.
  29461. */
  29462. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29463. /**
  29464. * Remove an externaly attached data from the Engine instance
  29465. * @param key the unique key that identifies the data
  29466. * @return true if the data was successfully removed, false if it doesn't exist
  29467. */
  29468. removeExternalData(key: string): boolean;
  29469. /**
  29470. * Unbind all vertex attributes from the webGL context
  29471. */
  29472. unbindAllAttributes(): void;
  29473. /**
  29474. * 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
  29475. */
  29476. releaseEffects(): void;
  29477. /**
  29478. * Dispose and release all associated resources
  29479. */
  29480. dispose(): void;
  29481. /**
  29482. * Display the loading screen
  29483. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29484. */
  29485. displayLoadingUI(): void;
  29486. /**
  29487. * Hide the loading screen
  29488. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29489. */
  29490. hideLoadingUI(): void;
  29491. /**
  29492. * Gets the current loading screen object
  29493. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29494. */
  29495. /**
  29496. * Sets the current loading screen object
  29497. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29498. */
  29499. loadingScreen: ILoadingScreen;
  29500. /**
  29501. * Sets the current loading screen text
  29502. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29503. */
  29504. loadingUIText: string;
  29505. /**
  29506. * Sets the current loading screen background color
  29507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29508. */
  29509. loadingUIBackgroundColor: string;
  29510. /**
  29511. * Attach a new callback raised when context lost event is fired
  29512. * @param callback defines the callback to call
  29513. */
  29514. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29515. /**
  29516. * Attach a new callback raised when context restored event is fired
  29517. * @param callback defines the callback to call
  29518. */
  29519. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29520. /**
  29521. * Gets the source code of the vertex shader associated with a specific webGL program
  29522. * @param program defines the program to use
  29523. * @returns a string containing the source code of the vertex shader associated with the program
  29524. */
  29525. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29526. /**
  29527. * Gets the source code of the fragment shader associated with a specific webGL program
  29528. * @param program defines the program to use
  29529. * @returns a string containing the source code of the fragment shader associated with the program
  29530. */
  29531. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29532. /**
  29533. * Get the current error code of the webGL context
  29534. * @returns the error code
  29535. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29536. */
  29537. getError(): number;
  29538. /**
  29539. * Gets the current framerate
  29540. * @returns a number representing the framerate
  29541. */
  29542. getFps(): number;
  29543. /**
  29544. * Gets the time spent between current and previous frame
  29545. * @returns a number representing the delta time in ms
  29546. */
  29547. getDeltaTime(): number;
  29548. private _measureFps;
  29549. /** @hidden */
  29550. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29551. private _canRenderToFloatFramebuffer;
  29552. private _canRenderToHalfFloatFramebuffer;
  29553. private _canRenderToFramebuffer;
  29554. /** @hidden */
  29555. _getWebGLTextureType(type: number): number;
  29556. private _getInternalFormat;
  29557. /** @hidden */
  29558. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29559. /** @hidden */
  29560. _getRGBAMultiSampleBufferFormat(type: number): number;
  29561. /** @hidden */
  29562. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  29563. /** @hidden */
  29564. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29565. private _partialLoadFile;
  29566. private _cascadeLoadFiles;
  29567. /**
  29568. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29569. * @returns true if the engine can be created
  29570. * @ignorenaming
  29571. */
  29572. static isSupported(): boolean;
  29573. }
  29574. }
  29575. declare module "babylonjs/Materials/effect" {
  29576. import { Observable } from "babylonjs/Misc/observable";
  29577. import { Nullable } from "babylonjs/types";
  29578. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29579. import { Engine } from "babylonjs/Engines/engine";
  29580. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29581. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29582. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29583. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29585. /**
  29586. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29587. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29588. */
  29589. export class EffectFallbacks {
  29590. private _defines;
  29591. private _currentRank;
  29592. private _maxRank;
  29593. private _mesh;
  29594. /**
  29595. * Removes the fallback from the bound mesh.
  29596. */
  29597. unBindMesh(): void;
  29598. /**
  29599. * Adds a fallback on the specified property.
  29600. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29601. * @param define The name of the define in the shader
  29602. */
  29603. addFallback(rank: number, define: string): void;
  29604. /**
  29605. * Sets the mesh to use CPU skinning when needing to fallback.
  29606. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29607. * @param mesh The mesh to use the fallbacks.
  29608. */
  29609. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29610. /**
  29611. * Checks to see if more fallbacks are still availible.
  29612. */
  29613. readonly isMoreFallbacks: boolean;
  29614. /**
  29615. * Removes the defines that shoould be removed when falling back.
  29616. * @param currentDefines defines the current define statements for the shader.
  29617. * @param effect defines the current effect we try to compile
  29618. * @returns The resulting defines with defines of the current rank removed.
  29619. */
  29620. reduce(currentDefines: string, effect: Effect): string;
  29621. }
  29622. /**
  29623. * Options to be used when creating an effect.
  29624. */
  29625. export class EffectCreationOptions {
  29626. /**
  29627. * Atrributes that will be used in the shader.
  29628. */
  29629. attributes: string[];
  29630. /**
  29631. * Uniform varible names that will be set in the shader.
  29632. */
  29633. uniformsNames: string[];
  29634. /**
  29635. * Uniform buffer varible names that will be set in the shader.
  29636. */
  29637. uniformBuffersNames: string[];
  29638. /**
  29639. * Sampler texture variable names that will be set in the shader.
  29640. */
  29641. samplers: string[];
  29642. /**
  29643. * Define statements that will be set in the shader.
  29644. */
  29645. defines: any;
  29646. /**
  29647. * Possible fallbacks for this effect to improve performance when needed.
  29648. */
  29649. fallbacks: Nullable<EffectFallbacks>;
  29650. /**
  29651. * Callback that will be called when the shader is compiled.
  29652. */
  29653. onCompiled: Nullable<(effect: Effect) => void>;
  29654. /**
  29655. * Callback that will be called if an error occurs during shader compilation.
  29656. */
  29657. onError: Nullable<(effect: Effect, errors: string) => void>;
  29658. /**
  29659. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29660. */
  29661. indexParameters: any;
  29662. /**
  29663. * Max number of lights that can be used in the shader.
  29664. */
  29665. maxSimultaneousLights: number;
  29666. /**
  29667. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29668. */
  29669. transformFeedbackVaryings: Nullable<string[]>;
  29670. }
  29671. /**
  29672. * Effect containing vertex and fragment shader that can be executed on an object.
  29673. */
  29674. export class Effect {
  29675. /**
  29676. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29677. */
  29678. static ShadersRepository: string;
  29679. /**
  29680. * Name of the effect.
  29681. */
  29682. name: any;
  29683. /**
  29684. * String container all the define statements that should be set on the shader.
  29685. */
  29686. defines: string;
  29687. /**
  29688. * Callback that will be called when the shader is compiled.
  29689. */
  29690. onCompiled: Nullable<(effect: Effect) => void>;
  29691. /**
  29692. * Callback that will be called if an error occurs during shader compilation.
  29693. */
  29694. onError: Nullable<(effect: Effect, errors: string) => void>;
  29695. /**
  29696. * Callback that will be called when effect is bound.
  29697. */
  29698. onBind: Nullable<(effect: Effect) => void>;
  29699. /**
  29700. * Unique ID of the effect.
  29701. */
  29702. uniqueId: number;
  29703. /**
  29704. * Observable that will be called when the shader is compiled.
  29705. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29706. */
  29707. onCompileObservable: Observable<Effect>;
  29708. /**
  29709. * Observable that will be called if an error occurs during shader compilation.
  29710. */
  29711. onErrorObservable: Observable<Effect>;
  29712. /** @hidden */
  29713. _onBindObservable: Nullable<Observable<Effect>>;
  29714. /**
  29715. * Observable that will be called when effect is bound.
  29716. */
  29717. readonly onBindObservable: Observable<Effect>;
  29718. /** @hidden */
  29719. _bonesComputationForcedToCPU: boolean;
  29720. private static _uniqueIdSeed;
  29721. private _engine;
  29722. private _uniformBuffersNames;
  29723. private _uniformsNames;
  29724. private _samplers;
  29725. private _isReady;
  29726. private _compilationError;
  29727. private _attributesNames;
  29728. private _attributes;
  29729. private _uniforms;
  29730. /**
  29731. * Key for the effect.
  29732. * @hidden
  29733. */
  29734. _key: string;
  29735. private _indexParameters;
  29736. private _fallbacks;
  29737. private _vertexSourceCode;
  29738. private _fragmentSourceCode;
  29739. private _vertexSourceCodeOverride;
  29740. private _fragmentSourceCodeOverride;
  29741. private _transformFeedbackVaryings;
  29742. /**
  29743. * Compiled shader to webGL program.
  29744. * @hidden
  29745. */
  29746. _program: WebGLProgram;
  29747. private _valueCache;
  29748. private static _baseCache;
  29749. /**
  29750. * Instantiates an effect.
  29751. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29752. * @param baseName Name of the effect.
  29753. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29754. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29755. * @param samplers List of sampler variables that will be passed to the shader.
  29756. * @param engine Engine to be used to render the effect
  29757. * @param defines Define statements to be added to the shader.
  29758. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29759. * @param onCompiled Callback that will be called when the shader is compiled.
  29760. * @param onError Callback that will be called if an error occurs during shader compilation.
  29761. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29762. */
  29763. 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);
  29764. /**
  29765. * Unique key for this effect
  29766. */
  29767. readonly key: string;
  29768. /**
  29769. * If the effect has been compiled and prepared.
  29770. * @returns if the effect is compiled and prepared.
  29771. */
  29772. isReady(): boolean;
  29773. /**
  29774. * The engine the effect was initialized with.
  29775. * @returns the engine.
  29776. */
  29777. getEngine(): Engine;
  29778. /**
  29779. * The compiled webGL program for the effect
  29780. * @returns the webGL program.
  29781. */
  29782. getProgram(): WebGLProgram;
  29783. /**
  29784. * The set of names of attribute variables for the shader.
  29785. * @returns An array of attribute names.
  29786. */
  29787. getAttributesNames(): string[];
  29788. /**
  29789. * Returns the attribute at the given index.
  29790. * @param index The index of the attribute.
  29791. * @returns The location of the attribute.
  29792. */
  29793. getAttributeLocation(index: number): number;
  29794. /**
  29795. * Returns the attribute based on the name of the variable.
  29796. * @param name of the attribute to look up.
  29797. * @returns the attribute location.
  29798. */
  29799. getAttributeLocationByName(name: string): number;
  29800. /**
  29801. * The number of attributes.
  29802. * @returns the numnber of attributes.
  29803. */
  29804. getAttributesCount(): number;
  29805. /**
  29806. * Gets the index of a uniform variable.
  29807. * @param uniformName of the uniform to look up.
  29808. * @returns the index.
  29809. */
  29810. getUniformIndex(uniformName: string): number;
  29811. /**
  29812. * Returns the attribute based on the name of the variable.
  29813. * @param uniformName of the uniform to look up.
  29814. * @returns the location of the uniform.
  29815. */
  29816. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29817. /**
  29818. * Returns an array of sampler variable names
  29819. * @returns The array of sampler variable neames.
  29820. */
  29821. getSamplers(): string[];
  29822. /**
  29823. * The error from the last compilation.
  29824. * @returns the error string.
  29825. */
  29826. getCompilationError(): string;
  29827. /**
  29828. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29829. * @param func The callback to be used.
  29830. */
  29831. executeWhenCompiled(func: (effect: Effect) => void): void;
  29832. private _checkIsReady;
  29833. /** @hidden */
  29834. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29835. /** @hidden */
  29836. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29837. /** @hidden */
  29838. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29839. private _processShaderConversion;
  29840. private _processIncludes;
  29841. private _processPrecision;
  29842. /**
  29843. * Recompiles the webGL program
  29844. * @param vertexSourceCode The source code for the vertex shader.
  29845. * @param fragmentSourceCode The source code for the fragment shader.
  29846. * @param onCompiled Callback called when completed.
  29847. * @param onError Callback called on error.
  29848. * @hidden
  29849. */
  29850. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29851. /**
  29852. * Gets the uniform locations of the the specified variable names
  29853. * @param names THe names of the variables to lookup.
  29854. * @returns Array of locations in the same order as variable names.
  29855. */
  29856. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29857. /**
  29858. * Prepares the effect
  29859. * @hidden
  29860. */
  29861. _prepareEffect(): void;
  29862. /**
  29863. * Checks if the effect is supported. (Must be called after compilation)
  29864. */
  29865. readonly isSupported: boolean;
  29866. /**
  29867. * Binds a texture to the engine to be used as output of the shader.
  29868. * @param channel Name of the output variable.
  29869. * @param texture Texture to bind.
  29870. * @hidden
  29871. */
  29872. _bindTexture(channel: string, texture: InternalTexture): void;
  29873. /**
  29874. * Sets a texture on the engine to be used in the shader.
  29875. * @param channel Name of the sampler variable.
  29876. * @param texture Texture to set.
  29877. */
  29878. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29879. /**
  29880. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29881. * @param channel Name of the sampler variable.
  29882. * @param texture Texture to set.
  29883. */
  29884. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29885. /**
  29886. * Sets an array of textures on the engine to be used in the shader.
  29887. * @param channel Name of the variable.
  29888. * @param textures Textures to set.
  29889. */
  29890. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29891. /**
  29892. * 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)
  29893. * @param channel Name of the sampler variable.
  29894. * @param postProcess Post process to get the input texture from.
  29895. */
  29896. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29897. /**
  29898. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29899. * 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)
  29900. * @param channel Name of the sampler variable.
  29901. * @param postProcess Post process to get the output texture from.
  29902. */
  29903. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29904. /** @hidden */
  29905. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29906. /** @hidden */
  29907. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29908. /** @hidden */
  29909. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29910. /** @hidden */
  29911. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29912. /**
  29913. * Binds a buffer to a uniform.
  29914. * @param buffer Buffer to bind.
  29915. * @param name Name of the uniform variable to bind to.
  29916. */
  29917. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29918. /**
  29919. * Binds block to a uniform.
  29920. * @param blockName Name of the block to bind.
  29921. * @param index Index to bind.
  29922. */
  29923. bindUniformBlock(blockName: string, index: number): void;
  29924. /**
  29925. * Sets an interger value on a uniform variable.
  29926. * @param uniformName Name of the variable.
  29927. * @param value Value to be set.
  29928. * @returns this effect.
  29929. */
  29930. setInt(uniformName: string, value: number): Effect;
  29931. /**
  29932. * Sets an int array on a uniform variable.
  29933. * @param uniformName Name of the variable.
  29934. * @param array array to be set.
  29935. * @returns this effect.
  29936. */
  29937. setIntArray(uniformName: string, array: Int32Array): Effect;
  29938. /**
  29939. * 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)
  29940. * @param uniformName Name of the variable.
  29941. * @param array array to be set.
  29942. * @returns this effect.
  29943. */
  29944. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29945. /**
  29946. * 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)
  29947. * @param uniformName Name of the variable.
  29948. * @param array array to be set.
  29949. * @returns this effect.
  29950. */
  29951. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29952. /**
  29953. * 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)
  29954. * @param uniformName Name of the variable.
  29955. * @param array array to be set.
  29956. * @returns this effect.
  29957. */
  29958. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29959. /**
  29960. * Sets an float array on a uniform variable.
  29961. * @param uniformName Name of the variable.
  29962. * @param array array to be set.
  29963. * @returns this effect.
  29964. */
  29965. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29966. /**
  29967. * 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)
  29968. * @param uniformName Name of the variable.
  29969. * @param array array to be set.
  29970. * @returns this effect.
  29971. */
  29972. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29973. /**
  29974. * 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)
  29975. * @param uniformName Name of the variable.
  29976. * @param array array to be set.
  29977. * @returns this effect.
  29978. */
  29979. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29980. /**
  29981. * 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)
  29982. * @param uniformName Name of the variable.
  29983. * @param array array to be set.
  29984. * @returns this effect.
  29985. */
  29986. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29987. /**
  29988. * Sets an array on a uniform variable.
  29989. * @param uniformName Name of the variable.
  29990. * @param array array to be set.
  29991. * @returns this effect.
  29992. */
  29993. setArray(uniformName: string, array: number[]): Effect;
  29994. /**
  29995. * 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)
  29996. * @param uniformName Name of the variable.
  29997. * @param array array to be set.
  29998. * @returns this effect.
  29999. */
  30000. setArray2(uniformName: string, array: number[]): Effect;
  30001. /**
  30002. * 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)
  30003. * @param uniformName Name of the variable.
  30004. * @param array array to be set.
  30005. * @returns this effect.
  30006. */
  30007. setArray3(uniformName: string, array: number[]): Effect;
  30008. /**
  30009. * 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)
  30010. * @param uniformName Name of the variable.
  30011. * @param array array to be set.
  30012. * @returns this effect.
  30013. */
  30014. setArray4(uniformName: string, array: number[]): Effect;
  30015. /**
  30016. * Sets matrices on a uniform variable.
  30017. * @param uniformName Name of the variable.
  30018. * @param matrices matrices to be set.
  30019. * @returns this effect.
  30020. */
  30021. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30022. /**
  30023. * Sets matrix on a uniform variable.
  30024. * @param uniformName Name of the variable.
  30025. * @param matrix matrix to be set.
  30026. * @returns this effect.
  30027. */
  30028. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30029. /**
  30030. * 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)
  30031. * @param uniformName Name of the variable.
  30032. * @param matrix matrix to be set.
  30033. * @returns this effect.
  30034. */
  30035. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30036. /**
  30037. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30038. * @param uniformName Name of the variable.
  30039. * @param matrix matrix to be set.
  30040. * @returns this effect.
  30041. */
  30042. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30043. /**
  30044. * Sets a float on a uniform variable.
  30045. * @param uniformName Name of the variable.
  30046. * @param value value to be set.
  30047. * @returns this effect.
  30048. */
  30049. setFloat(uniformName: string, value: number): Effect;
  30050. /**
  30051. * Sets a boolean on a uniform variable.
  30052. * @param uniformName Name of the variable.
  30053. * @param bool value to be set.
  30054. * @returns this effect.
  30055. */
  30056. setBool(uniformName: string, bool: boolean): Effect;
  30057. /**
  30058. * Sets a Vector2 on a uniform variable.
  30059. * @param uniformName Name of the variable.
  30060. * @param vector2 vector2 to be set.
  30061. * @returns this effect.
  30062. */
  30063. setVector2(uniformName: string, vector2: Vector2): Effect;
  30064. /**
  30065. * Sets a float2 on a uniform variable.
  30066. * @param uniformName Name of the variable.
  30067. * @param x First float in float2.
  30068. * @param y Second float in float2.
  30069. * @returns this effect.
  30070. */
  30071. setFloat2(uniformName: string, x: number, y: number): Effect;
  30072. /**
  30073. * Sets a Vector3 on a uniform variable.
  30074. * @param uniformName Name of the variable.
  30075. * @param vector3 Value to be set.
  30076. * @returns this effect.
  30077. */
  30078. setVector3(uniformName: string, vector3: Vector3): Effect;
  30079. /**
  30080. * Sets a float3 on a uniform variable.
  30081. * @param uniformName Name of the variable.
  30082. * @param x First float in float3.
  30083. * @param y Second float in float3.
  30084. * @param z Third float in float3.
  30085. * @returns this effect.
  30086. */
  30087. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30088. /**
  30089. * Sets a Vector4 on a uniform variable.
  30090. * @param uniformName Name of the variable.
  30091. * @param vector4 Value to be set.
  30092. * @returns this effect.
  30093. */
  30094. setVector4(uniformName: string, vector4: Vector4): Effect;
  30095. /**
  30096. * Sets a float4 on a uniform variable.
  30097. * @param uniformName Name of the variable.
  30098. * @param x First float in float4.
  30099. * @param y Second float in float4.
  30100. * @param z Third float in float4.
  30101. * @param w Fourth float in float4.
  30102. * @returns this effect.
  30103. */
  30104. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30105. /**
  30106. * Sets a Color3 on a uniform variable.
  30107. * @param uniformName Name of the variable.
  30108. * @param color3 Value to be set.
  30109. * @returns this effect.
  30110. */
  30111. setColor3(uniformName: string, color3: Color3): Effect;
  30112. /**
  30113. * Sets a Color4 on a uniform variable.
  30114. * @param uniformName Name of the variable.
  30115. * @param color3 Value to be set.
  30116. * @param alpha Alpha value to be set.
  30117. * @returns this effect.
  30118. */
  30119. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30120. /**
  30121. * Sets a Color4 on a uniform variable
  30122. * @param uniformName defines the name of the variable
  30123. * @param color4 defines the value to be set
  30124. * @returns this effect.
  30125. */
  30126. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30127. /**
  30128. * This function will add a new shader to the shader store
  30129. * @param name the name of the shader
  30130. * @param pixelShader optional pixel shader content
  30131. * @param vertexShader optional vertex shader content
  30132. */
  30133. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30134. /**
  30135. * Store of each shader (The can be looked up using effect.key)
  30136. */
  30137. static ShadersStore: {
  30138. [key: string]: string;
  30139. };
  30140. /**
  30141. * Store of each included file for a shader (The can be looked up using effect.key)
  30142. */
  30143. static IncludesShadersStore: {
  30144. [key: string]: string;
  30145. };
  30146. /**
  30147. * Resets the cache of effects.
  30148. */
  30149. static ResetCache(): void;
  30150. }
  30151. }
  30152. declare module "babylonjs/Materials/colorCurves" {
  30153. import { Effect } from "babylonjs/Materials/effect";
  30154. /**
  30155. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30156. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30157. * 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;
  30158. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30159. */
  30160. export class ColorCurves {
  30161. private _dirty;
  30162. private _tempColor;
  30163. private _globalCurve;
  30164. private _highlightsCurve;
  30165. private _midtonesCurve;
  30166. private _shadowsCurve;
  30167. private _positiveCurve;
  30168. private _negativeCurve;
  30169. private _globalHue;
  30170. private _globalDensity;
  30171. private _globalSaturation;
  30172. private _globalExposure;
  30173. /**
  30174. * Gets the global Hue value.
  30175. * 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).
  30176. */
  30177. /**
  30178. * Sets the global Hue value.
  30179. * 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).
  30180. */
  30181. globalHue: number;
  30182. /**
  30183. * Gets the global Density value.
  30184. * 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.
  30185. * Values less than zero provide a filter of opposite hue.
  30186. */
  30187. /**
  30188. * Sets the global Density value.
  30189. * 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.
  30190. * Values less than zero provide a filter of opposite hue.
  30191. */
  30192. globalDensity: number;
  30193. /**
  30194. * Gets the global Saturation value.
  30195. * 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.
  30196. */
  30197. /**
  30198. * Sets the global Saturation value.
  30199. * 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.
  30200. */
  30201. globalSaturation: number;
  30202. /**
  30203. * Gets the global Exposure value.
  30204. * 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.
  30205. */
  30206. /**
  30207. * Sets the global Exposure value.
  30208. * 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.
  30209. */
  30210. globalExposure: number;
  30211. private _highlightsHue;
  30212. private _highlightsDensity;
  30213. private _highlightsSaturation;
  30214. private _highlightsExposure;
  30215. /**
  30216. * Gets the highlights Hue value.
  30217. * 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).
  30218. */
  30219. /**
  30220. * Sets the highlights Hue value.
  30221. * 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).
  30222. */
  30223. highlightsHue: number;
  30224. /**
  30225. * Gets the highlights Density value.
  30226. * 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.
  30227. * Values less than zero provide a filter of opposite hue.
  30228. */
  30229. /**
  30230. * Sets the highlights Density value.
  30231. * 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.
  30232. * Values less than zero provide a filter of opposite hue.
  30233. */
  30234. highlightsDensity: number;
  30235. /**
  30236. * Gets the highlights Saturation value.
  30237. * 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.
  30238. */
  30239. /**
  30240. * Sets the highlights Saturation value.
  30241. * 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.
  30242. */
  30243. highlightsSaturation: number;
  30244. /**
  30245. * Gets the highlights Exposure value.
  30246. * 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.
  30247. */
  30248. /**
  30249. * Sets the highlights Exposure value.
  30250. * 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.
  30251. */
  30252. highlightsExposure: number;
  30253. private _midtonesHue;
  30254. private _midtonesDensity;
  30255. private _midtonesSaturation;
  30256. private _midtonesExposure;
  30257. /**
  30258. * Gets the midtones Hue value.
  30259. * 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).
  30260. */
  30261. /**
  30262. * Sets the midtones Hue value.
  30263. * 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).
  30264. */
  30265. midtonesHue: number;
  30266. /**
  30267. * Gets the midtones Density value.
  30268. * 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.
  30269. * Values less than zero provide a filter of opposite hue.
  30270. */
  30271. /**
  30272. * Sets the midtones Density value.
  30273. * 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.
  30274. * Values less than zero provide a filter of opposite hue.
  30275. */
  30276. midtonesDensity: number;
  30277. /**
  30278. * Gets the midtones Saturation value.
  30279. * 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.
  30280. */
  30281. /**
  30282. * Sets the midtones Saturation value.
  30283. * 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.
  30284. */
  30285. midtonesSaturation: number;
  30286. /**
  30287. * Gets the midtones Exposure value.
  30288. * 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.
  30289. */
  30290. /**
  30291. * Sets the midtones Exposure value.
  30292. * 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.
  30293. */
  30294. midtonesExposure: number;
  30295. private _shadowsHue;
  30296. private _shadowsDensity;
  30297. private _shadowsSaturation;
  30298. private _shadowsExposure;
  30299. /**
  30300. * Gets the shadows Hue value.
  30301. * 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).
  30302. */
  30303. /**
  30304. * Sets the shadows Hue value.
  30305. * 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).
  30306. */
  30307. shadowsHue: number;
  30308. /**
  30309. * Gets the shadows Density value.
  30310. * 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.
  30311. * Values less than zero provide a filter of opposite hue.
  30312. */
  30313. /**
  30314. * Sets the shadows Density value.
  30315. * 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.
  30316. * Values less than zero provide a filter of opposite hue.
  30317. */
  30318. shadowsDensity: number;
  30319. /**
  30320. * Gets the shadows Saturation value.
  30321. * 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.
  30322. */
  30323. /**
  30324. * Sets the shadows Saturation value.
  30325. * 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.
  30326. */
  30327. shadowsSaturation: number;
  30328. /**
  30329. * Gets the shadows Exposure value.
  30330. * 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.
  30331. */
  30332. /**
  30333. * Sets the shadows Exposure value.
  30334. * 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.
  30335. */
  30336. shadowsExposure: number;
  30337. /**
  30338. * Returns the class name
  30339. * @returns The class name
  30340. */
  30341. getClassName(): string;
  30342. /**
  30343. * Binds the color curves to the shader.
  30344. * @param colorCurves The color curve to bind
  30345. * @param effect The effect to bind to
  30346. * @param positiveUniform The positive uniform shader parameter
  30347. * @param neutralUniform The neutral uniform shader parameter
  30348. * @param negativeUniform The negative uniform shader parameter
  30349. */
  30350. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30351. /**
  30352. * Prepare the list of uniforms associated with the ColorCurves effects.
  30353. * @param uniformsList The list of uniforms used in the effect
  30354. */
  30355. static PrepareUniforms(uniformsList: string[]): void;
  30356. /**
  30357. * Returns color grading data based on a hue, density, saturation and exposure value.
  30358. * @param filterHue The hue of the color filter.
  30359. * @param filterDensity The density of the color filter.
  30360. * @param saturation The saturation.
  30361. * @param exposure The exposure.
  30362. * @param result The result data container.
  30363. */
  30364. private getColorGradingDataToRef;
  30365. /**
  30366. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30367. * @param value The input slider value in range [-100,100].
  30368. * @returns Adjusted value.
  30369. */
  30370. private static applyColorGradingSliderNonlinear;
  30371. /**
  30372. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30373. * @param hue The hue (H) input.
  30374. * @param saturation The saturation (S) input.
  30375. * @param brightness The brightness (B) input.
  30376. * @result An RGBA color represented as Vector4.
  30377. */
  30378. private static fromHSBToRef;
  30379. /**
  30380. * Returns a value clamped between min and max
  30381. * @param value The value to clamp
  30382. * @param min The minimum of value
  30383. * @param max The maximum of value
  30384. * @returns The clamped value.
  30385. */
  30386. private static clamp;
  30387. /**
  30388. * Clones the current color curve instance.
  30389. * @return The cloned curves
  30390. */
  30391. clone(): ColorCurves;
  30392. /**
  30393. * Serializes the current color curve instance to a json representation.
  30394. * @return a JSON representation
  30395. */
  30396. serialize(): any;
  30397. /**
  30398. * Parses the color curve from a json representation.
  30399. * @param source the JSON source to parse
  30400. * @return The parsed curves
  30401. */
  30402. static Parse(source: any): ColorCurves;
  30403. }
  30404. }
  30405. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30406. import { Observable } from "babylonjs/Misc/observable";
  30407. import { Nullable } from "babylonjs/types";
  30408. import { Color4 } from "babylonjs/Maths/math";
  30409. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30410. import { Effect } from "babylonjs/Materials/effect";
  30411. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30412. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30413. /**
  30414. * Interface to follow in your material defines to integrate easily the
  30415. * Image proccessing functions.
  30416. * @hidden
  30417. */
  30418. export interface IImageProcessingConfigurationDefines {
  30419. IMAGEPROCESSING: boolean;
  30420. VIGNETTE: boolean;
  30421. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30422. VIGNETTEBLENDMODEOPAQUE: boolean;
  30423. TONEMAPPING: boolean;
  30424. TONEMAPPING_ACES: boolean;
  30425. CONTRAST: boolean;
  30426. EXPOSURE: boolean;
  30427. COLORCURVES: boolean;
  30428. COLORGRADING: boolean;
  30429. COLORGRADING3D: boolean;
  30430. SAMPLER3DGREENDEPTH: boolean;
  30431. SAMPLER3DBGRMAP: boolean;
  30432. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30433. }
  30434. /**
  30435. * @hidden
  30436. */
  30437. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30438. IMAGEPROCESSING: boolean;
  30439. VIGNETTE: boolean;
  30440. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30441. VIGNETTEBLENDMODEOPAQUE: boolean;
  30442. TONEMAPPING: boolean;
  30443. TONEMAPPING_ACES: boolean;
  30444. CONTRAST: boolean;
  30445. COLORCURVES: boolean;
  30446. COLORGRADING: boolean;
  30447. COLORGRADING3D: boolean;
  30448. SAMPLER3DGREENDEPTH: boolean;
  30449. SAMPLER3DBGRMAP: boolean;
  30450. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30451. EXPOSURE: boolean;
  30452. constructor();
  30453. }
  30454. /**
  30455. * This groups together the common properties used for image processing either in direct forward pass
  30456. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30457. * or not.
  30458. */
  30459. export class ImageProcessingConfiguration {
  30460. /**
  30461. * Default tone mapping applied in BabylonJS.
  30462. */
  30463. static readonly TONEMAPPING_STANDARD: number;
  30464. /**
  30465. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30466. * to other engines rendering to increase portability.
  30467. */
  30468. static readonly TONEMAPPING_ACES: number;
  30469. /**
  30470. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30471. */
  30472. colorCurves: Nullable<ColorCurves>;
  30473. private _colorCurvesEnabled;
  30474. /**
  30475. * Gets wether the color curves effect is enabled.
  30476. */
  30477. /**
  30478. * Sets wether the color curves effect is enabled.
  30479. */
  30480. colorCurvesEnabled: boolean;
  30481. private _colorGradingTexture;
  30482. /**
  30483. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30484. */
  30485. /**
  30486. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30487. */
  30488. colorGradingTexture: Nullable<BaseTexture>;
  30489. private _colorGradingEnabled;
  30490. /**
  30491. * Gets wether the color grading effect is enabled.
  30492. */
  30493. /**
  30494. * Sets wether the color grading effect is enabled.
  30495. */
  30496. colorGradingEnabled: boolean;
  30497. private _colorGradingWithGreenDepth;
  30498. /**
  30499. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30500. */
  30501. /**
  30502. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30503. */
  30504. colorGradingWithGreenDepth: boolean;
  30505. private _colorGradingBGR;
  30506. /**
  30507. * Gets wether the color grading texture contains BGR values.
  30508. */
  30509. /**
  30510. * Sets wether the color grading texture contains BGR values.
  30511. */
  30512. colorGradingBGR: boolean;
  30513. /** @hidden */
  30514. _exposure: number;
  30515. /**
  30516. * Gets the Exposure used in the effect.
  30517. */
  30518. /**
  30519. * Sets the Exposure used in the effect.
  30520. */
  30521. exposure: number;
  30522. private _toneMappingEnabled;
  30523. /**
  30524. * Gets wether the tone mapping effect is enabled.
  30525. */
  30526. /**
  30527. * Sets wether the tone mapping effect is enabled.
  30528. */
  30529. toneMappingEnabled: boolean;
  30530. private _toneMappingType;
  30531. /**
  30532. * Gets the type of tone mapping effect.
  30533. */
  30534. /**
  30535. * Sets the type of tone mapping effect used in BabylonJS.
  30536. */
  30537. toneMappingType: number;
  30538. protected _contrast: number;
  30539. /**
  30540. * Gets the contrast used in the effect.
  30541. */
  30542. /**
  30543. * Sets the contrast used in the effect.
  30544. */
  30545. contrast: number;
  30546. /**
  30547. * Vignette stretch size.
  30548. */
  30549. vignetteStretch: number;
  30550. /**
  30551. * Vignette centre X Offset.
  30552. */
  30553. vignetteCentreX: number;
  30554. /**
  30555. * Vignette centre Y Offset.
  30556. */
  30557. vignetteCentreY: number;
  30558. /**
  30559. * Vignette weight or intensity of the vignette effect.
  30560. */
  30561. vignetteWeight: number;
  30562. /**
  30563. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30564. * if vignetteEnabled is set to true.
  30565. */
  30566. vignetteColor: Color4;
  30567. /**
  30568. * Camera field of view used by the Vignette effect.
  30569. */
  30570. vignetteCameraFov: number;
  30571. private _vignetteBlendMode;
  30572. /**
  30573. * Gets the vignette blend mode allowing different kind of effect.
  30574. */
  30575. /**
  30576. * Sets the vignette blend mode allowing different kind of effect.
  30577. */
  30578. vignetteBlendMode: number;
  30579. private _vignetteEnabled;
  30580. /**
  30581. * Gets wether the vignette effect is enabled.
  30582. */
  30583. /**
  30584. * Sets wether the vignette effect is enabled.
  30585. */
  30586. vignetteEnabled: boolean;
  30587. private _applyByPostProcess;
  30588. /**
  30589. * Gets wether the image processing is applied through a post process or not.
  30590. */
  30591. /**
  30592. * Sets wether the image processing is applied through a post process or not.
  30593. */
  30594. applyByPostProcess: boolean;
  30595. private _isEnabled;
  30596. /**
  30597. * Gets wether the image processing is enabled or not.
  30598. */
  30599. /**
  30600. * Sets wether the image processing is enabled or not.
  30601. */
  30602. isEnabled: boolean;
  30603. /**
  30604. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30605. */
  30606. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30607. /**
  30608. * Method called each time the image processing information changes requires to recompile the effect.
  30609. */
  30610. protected _updateParameters(): void;
  30611. /**
  30612. * Gets the current class name.
  30613. * @return "ImageProcessingConfiguration"
  30614. */
  30615. getClassName(): string;
  30616. /**
  30617. * Prepare the list of uniforms associated with the Image Processing effects.
  30618. * @param uniforms The list of uniforms used in the effect
  30619. * @param defines the list of defines currently in use
  30620. */
  30621. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30622. /**
  30623. * Prepare the list of samplers associated with the Image Processing effects.
  30624. * @param samplersList The list of uniforms used in the effect
  30625. * @param defines the list of defines currently in use
  30626. */
  30627. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30628. /**
  30629. * Prepare the list of defines associated to the shader.
  30630. * @param defines the list of defines to complete
  30631. * @param forPostProcess Define if we are currently in post process mode or not
  30632. */
  30633. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30634. /**
  30635. * Returns true if all the image processing information are ready.
  30636. * @returns True if ready, otherwise, false
  30637. */
  30638. isReady(): boolean;
  30639. /**
  30640. * Binds the image processing to the shader.
  30641. * @param effect The effect to bind to
  30642. * @param aspectRatio Define the current aspect ratio of the effect
  30643. */
  30644. bind(effect: Effect, aspectRatio?: number): void;
  30645. /**
  30646. * Clones the current image processing instance.
  30647. * @return The cloned image processing
  30648. */
  30649. clone(): ImageProcessingConfiguration;
  30650. /**
  30651. * Serializes the current image processing instance to a json representation.
  30652. * @return a JSON representation
  30653. */
  30654. serialize(): any;
  30655. /**
  30656. * Parses the image processing from a json representation.
  30657. * @param source the JSON source to parse
  30658. * @return The parsed image processing
  30659. */
  30660. static Parse(source: any): ImageProcessingConfiguration;
  30661. private static _VIGNETTEMODE_MULTIPLY;
  30662. private static _VIGNETTEMODE_OPAQUE;
  30663. /**
  30664. * Used to apply the vignette as a mix with the pixel color.
  30665. */
  30666. static readonly VIGNETTEMODE_MULTIPLY: number;
  30667. /**
  30668. * Used to apply the vignette as a replacement of the pixel color.
  30669. */
  30670. static readonly VIGNETTEMODE_OPAQUE: number;
  30671. }
  30672. }
  30673. declare module "babylonjs/Materials/fresnelParameters" {
  30674. import { Color3 } from "babylonjs/Maths/math";
  30675. /**
  30676. * This represents all the required information to add a fresnel effect on a material:
  30677. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30678. */
  30679. export class FresnelParameters {
  30680. private _isEnabled;
  30681. /**
  30682. * Define if the fresnel effect is enable or not.
  30683. */
  30684. isEnabled: boolean;
  30685. /**
  30686. * Define the color used on edges (grazing angle)
  30687. */
  30688. leftColor: Color3;
  30689. /**
  30690. * Define the color used on center
  30691. */
  30692. rightColor: Color3;
  30693. /**
  30694. * Define bias applied to computed fresnel term
  30695. */
  30696. bias: number;
  30697. /**
  30698. * Defined the power exponent applied to fresnel term
  30699. */
  30700. power: number;
  30701. /**
  30702. * Clones the current fresnel and its valuues
  30703. * @returns a clone fresnel configuration
  30704. */
  30705. clone(): FresnelParameters;
  30706. /**
  30707. * Serializes the current fresnel parameters to a JSON representation.
  30708. * @return the JSON serialization
  30709. */
  30710. serialize(): any;
  30711. /**
  30712. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30713. * @param parsedFresnelParameters Define the JSON representation
  30714. * @returns the parsed parameters
  30715. */
  30716. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30717. }
  30718. }
  30719. declare module "babylonjs/Misc/decorators" {
  30720. import { Nullable } from "babylonjs/types";
  30721. import { Scene } from "babylonjs/scene";
  30722. import { IAnimatable } from "babylonjs/Misc/tools";
  30723. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30724. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30725. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30726. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30727. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30728. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30729. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30730. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30731. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30732. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30733. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30734. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30735. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30736. /**
  30737. * Decorator used to define property that can be serialized as reference to a camera
  30738. * @param sourceName defines the name of the property to decorate
  30739. */
  30740. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30741. /**
  30742. * Class used to help serialization objects
  30743. */
  30744. export class SerializationHelper {
  30745. /** hidden */
  30746. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30747. /** hidden */
  30748. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30749. /** hidden */
  30750. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30751. /** hidden */
  30752. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30753. /**
  30754. * Appends the serialized animations from the source animations
  30755. * @param source Source containing the animations
  30756. * @param destination Target to store the animations
  30757. */
  30758. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30759. /**
  30760. * Static function used to serialized a specific entity
  30761. * @param entity defines the entity to serialize
  30762. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30763. * @returns a JSON compatible object representing the serialization of the entity
  30764. */
  30765. static Serialize<T>(entity: T, serializationObject?: any): any;
  30766. /**
  30767. * Creates a new entity from a serialization data object
  30768. * @param creationFunction defines a function used to instanciated the new entity
  30769. * @param source defines the source serialization data
  30770. * @param scene defines the hosting scene
  30771. * @param rootUrl defines the root url for resources
  30772. * @returns a new entity
  30773. */
  30774. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30775. /**
  30776. * Clones an object
  30777. * @param creationFunction defines the function used to instanciate the new object
  30778. * @param source defines the source object
  30779. * @returns the cloned object
  30780. */
  30781. static Clone<T>(creationFunction: () => T, source: T): T;
  30782. /**
  30783. * Instanciates a new object based on a source one (some data will be shared between both object)
  30784. * @param creationFunction defines the function used to instanciate the new object
  30785. * @param source defines the source object
  30786. * @returns the new object
  30787. */
  30788. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30789. }
  30790. }
  30791. declare module "babylonjs/Cameras/camera" {
  30792. import { SmartArray } from "babylonjs/Misc/smartArray";
  30793. import { Observable } from "babylonjs/Misc/observable";
  30794. import { Nullable } from "babylonjs/types";
  30795. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30796. import { Scene } from "babylonjs/scene";
  30797. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30798. import { Node } from "babylonjs/node";
  30799. import { Mesh } from "babylonjs/Meshes/mesh";
  30800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30801. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30802. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30803. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30804. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30805. import { Ray } from "babylonjs/Culling/ray";
  30806. /**
  30807. * This is the base class of all the camera used in the application.
  30808. * @see http://doc.babylonjs.com/features/cameras
  30809. */
  30810. export class Camera extends Node {
  30811. /** @hidden */
  30812. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30813. /**
  30814. * This is the default projection mode used by the cameras.
  30815. * It helps recreating a feeling of perspective and better appreciate depth.
  30816. * This is the best way to simulate real life cameras.
  30817. */
  30818. static readonly PERSPECTIVE_CAMERA: number;
  30819. /**
  30820. * This helps creating camera with an orthographic mode.
  30821. * 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.
  30822. */
  30823. static readonly ORTHOGRAPHIC_CAMERA: number;
  30824. /**
  30825. * This is the default FOV mode for perspective cameras.
  30826. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30827. */
  30828. static readonly FOVMODE_VERTICAL_FIXED: number;
  30829. /**
  30830. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30831. */
  30832. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30833. /**
  30834. * This specifies ther is no need for a camera rig.
  30835. * Basically only one eye is rendered corresponding to the camera.
  30836. */
  30837. static readonly RIG_MODE_NONE: number;
  30838. /**
  30839. * Simulates a camera Rig with one blue eye and one red eye.
  30840. * This can be use with 3d blue and red glasses.
  30841. */
  30842. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30843. /**
  30844. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30845. */
  30846. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30847. /**
  30848. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30849. */
  30850. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30851. /**
  30852. * Defines that both eyes of the camera will be rendered over under each other.
  30853. */
  30854. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30855. /**
  30856. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30857. */
  30858. static readonly RIG_MODE_VR: number;
  30859. /**
  30860. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30861. */
  30862. static readonly RIG_MODE_WEBVR: number;
  30863. /**
  30864. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30865. */
  30866. static readonly RIG_MODE_CUSTOM: number;
  30867. /**
  30868. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30869. */
  30870. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30871. /**
  30872. * Define the input manager associated with the camera.
  30873. */
  30874. inputs: CameraInputsManager<Camera>;
  30875. /** @hidden */
  30876. _position: Vector3;
  30877. /**
  30878. * Define the current local position of the camera in the scene
  30879. */
  30880. position: Vector3;
  30881. /**
  30882. * The vector the camera should consider as up.
  30883. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30884. */
  30885. upVector: Vector3;
  30886. /**
  30887. * Define the current limit on the left side for an orthographic camera
  30888. * In scene unit
  30889. */
  30890. orthoLeft: Nullable<number>;
  30891. /**
  30892. * Define the current limit on the right side for an orthographic camera
  30893. * In scene unit
  30894. */
  30895. orthoRight: Nullable<number>;
  30896. /**
  30897. * Define the current limit on the bottom side for an orthographic camera
  30898. * In scene unit
  30899. */
  30900. orthoBottom: Nullable<number>;
  30901. /**
  30902. * Define the current limit on the top side for an orthographic camera
  30903. * In scene unit
  30904. */
  30905. orthoTop: Nullable<number>;
  30906. /**
  30907. * Field Of View is set in Radians. (default is 0.8)
  30908. */
  30909. fov: number;
  30910. /**
  30911. * Define the minimum distance the camera can see from.
  30912. * This is important to note that the depth buffer are not infinite and the closer it starts
  30913. * the more your scene might encounter depth fighting issue.
  30914. */
  30915. minZ: number;
  30916. /**
  30917. * Define the maximum distance the camera can see to.
  30918. * This is important to note that the depth buffer are not infinite and the further it end
  30919. * the more your scene might encounter depth fighting issue.
  30920. */
  30921. maxZ: number;
  30922. /**
  30923. * Define the default inertia of the camera.
  30924. * This helps giving a smooth feeling to the camera movement.
  30925. */
  30926. inertia: number;
  30927. /**
  30928. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30929. */
  30930. mode: number;
  30931. /**
  30932. * Define wether the camera is intermediate.
  30933. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30934. */
  30935. isIntermediate: boolean;
  30936. /**
  30937. * Define the viewport of the camera.
  30938. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30939. */
  30940. viewport: Viewport;
  30941. /**
  30942. * Restricts the camera to viewing objects with the same layerMask.
  30943. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30944. */
  30945. layerMask: number;
  30946. /**
  30947. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30948. */
  30949. fovMode: number;
  30950. /**
  30951. * Rig mode of the camera.
  30952. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30953. * This is normally controlled byt the camera themselves as internal use.
  30954. */
  30955. cameraRigMode: number;
  30956. /**
  30957. * Defines the distance between both "eyes" in case of a RIG
  30958. */
  30959. interaxialDistance: number;
  30960. /**
  30961. * Defines if stereoscopic rendering is done side by side or over under.
  30962. */
  30963. isStereoscopicSideBySide: boolean;
  30964. /**
  30965. * 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
  30966. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30967. * else in the scene.
  30968. */
  30969. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30970. /**
  30971. * When set, the camera will render to this render target instead of the default canvas
  30972. */
  30973. outputRenderTarget: Nullable<RenderTargetTexture>;
  30974. /**
  30975. * @hidden
  30976. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  30977. */
  30978. _useMultiviewToSingleView: boolean;
  30979. /**
  30980. * @hidden
  30981. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  30982. */
  30983. _multiviewTexture: Nullable<RenderTargetTexture>;
  30984. /**
  30985. * @hidden
  30986. * ensures the multiview texture of the camera exists and has the specified width/height
  30987. * @param width height to set on the multiview texture
  30988. * @param height width to set on the multiview texture
  30989. */
  30990. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  30991. /**
  30992. * Observable triggered when the camera view matrix has changed.
  30993. */
  30994. onViewMatrixChangedObservable: Observable<Camera>;
  30995. /**
  30996. * Observable triggered when the camera Projection matrix has changed.
  30997. */
  30998. onProjectionMatrixChangedObservable: Observable<Camera>;
  30999. /**
  31000. * Observable triggered when the inputs have been processed.
  31001. */
  31002. onAfterCheckInputsObservable: Observable<Camera>;
  31003. /**
  31004. * Observable triggered when reset has been called and applied to the camera.
  31005. */
  31006. onRestoreStateObservable: Observable<Camera>;
  31007. /** @hidden */
  31008. _cameraRigParams: any;
  31009. /** @hidden */
  31010. _rigCameras: Camera[];
  31011. /** @hidden */
  31012. _rigPostProcess: Nullable<PostProcess>;
  31013. protected _webvrViewMatrix: Matrix;
  31014. /** @hidden */
  31015. _skipRendering: boolean;
  31016. /** @hidden */
  31017. _projectionMatrix: Matrix;
  31018. /** @hidden */
  31019. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31020. /** @hidden */
  31021. _activeMeshes: SmartArray<AbstractMesh>;
  31022. protected _globalPosition: Vector3;
  31023. /** hidden */
  31024. _computedViewMatrix: Matrix;
  31025. private _doNotComputeProjectionMatrix;
  31026. private _transformMatrix;
  31027. private _frustumPlanes;
  31028. private _refreshFrustumPlanes;
  31029. private _storedFov;
  31030. private _stateStored;
  31031. /**
  31032. * Instantiates a new camera object.
  31033. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31034. * @see http://doc.babylonjs.com/features/cameras
  31035. * @param name Defines the name of the camera in the scene
  31036. * @param position Defines the position of the camera
  31037. * @param scene Defines the scene the camera belongs too
  31038. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31039. */
  31040. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31041. /**
  31042. * Store current camera state (fov, position, etc..)
  31043. * @returns the camera
  31044. */
  31045. storeState(): Camera;
  31046. /**
  31047. * Restores the camera state values if it has been stored. You must call storeState() first
  31048. */
  31049. protected _restoreStateValues(): boolean;
  31050. /**
  31051. * Restored camera state. You must call storeState() first.
  31052. * @returns true if restored and false otherwise
  31053. */
  31054. restoreState(): boolean;
  31055. /**
  31056. * Gets the class name of the camera.
  31057. * @returns the class name
  31058. */
  31059. getClassName(): string;
  31060. /** @hidden */
  31061. readonly _isCamera: boolean;
  31062. /**
  31063. * Gets a string representation of the camera useful for debug purpose.
  31064. * @param fullDetails Defines that a more verboe level of logging is required
  31065. * @returns the string representation
  31066. */
  31067. toString(fullDetails?: boolean): string;
  31068. /**
  31069. * Gets the current world space position of the camera.
  31070. */
  31071. readonly globalPosition: Vector3;
  31072. /**
  31073. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31074. * @returns the active meshe list
  31075. */
  31076. getActiveMeshes(): SmartArray<AbstractMesh>;
  31077. /**
  31078. * Check wether a mesh is part of the current active mesh list of the camera
  31079. * @param mesh Defines the mesh to check
  31080. * @returns true if active, false otherwise
  31081. */
  31082. isActiveMesh(mesh: Mesh): boolean;
  31083. /**
  31084. * Is this camera ready to be used/rendered
  31085. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31086. * @return true if the camera is ready
  31087. */
  31088. isReady(completeCheck?: boolean): boolean;
  31089. /** @hidden */
  31090. _initCache(): void;
  31091. /** @hidden */
  31092. _updateCache(ignoreParentClass?: boolean): void;
  31093. /** @hidden */
  31094. _isSynchronized(): boolean;
  31095. /** @hidden */
  31096. _isSynchronizedViewMatrix(): boolean;
  31097. /** @hidden */
  31098. _isSynchronizedProjectionMatrix(): boolean;
  31099. /**
  31100. * Attach the input controls to a specific dom element to get the input from.
  31101. * @param element Defines the element the controls should be listened from
  31102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31103. */
  31104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31105. /**
  31106. * Detach the current controls from the specified dom element.
  31107. * @param element Defines the element to stop listening the inputs from
  31108. */
  31109. detachControl(element: HTMLElement): void;
  31110. /**
  31111. * Update the camera state according to the different inputs gathered during the frame.
  31112. */
  31113. update(): void;
  31114. /** @hidden */
  31115. _checkInputs(): void;
  31116. /** @hidden */
  31117. readonly rigCameras: Camera[];
  31118. /**
  31119. * Gets the post process used by the rig cameras
  31120. */
  31121. readonly rigPostProcess: Nullable<PostProcess>;
  31122. /**
  31123. * Internal, gets the first post proces.
  31124. * @returns the first post process to be run on this camera.
  31125. */
  31126. _getFirstPostProcess(): Nullable<PostProcess>;
  31127. private _cascadePostProcessesToRigCams;
  31128. /**
  31129. * Attach a post process to the camera.
  31130. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31131. * @param postProcess The post process to attach to the camera
  31132. * @param insertAt The position of the post process in case several of them are in use in the scene
  31133. * @returns the position the post process has been inserted at
  31134. */
  31135. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31136. /**
  31137. * Detach a post process to the camera.
  31138. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31139. * @param postProcess The post process to detach from the camera
  31140. */
  31141. detachPostProcess(postProcess: PostProcess): void;
  31142. /**
  31143. * Gets the current world matrix of the camera
  31144. */
  31145. getWorldMatrix(): Matrix;
  31146. /** @hidden */
  31147. _getViewMatrix(): Matrix;
  31148. /**
  31149. * Gets the current view matrix of the camera.
  31150. * @param force forces the camera to recompute the matrix without looking at the cached state
  31151. * @returns the view matrix
  31152. */
  31153. getViewMatrix(force?: boolean): Matrix;
  31154. /**
  31155. * Freeze the projection matrix.
  31156. * It will prevent the cache check of the camera projection compute and can speed up perf
  31157. * if no parameter of the camera are meant to change
  31158. * @param projection Defines manually a projection if necessary
  31159. */
  31160. freezeProjectionMatrix(projection?: Matrix): void;
  31161. /**
  31162. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31163. */
  31164. unfreezeProjectionMatrix(): void;
  31165. /**
  31166. * Gets the current projection matrix of the camera.
  31167. * @param force forces the camera to recompute the matrix without looking at the cached state
  31168. * @returns the projection matrix
  31169. */
  31170. getProjectionMatrix(force?: boolean): Matrix;
  31171. /**
  31172. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31173. * @returns a Matrix
  31174. */
  31175. getTransformationMatrix(): Matrix;
  31176. private _updateFrustumPlanes;
  31177. /**
  31178. * Checks if a cullable object (mesh...) is in the camera frustum
  31179. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31180. * @param target The object to check
  31181. * @returns true if the object is in frustum otherwise false
  31182. */
  31183. isInFrustum(target: ICullable): boolean;
  31184. /**
  31185. * Checks if a cullable object (mesh...) is in the camera frustum
  31186. * Unlike isInFrustum this cheks the full bounding box
  31187. * @param target The object to check
  31188. * @returns true if the object is in frustum otherwise false
  31189. */
  31190. isCompletelyInFrustum(target: ICullable): boolean;
  31191. /**
  31192. * Gets a ray in the forward direction from the camera.
  31193. * @param length Defines the length of the ray to create
  31194. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31195. * @param origin Defines the start point of the ray which defaults to the camera position
  31196. * @returns the forward ray
  31197. */
  31198. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31199. /**
  31200. * Releases resources associated with this node.
  31201. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31202. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31203. */
  31204. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31205. /** @hidden */
  31206. _isLeftCamera: boolean;
  31207. /**
  31208. * Gets the left camera of a rig setup in case of Rigged Camera
  31209. */
  31210. readonly isLeftCamera: boolean;
  31211. /** @hidden */
  31212. _isRightCamera: boolean;
  31213. /**
  31214. * Gets the right camera of a rig setup in case of Rigged Camera
  31215. */
  31216. readonly isRightCamera: boolean;
  31217. /**
  31218. * Gets the left camera of a rig setup in case of Rigged Camera
  31219. */
  31220. readonly leftCamera: Nullable<FreeCamera>;
  31221. /**
  31222. * Gets the right camera of a rig setup in case of Rigged Camera
  31223. */
  31224. readonly rightCamera: Nullable<FreeCamera>;
  31225. /**
  31226. * Gets the left camera target of a rig setup in case of Rigged Camera
  31227. * @returns the target position
  31228. */
  31229. getLeftTarget(): Nullable<Vector3>;
  31230. /**
  31231. * Gets the right camera target of a rig setup in case of Rigged Camera
  31232. * @returns the target position
  31233. */
  31234. getRightTarget(): Nullable<Vector3>;
  31235. /**
  31236. * @hidden
  31237. */
  31238. setCameraRigMode(mode: number, rigParams: any): void;
  31239. /** @hidden */
  31240. static _setStereoscopicRigMode(camera: Camera): void;
  31241. /** @hidden */
  31242. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31243. /** @hidden */
  31244. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31245. /** @hidden */
  31246. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31247. /** @hidden */
  31248. _getVRProjectionMatrix(): Matrix;
  31249. protected _updateCameraRotationMatrix(): void;
  31250. protected _updateWebVRCameraRotationMatrix(): void;
  31251. /**
  31252. * This function MUST be overwritten by the different WebVR cameras available.
  31253. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31254. * @hidden
  31255. */
  31256. _getWebVRProjectionMatrix(): Matrix;
  31257. /**
  31258. * This function MUST be overwritten by the different WebVR cameras available.
  31259. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31260. * @hidden
  31261. */
  31262. _getWebVRViewMatrix(): Matrix;
  31263. /** @hidden */
  31264. setCameraRigParameter(name: string, value: any): void;
  31265. /**
  31266. * needs to be overridden by children so sub has required properties to be copied
  31267. * @hidden
  31268. */
  31269. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31270. /**
  31271. * May need to be overridden by children
  31272. * @hidden
  31273. */
  31274. _updateRigCameras(): void;
  31275. /** @hidden */
  31276. _setupInputs(): void;
  31277. /**
  31278. * Serialiaze the camera setup to a json represention
  31279. * @returns the JSON representation
  31280. */
  31281. serialize(): any;
  31282. /**
  31283. * Clones the current camera.
  31284. * @param name The cloned camera name
  31285. * @returns the cloned camera
  31286. */
  31287. clone(name: string): Camera;
  31288. /**
  31289. * Gets the direction of the camera relative to a given local axis.
  31290. * @param localAxis Defines the reference axis to provide a relative direction.
  31291. * @return the direction
  31292. */
  31293. getDirection(localAxis: Vector3): Vector3;
  31294. /**
  31295. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31296. * @param localAxis Defines the reference axis to provide a relative direction.
  31297. * @param result Defines the vector to store the result in
  31298. */
  31299. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31300. /**
  31301. * Gets a camera constructor for a given camera type
  31302. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31303. * @param name The name of the camera the result will be able to instantiate
  31304. * @param scene The scene the result will construct the camera in
  31305. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31306. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31307. * @returns a factory method to construc the camera
  31308. */
  31309. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31310. /**
  31311. * Compute the world matrix of the camera.
  31312. * @returns the camera workd matrix
  31313. */
  31314. computeWorldMatrix(): Matrix;
  31315. /**
  31316. * Parse a JSON and creates the camera from the parsed information
  31317. * @param parsedCamera The JSON to parse
  31318. * @param scene The scene to instantiate the camera in
  31319. * @returns the newly constructed camera
  31320. */
  31321. static Parse(parsedCamera: any, scene: Scene): Camera;
  31322. }
  31323. }
  31324. declare module "babylonjs/Misc/tools" {
  31325. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31326. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31327. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31328. import { Observable } from "babylonjs/Misc/observable";
  31329. import { DomManagement } from "babylonjs/Misc/domManagement";
  31330. import { WebRequest } from "babylonjs/Misc/webRequest";
  31331. import { Camera } from "babylonjs/Cameras/camera";
  31332. import { Engine } from "babylonjs/Engines/engine";
  31333. import { Animation } from "babylonjs/Animations/animation";
  31334. /**
  31335. * Interface for any object that can request an animation frame
  31336. */
  31337. export interface ICustomAnimationFrameRequester {
  31338. /**
  31339. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31340. */
  31341. renderFunction?: Function;
  31342. /**
  31343. * Called to request the next frame to render to
  31344. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31345. */
  31346. requestAnimationFrame: Function;
  31347. /**
  31348. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31349. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31350. */
  31351. requestID?: number;
  31352. }
  31353. /**
  31354. * Interface containing an array of animations
  31355. */
  31356. export interface IAnimatable {
  31357. /**
  31358. * Array of animations
  31359. */
  31360. animations: Array<Animation>;
  31361. }
  31362. /** Interface used by value gradients (color, factor, ...) */
  31363. export interface IValueGradient {
  31364. /**
  31365. * Gets or sets the gradient value (between 0 and 1)
  31366. */
  31367. gradient: number;
  31368. }
  31369. /** Class used to store color4 gradient */
  31370. export class ColorGradient implements IValueGradient {
  31371. /**
  31372. * Gets or sets the gradient value (between 0 and 1)
  31373. */
  31374. gradient: number;
  31375. /**
  31376. * Gets or sets first associated color
  31377. */
  31378. color1: Color4;
  31379. /**
  31380. * Gets or sets second associated color
  31381. */
  31382. color2?: Color4;
  31383. /**
  31384. * Will get a color picked randomly between color1 and color2.
  31385. * If color2 is undefined then color1 will be used
  31386. * @param result defines the target Color4 to store the result in
  31387. */
  31388. getColorToRef(result: Color4): void;
  31389. }
  31390. /** Class used to store color 3 gradient */
  31391. export class Color3Gradient implements IValueGradient {
  31392. /**
  31393. * Gets or sets the gradient value (between 0 and 1)
  31394. */
  31395. gradient: number;
  31396. /**
  31397. * Gets or sets the associated color
  31398. */
  31399. color: Color3;
  31400. }
  31401. /** Class used to store factor gradient */
  31402. export class FactorGradient implements IValueGradient {
  31403. /**
  31404. * Gets or sets the gradient value (between 0 and 1)
  31405. */
  31406. gradient: number;
  31407. /**
  31408. * Gets or sets first associated factor
  31409. */
  31410. factor1: number;
  31411. /**
  31412. * Gets or sets second associated factor
  31413. */
  31414. factor2?: number;
  31415. /**
  31416. * Will get a number picked randomly between factor1 and factor2.
  31417. * If factor2 is undefined then factor1 will be used
  31418. * @returns the picked number
  31419. */
  31420. getFactor(): number;
  31421. }
  31422. /**
  31423. * @ignore
  31424. * Application error to support additional information when loading a file
  31425. */
  31426. export class LoadFileError extends Error {
  31427. /** defines the optional web request */
  31428. request?: WebRequest | undefined;
  31429. private static _setPrototypeOf;
  31430. /**
  31431. * Creates a new LoadFileError
  31432. * @param message defines the message of the error
  31433. * @param request defines the optional web request
  31434. */
  31435. constructor(message: string,
  31436. /** defines the optional web request */
  31437. request?: WebRequest | undefined);
  31438. }
  31439. /**
  31440. * Class used to define a retry strategy when error happens while loading assets
  31441. */
  31442. export class RetryStrategy {
  31443. /**
  31444. * Function used to defines an exponential back off strategy
  31445. * @param maxRetries defines the maximum number of retries (3 by default)
  31446. * @param baseInterval defines the interval between retries
  31447. * @returns the strategy function to use
  31448. */
  31449. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31450. }
  31451. /**
  31452. * File request interface
  31453. */
  31454. export interface IFileRequest {
  31455. /**
  31456. * Raised when the request is complete (success or error).
  31457. */
  31458. onCompleteObservable: Observable<IFileRequest>;
  31459. /**
  31460. * Aborts the request for a file.
  31461. */
  31462. abort: () => void;
  31463. }
  31464. /**
  31465. * Class containing a set of static utilities functions
  31466. */
  31467. export class Tools {
  31468. /**
  31469. * Gets or sets the base URL to use to load assets
  31470. */
  31471. static BaseUrl: string;
  31472. /**
  31473. * Enable/Disable Custom HTTP Request Headers globally.
  31474. * default = false
  31475. * @see CustomRequestHeaders
  31476. */
  31477. static UseCustomRequestHeaders: boolean;
  31478. /**
  31479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31480. * i.e. when loading files, where the server/service expects an Authorization header
  31481. */
  31482. static CustomRequestHeaders: {
  31483. [key: string]: string;
  31484. };
  31485. /**
  31486. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31487. */
  31488. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31489. /**
  31490. * Default behaviour for cors in the application.
  31491. * It can be a string if the expected behavior is identical in the entire app.
  31492. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31493. */
  31494. static CorsBehavior: string | ((url: string | string[]) => string);
  31495. /**
  31496. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31497. * @ignorenaming
  31498. */
  31499. static UseFallbackTexture: boolean;
  31500. /**
  31501. * Use this object to register external classes like custom textures or material
  31502. * to allow the laoders to instantiate them
  31503. */
  31504. static RegisteredExternalClasses: {
  31505. [key: string]: Object;
  31506. };
  31507. /**
  31508. * Texture content used if a texture cannot loaded
  31509. * @ignorenaming
  31510. */
  31511. static fallbackTexture: string;
  31512. /**
  31513. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31514. * @param u defines the coordinate on X axis
  31515. * @param v defines the coordinate on Y axis
  31516. * @param width defines the width of the source data
  31517. * @param height defines the height of the source data
  31518. * @param pixels defines the source byte array
  31519. * @param color defines the output color
  31520. */
  31521. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31522. /**
  31523. * Interpolates between a and b via alpha
  31524. * @param a The lower value (returned when alpha = 0)
  31525. * @param b The upper value (returned when alpha = 1)
  31526. * @param alpha The interpolation-factor
  31527. * @return The mixed value
  31528. */
  31529. static Mix(a: number, b: number, alpha: number): number;
  31530. /**
  31531. * Tries to instantiate a new object from a given class name
  31532. * @param className defines the class name to instantiate
  31533. * @returns the new object or null if the system was not able to do the instantiation
  31534. */
  31535. static Instantiate(className: string): any;
  31536. /**
  31537. * Provides a slice function that will work even on IE
  31538. * @param data defines the array to slice
  31539. * @param start defines the start of the data (optional)
  31540. * @param end defines the end of the data (optional)
  31541. * @returns the new sliced array
  31542. */
  31543. static Slice<T>(data: T, start?: number, end?: number): T;
  31544. /**
  31545. * Polyfill for setImmediate
  31546. * @param action defines the action to execute after the current execution block
  31547. */
  31548. static SetImmediate(action: () => void): void;
  31549. /**
  31550. * Function indicating if a number is an exponent of 2
  31551. * @param value defines the value to test
  31552. * @returns true if the value is an exponent of 2
  31553. */
  31554. static IsExponentOfTwo(value: number): boolean;
  31555. private static _tmpFloatArray;
  31556. /**
  31557. * Returns the nearest 32-bit single precision float representation of a Number
  31558. * @param value A Number. If the parameter is of a different type, it will get converted
  31559. * to a number or to NaN if it cannot be converted
  31560. * @returns number
  31561. */
  31562. static FloatRound(value: number): number;
  31563. /**
  31564. * Find the next highest power of two.
  31565. * @param x Number to start search from.
  31566. * @return Next highest power of two.
  31567. */
  31568. static CeilingPOT(x: number): number;
  31569. /**
  31570. * Find the next lowest power of two.
  31571. * @param x Number to start search from.
  31572. * @return Next lowest power of two.
  31573. */
  31574. static FloorPOT(x: number): number;
  31575. /**
  31576. * Find the nearest power of two.
  31577. * @param x Number to start search from.
  31578. * @return Next nearest power of two.
  31579. */
  31580. static NearestPOT(x: number): number;
  31581. /**
  31582. * Get the closest exponent of two
  31583. * @param value defines the value to approximate
  31584. * @param max defines the maximum value to return
  31585. * @param mode defines how to define the closest value
  31586. * @returns closest exponent of two of the given value
  31587. */
  31588. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31589. /**
  31590. * Extracts the filename from a path
  31591. * @param path defines the path to use
  31592. * @returns the filename
  31593. */
  31594. static GetFilename(path: string): string;
  31595. /**
  31596. * Extracts the "folder" part of a path (everything before the filename).
  31597. * @param uri The URI to extract the info from
  31598. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31599. * @returns The "folder" part of the path
  31600. */
  31601. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31602. /**
  31603. * Extracts text content from a DOM element hierarchy
  31604. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31605. */
  31606. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31607. /**
  31608. * Convert an angle in radians to degrees
  31609. * @param angle defines the angle to convert
  31610. * @returns the angle in degrees
  31611. */
  31612. static ToDegrees(angle: number): number;
  31613. /**
  31614. * Convert an angle in degrees to radians
  31615. * @param angle defines the angle to convert
  31616. * @returns the angle in radians
  31617. */
  31618. static ToRadians(angle: number): number;
  31619. /**
  31620. * Encode a buffer to a base64 string
  31621. * @param buffer defines the buffer to encode
  31622. * @returns the encoded string
  31623. */
  31624. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31625. /**
  31626. * Extracts minimum and maximum values from a list of indexed positions
  31627. * @param positions defines the positions to use
  31628. * @param indices defines the indices to the positions
  31629. * @param indexStart defines the start index
  31630. * @param indexCount defines the end index
  31631. * @param bias defines bias value to add to the result
  31632. * @return minimum and maximum values
  31633. */
  31634. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31635. minimum: Vector3;
  31636. maximum: Vector3;
  31637. };
  31638. /**
  31639. * Extracts minimum and maximum values from a list of positions
  31640. * @param positions defines the positions to use
  31641. * @param start defines the start index in the positions array
  31642. * @param count defines the number of positions to handle
  31643. * @param bias defines bias value to add to the result
  31644. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31645. * @return minimum and maximum values
  31646. */
  31647. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31648. minimum: Vector3;
  31649. maximum: Vector3;
  31650. };
  31651. /**
  31652. * Returns an array if obj is not an array
  31653. * @param obj defines the object to evaluate as an array
  31654. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31655. * @returns either obj directly if obj is an array or a new array containing obj
  31656. */
  31657. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31658. /**
  31659. * Gets the pointer prefix to use
  31660. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31661. */
  31662. static GetPointerPrefix(): string;
  31663. /**
  31664. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31665. * @param func - the function to be called
  31666. * @param requester - the object that will request the next frame. Falls back to window.
  31667. * @returns frame number
  31668. */
  31669. static QueueNewFrame(func: () => void, requester?: any): number;
  31670. /**
  31671. * Ask the browser to promote the current element to fullscreen rendering mode
  31672. * @param element defines the DOM element to promote
  31673. */
  31674. static RequestFullscreen(element: HTMLElement): void;
  31675. /**
  31676. * Asks the browser to exit fullscreen mode
  31677. */
  31678. static ExitFullscreen(): void;
  31679. /**
  31680. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31681. * @param url define the url we are trying
  31682. * @param element define the dom element where to configure the cors policy
  31683. */
  31684. static SetCorsBehavior(url: string | string[], element: {
  31685. crossOrigin: string | null;
  31686. }): void;
  31687. /**
  31688. * Removes unwanted characters from an url
  31689. * @param url defines the url to clean
  31690. * @returns the cleaned url
  31691. */
  31692. static CleanUrl(url: string): string;
  31693. /**
  31694. * Gets or sets a function used to pre-process url before using them to load assets
  31695. */
  31696. static PreprocessUrl: (url: string) => string;
  31697. /**
  31698. * Loads an image as an HTMLImageElement.
  31699. * @param input url string, ArrayBuffer, or Blob to load
  31700. * @param onLoad callback called when the image successfully loads
  31701. * @param onError callback called when the image fails to load
  31702. * @param offlineProvider offline provider for caching
  31703. * @returns the HTMLImageElement of the loaded image
  31704. */
  31705. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31706. /**
  31707. * Loads a file
  31708. * @param url url string, ArrayBuffer, or Blob to load
  31709. * @param onSuccess callback called when the file successfully loads
  31710. * @param onProgress callback called while file is loading (if the server supports this mode)
  31711. * @param offlineProvider defines the offline provider for caching
  31712. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31713. * @param onError callback called when the file fails to load
  31714. * @returns a file request object
  31715. */
  31716. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31717. /**
  31718. * Load a script (identified by an url). When the url returns, the
  31719. * content of this file is added into a new script element, attached to the DOM (body element)
  31720. * @param scriptUrl defines the url of the script to laod
  31721. * @param onSuccess defines the callback called when the script is loaded
  31722. * @param onError defines the callback to call if an error occurs
  31723. */
  31724. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31725. /**
  31726. * Loads a file from a blob
  31727. * @param fileToLoad defines the blob to use
  31728. * @param callback defines the callback to call when data is loaded
  31729. * @param progressCallback defines the callback to call during loading process
  31730. * @returns a file request object
  31731. */
  31732. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31733. /**
  31734. * Loads a file
  31735. * @param fileToLoad defines the file to load
  31736. * @param callback defines the callback to call when data is loaded
  31737. * @param progressCallBack defines the callback to call during loading process
  31738. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31739. * @returns a file request object
  31740. */
  31741. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31742. /**
  31743. * Creates a data url from a given string content
  31744. * @param content defines the content to convert
  31745. * @returns the new data url link
  31746. */
  31747. static FileAsURL(content: string): string;
  31748. /**
  31749. * Format the given number to a specific decimal format
  31750. * @param value defines the number to format
  31751. * @param decimals defines the number of decimals to use
  31752. * @returns the formatted string
  31753. */
  31754. static Format(value: number, decimals?: number): string;
  31755. /**
  31756. * Checks if a given vector is inside a specific range
  31757. * @param v defines the vector to test
  31758. * @param min defines the minimum range
  31759. * @param max defines the maximum range
  31760. */
  31761. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31762. /**
  31763. * Tries to copy an object by duplicating every property
  31764. * @param source defines the source object
  31765. * @param destination defines the target object
  31766. * @param doNotCopyList defines a list of properties to avoid
  31767. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31768. */
  31769. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31770. /**
  31771. * Gets a boolean indicating if the given object has no own property
  31772. * @param obj defines the object to test
  31773. * @returns true if object has no own property
  31774. */
  31775. static IsEmpty(obj: any): boolean;
  31776. /**
  31777. * Function used to register events at window level
  31778. * @param events defines the events to register
  31779. */
  31780. static RegisterTopRootEvents(events: {
  31781. name: string;
  31782. handler: Nullable<(e: FocusEvent) => any>;
  31783. }[]): void;
  31784. /**
  31785. * Function used to unregister events from window level
  31786. * @param events defines the events to unregister
  31787. */
  31788. static UnregisterTopRootEvents(events: {
  31789. name: string;
  31790. handler: Nullable<(e: FocusEvent) => any>;
  31791. }[]): void;
  31792. /**
  31793. * @ignore
  31794. */
  31795. static _ScreenshotCanvas: HTMLCanvasElement;
  31796. /**
  31797. * Dumps the current bound framebuffer
  31798. * @param width defines the rendering width
  31799. * @param height defines the rendering height
  31800. * @param engine defines the hosting engine
  31801. * @param successCallback defines the callback triggered once the data are available
  31802. * @param mimeType defines the mime type of the result
  31803. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31804. */
  31805. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31806. /**
  31807. * Converts the canvas data to blob.
  31808. * This acts as a polyfill for browsers not supporting the to blob function.
  31809. * @param canvas Defines the canvas to extract the data from
  31810. * @param successCallback Defines the callback triggered once the data are available
  31811. * @param mimeType Defines the mime type of the result
  31812. */
  31813. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31814. /**
  31815. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31816. * @param successCallback defines the callback triggered once the data are available
  31817. * @param mimeType defines the mime type of the result
  31818. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31819. */
  31820. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31821. /**
  31822. * Downloads a blob in the browser
  31823. * @param blob defines the blob to download
  31824. * @param fileName defines the name of the downloaded file
  31825. */
  31826. static Download(blob: Blob, fileName: string): void;
  31827. /**
  31828. * Captures a screenshot of the current rendering
  31829. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31830. * @param engine defines the rendering engine
  31831. * @param camera defines the source camera
  31832. * @param size This parameter can be set to a single number or to an object with the
  31833. * following (optional) properties: precision, width, height. If a single number is passed,
  31834. * it will be used for both width and height. If an object is passed, the screenshot size
  31835. * will be derived from the parameters. The precision property is a multiplier allowing
  31836. * rendering at a higher or lower resolution
  31837. * @param successCallback defines the callback receives a single parameter which contains the
  31838. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31839. * src parameter of an <img> to display it
  31840. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31841. * Check your browser for supported MIME types
  31842. */
  31843. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31844. /**
  31845. * Generates an image screenshot from the specified camera.
  31846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31847. * @param engine The engine to use for rendering
  31848. * @param camera The camera to use for rendering
  31849. * @param size This parameter can be set to a single number or to an object with the
  31850. * following (optional) properties: precision, width, height. If a single number is passed,
  31851. * it will be used for both width and height. If an object is passed, the screenshot size
  31852. * will be derived from the parameters. The precision property is a multiplier allowing
  31853. * rendering at a higher or lower resolution
  31854. * @param successCallback The callback receives a single parameter which contains the
  31855. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31856. * src parameter of an <img> to display it
  31857. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31858. * Check your browser for supported MIME types
  31859. * @param samples Texture samples (default: 1)
  31860. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31861. * @param fileName A name for for the downloaded file.
  31862. */
  31863. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31864. /**
  31865. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31866. * Be aware Math.random() could cause collisions, but:
  31867. * "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"
  31868. * @returns a pseudo random id
  31869. */
  31870. static RandomId(): string;
  31871. /**
  31872. * Test if the given uri is a base64 string
  31873. * @param uri The uri to test
  31874. * @return True if the uri is a base64 string or false otherwise
  31875. */
  31876. static IsBase64(uri: string): boolean;
  31877. /**
  31878. * Decode the given base64 uri.
  31879. * @param uri The uri to decode
  31880. * @return The decoded base64 data.
  31881. */
  31882. static DecodeBase64(uri: string): ArrayBuffer;
  31883. /**
  31884. * No log
  31885. */
  31886. static readonly NoneLogLevel: number;
  31887. /**
  31888. * Only message logs
  31889. */
  31890. static readonly MessageLogLevel: number;
  31891. /**
  31892. * Only warning logs
  31893. */
  31894. static readonly WarningLogLevel: number;
  31895. /**
  31896. * Only error logs
  31897. */
  31898. static readonly ErrorLogLevel: number;
  31899. /**
  31900. * All logs
  31901. */
  31902. static readonly AllLogLevel: number;
  31903. /**
  31904. * Gets a value indicating the number of loading errors
  31905. * @ignorenaming
  31906. */
  31907. static readonly errorsCount: number;
  31908. /**
  31909. * Callback called when a new log is added
  31910. */
  31911. static OnNewCacheEntry: (entry: string) => void;
  31912. /**
  31913. * Log a message to the console
  31914. * @param message defines the message to log
  31915. */
  31916. static Log(message: string): void;
  31917. /**
  31918. * Write a warning message to the console
  31919. * @param message defines the message to log
  31920. */
  31921. static Warn(message: string): void;
  31922. /**
  31923. * Write an error message to the console
  31924. * @param message defines the message to log
  31925. */
  31926. static Error(message: string): void;
  31927. /**
  31928. * Gets current log cache (list of logs)
  31929. */
  31930. static readonly LogCache: string;
  31931. /**
  31932. * Clears the log cache
  31933. */
  31934. static ClearLogCache(): void;
  31935. /**
  31936. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31937. */
  31938. static LogLevels: number;
  31939. /**
  31940. * Checks if the loaded document was accessed via `file:`-Protocol.
  31941. * @returns boolean
  31942. */
  31943. static IsFileURL(): boolean;
  31944. /**
  31945. * Checks if the window object exists
  31946. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31947. */
  31948. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31949. /**
  31950. * No performance log
  31951. */
  31952. static readonly PerformanceNoneLogLevel: number;
  31953. /**
  31954. * Use user marks to log performance
  31955. */
  31956. static readonly PerformanceUserMarkLogLevel: number;
  31957. /**
  31958. * Log performance to the console
  31959. */
  31960. static readonly PerformanceConsoleLogLevel: number;
  31961. private static _performance;
  31962. /**
  31963. * Sets the current performance log level
  31964. */
  31965. static PerformanceLogLevel: number;
  31966. private static _StartPerformanceCounterDisabled;
  31967. private static _EndPerformanceCounterDisabled;
  31968. private static _StartUserMark;
  31969. private static _EndUserMark;
  31970. private static _StartPerformanceConsole;
  31971. private static _EndPerformanceConsole;
  31972. /**
  31973. * Starts a performance counter
  31974. */
  31975. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31976. /**
  31977. * Ends a specific performance coutner
  31978. */
  31979. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31980. /**
  31981. * Gets either window.performance.now() if supported or Date.now() else
  31982. */
  31983. static readonly Now: number;
  31984. /**
  31985. * This method will return the name of the class used to create the instance of the given object.
  31986. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31987. * @param object the object to get the class name from
  31988. * @param isType defines if the object is actually a type
  31989. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31990. */
  31991. static GetClassName(object: any, isType?: boolean): string;
  31992. /**
  31993. * Gets the first element of an array satisfying a given predicate
  31994. * @param array defines the array to browse
  31995. * @param predicate defines the predicate to use
  31996. * @returns null if not found or the element
  31997. */
  31998. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31999. /**
  32000. * This method will return the name of the full name of the class, including its owning module (if any).
  32001. * 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).
  32002. * @param object the object to get the class name from
  32003. * @param isType defines if the object is actually a type
  32004. * @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.
  32005. * @ignorenaming
  32006. */
  32007. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32008. /**
  32009. * Returns a promise that resolves after the given amount of time.
  32010. * @param delay Number of milliseconds to delay
  32011. * @returns Promise that resolves after the given amount of time
  32012. */
  32013. static DelayAsync(delay: number): Promise<void>;
  32014. /**
  32015. * Gets the current gradient from an array of IValueGradient
  32016. * @param ratio defines the current ratio to get
  32017. * @param gradients defines the array of IValueGradient
  32018. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32019. */
  32020. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32021. }
  32022. /**
  32023. * This class is used to track a performance counter which is number based.
  32024. * The user has access to many properties which give statistics of different nature.
  32025. *
  32026. * The implementer can track two kinds of Performance Counter: time and count.
  32027. * 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.
  32028. * 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.
  32029. */
  32030. export class PerfCounter {
  32031. /**
  32032. * Gets or sets a global boolean to turn on and off all the counters
  32033. */
  32034. static Enabled: boolean;
  32035. /**
  32036. * Returns the smallest value ever
  32037. */
  32038. readonly min: number;
  32039. /**
  32040. * Returns the biggest value ever
  32041. */
  32042. readonly max: number;
  32043. /**
  32044. * Returns the average value since the performance counter is running
  32045. */
  32046. readonly average: number;
  32047. /**
  32048. * Returns the average value of the last second the counter was monitored
  32049. */
  32050. readonly lastSecAverage: number;
  32051. /**
  32052. * Returns the current value
  32053. */
  32054. readonly current: number;
  32055. /**
  32056. * Gets the accumulated total
  32057. */
  32058. readonly total: number;
  32059. /**
  32060. * Gets the total value count
  32061. */
  32062. readonly count: number;
  32063. /**
  32064. * Creates a new counter
  32065. */
  32066. constructor();
  32067. /**
  32068. * Call this method to start monitoring a new frame.
  32069. * 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.
  32070. */
  32071. fetchNewFrame(): void;
  32072. /**
  32073. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32074. * @param newCount the count value to add to the monitored count
  32075. * @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.
  32076. */
  32077. addCount(newCount: number, fetchResult: boolean): void;
  32078. /**
  32079. * Start monitoring this performance counter
  32080. */
  32081. beginMonitoring(): void;
  32082. /**
  32083. * Compute the time lapsed since the previous beginMonitoring() call.
  32084. * @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
  32085. */
  32086. endMonitoring(newFrame?: boolean): void;
  32087. private _fetchResult;
  32088. private _startMonitoringTime;
  32089. private _min;
  32090. private _max;
  32091. private _average;
  32092. private _current;
  32093. private _totalValueCount;
  32094. private _totalAccumulated;
  32095. private _lastSecAverage;
  32096. private _lastSecAccumulated;
  32097. private _lastSecTime;
  32098. private _lastSecValueCount;
  32099. }
  32100. /**
  32101. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32102. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32103. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32104. * @param name The name of the class, case should be preserved
  32105. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32106. */
  32107. export function className(name: string, module?: string): (target: Object) => void;
  32108. /**
  32109. * An implementation of a loop for asynchronous functions.
  32110. */
  32111. export class AsyncLoop {
  32112. /**
  32113. * Defines the number of iterations for the loop
  32114. */
  32115. iterations: number;
  32116. /**
  32117. * Defines the current index of the loop.
  32118. */
  32119. index: number;
  32120. private _done;
  32121. private _fn;
  32122. private _successCallback;
  32123. /**
  32124. * Constructor.
  32125. * @param iterations the number of iterations.
  32126. * @param func the function to run each iteration
  32127. * @param successCallback the callback that will be called upon succesful execution
  32128. * @param offset starting offset.
  32129. */
  32130. constructor(
  32131. /**
  32132. * Defines the number of iterations for the loop
  32133. */
  32134. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32135. /**
  32136. * Execute the next iteration. Must be called after the last iteration was finished.
  32137. */
  32138. executeNext(): void;
  32139. /**
  32140. * Break the loop and run the success callback.
  32141. */
  32142. breakLoop(): void;
  32143. /**
  32144. * Create and run an async loop.
  32145. * @param iterations the number of iterations.
  32146. * @param fn the function to run each iteration
  32147. * @param successCallback the callback that will be called upon succesful execution
  32148. * @param offset starting offset.
  32149. * @returns the created async loop object
  32150. */
  32151. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32152. /**
  32153. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32154. * @param iterations total number of iterations
  32155. * @param syncedIterations number of synchronous iterations in each async iteration.
  32156. * @param fn the function to call each iteration.
  32157. * @param callback a success call back that will be called when iterating stops.
  32158. * @param breakFunction a break condition (optional)
  32159. * @param timeout timeout settings for the setTimeout function. default - 0.
  32160. * @returns the created async loop object
  32161. */
  32162. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32163. }
  32164. }
  32165. declare module "babylonjs/Collisions/collisionCoordinator" {
  32166. import { Nullable } from "babylonjs/types";
  32167. import { Scene } from "babylonjs/scene";
  32168. import { Vector3 } from "babylonjs/Maths/math";
  32169. import { Collider } from "babylonjs/Collisions/collider";
  32170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32171. /** @hidden */
  32172. export interface ICollisionCoordinator {
  32173. createCollider(): Collider;
  32174. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32175. init(scene: Scene): void;
  32176. }
  32177. /** @hidden */
  32178. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32179. private _scene;
  32180. private _scaledPosition;
  32181. private _scaledVelocity;
  32182. private _finalPosition;
  32183. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32184. createCollider(): Collider;
  32185. init(scene: Scene): void;
  32186. private _collideWithWorld;
  32187. }
  32188. }
  32189. declare module "babylonjs/Animations/animationGroup" {
  32190. import { Animatable } from "babylonjs/Animations/animatable";
  32191. import { Animation } from "babylonjs/Animations/animation";
  32192. import { Scene, IDisposable } from "babylonjs/scene";
  32193. import { Observable } from "babylonjs/Misc/observable";
  32194. import { Nullable } from "babylonjs/types";
  32195. /**
  32196. * This class defines the direct association between an animation and a target
  32197. */
  32198. export class TargetedAnimation {
  32199. /**
  32200. * Animation to perform
  32201. */
  32202. animation: Animation;
  32203. /**
  32204. * Target to animate
  32205. */
  32206. target: any;
  32207. }
  32208. /**
  32209. * Use this class to create coordinated animations on multiple targets
  32210. */
  32211. export class AnimationGroup implements IDisposable {
  32212. /** The name of the animation group */
  32213. name: string;
  32214. private _scene;
  32215. private _targetedAnimations;
  32216. private _animatables;
  32217. private _from;
  32218. private _to;
  32219. private _isStarted;
  32220. private _isPaused;
  32221. private _speedRatio;
  32222. /**
  32223. * Gets or sets the unique id of the node
  32224. */
  32225. uniqueId: number;
  32226. /**
  32227. * This observable will notify when one animation have ended
  32228. */
  32229. onAnimationEndObservable: Observable<TargetedAnimation>;
  32230. /**
  32231. * Observer raised when one animation loops
  32232. */
  32233. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32234. /**
  32235. * This observable will notify when all animations have ended.
  32236. */
  32237. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32238. /**
  32239. * This observable will notify when all animations have paused.
  32240. */
  32241. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32242. /**
  32243. * This observable will notify when all animations are playing.
  32244. */
  32245. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32246. /**
  32247. * Gets the first frame
  32248. */
  32249. readonly from: number;
  32250. /**
  32251. * Gets the last frame
  32252. */
  32253. readonly to: number;
  32254. /**
  32255. * Define if the animations are started
  32256. */
  32257. readonly isStarted: boolean;
  32258. /**
  32259. * Gets a value indicating that the current group is playing
  32260. */
  32261. readonly isPlaying: boolean;
  32262. /**
  32263. * Gets or sets the speed ratio to use for all animations
  32264. */
  32265. /**
  32266. * Gets or sets the speed ratio to use for all animations
  32267. */
  32268. speedRatio: number;
  32269. /**
  32270. * Gets the targeted animations for this animation group
  32271. */
  32272. readonly targetedAnimations: Array<TargetedAnimation>;
  32273. /**
  32274. * returning the list of animatables controlled by this animation group.
  32275. */
  32276. readonly animatables: Array<Animatable>;
  32277. /**
  32278. * Instantiates a new Animation Group.
  32279. * This helps managing several animations at once.
  32280. * @see http://doc.babylonjs.com/how_to/group
  32281. * @param name Defines the name of the group
  32282. * @param scene Defines the scene the group belongs to
  32283. */
  32284. constructor(
  32285. /** The name of the animation group */
  32286. name: string, scene?: Nullable<Scene>);
  32287. /**
  32288. * Add an animation (with its target) in the group
  32289. * @param animation defines the animation we want to add
  32290. * @param target defines the target of the animation
  32291. * @returns the TargetedAnimation object
  32292. */
  32293. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32294. /**
  32295. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32296. * It can add constant keys at begin or end
  32297. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32298. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32299. * @returns the animation group
  32300. */
  32301. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32302. /**
  32303. * Start all animations on given targets
  32304. * @param loop defines if animations must loop
  32305. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32306. * @param from defines the from key (optional)
  32307. * @param to defines the to key (optional)
  32308. * @returns the current animation group
  32309. */
  32310. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32311. /**
  32312. * Pause all animations
  32313. * @returns the animation group
  32314. */
  32315. pause(): AnimationGroup;
  32316. /**
  32317. * Play all animations to initial state
  32318. * This function will start() the animations if they were not started or will restart() them if they were paused
  32319. * @param loop defines if animations must loop
  32320. * @returns the animation group
  32321. */
  32322. play(loop?: boolean): AnimationGroup;
  32323. /**
  32324. * Reset all animations to initial state
  32325. * @returns the animation group
  32326. */
  32327. reset(): AnimationGroup;
  32328. /**
  32329. * Restart animations from key 0
  32330. * @returns the animation group
  32331. */
  32332. restart(): AnimationGroup;
  32333. /**
  32334. * Stop all animations
  32335. * @returns the animation group
  32336. */
  32337. stop(): AnimationGroup;
  32338. /**
  32339. * Set animation weight for all animatables
  32340. * @param weight defines the weight to use
  32341. * @return the animationGroup
  32342. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32343. */
  32344. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32345. /**
  32346. * Synchronize and normalize all animatables with a source animatable
  32347. * @param root defines the root animatable to synchronize with
  32348. * @return the animationGroup
  32349. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32350. */
  32351. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32352. /**
  32353. * Goes to a specific frame in this animation group
  32354. * @param frame the frame number to go to
  32355. * @return the animationGroup
  32356. */
  32357. goToFrame(frame: number): AnimationGroup;
  32358. /**
  32359. * Dispose all associated resources
  32360. */
  32361. dispose(): void;
  32362. private _checkAnimationGroupEnded;
  32363. /**
  32364. * Clone the current animation group and returns a copy
  32365. * @param newName defines the name of the new group
  32366. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32367. * @returns the new aniamtion group
  32368. */
  32369. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32370. /**
  32371. * Returns a new AnimationGroup object parsed from the source provided.
  32372. * @param parsedAnimationGroup defines the source
  32373. * @param scene defines the scene that will receive the animationGroup
  32374. * @returns a new AnimationGroup
  32375. */
  32376. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32377. /**
  32378. * Returns the string "AnimationGroup"
  32379. * @returns "AnimationGroup"
  32380. */
  32381. getClassName(): string;
  32382. /**
  32383. * Creates a detailled string about the object
  32384. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32385. * @returns a string representing the object
  32386. */
  32387. toString(fullDetails?: boolean): string;
  32388. }
  32389. }
  32390. declare module "babylonjs/scene" {
  32391. import { Nullable } from "babylonjs/types";
  32392. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32393. import { Observable } from "babylonjs/Misc/observable";
  32394. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32395. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32396. import { Geometry } from "babylonjs/Meshes/geometry";
  32397. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32398. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32400. import { Mesh } from "babylonjs/Meshes/mesh";
  32401. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32402. import { Bone } from "babylonjs/Bones/bone";
  32403. import { Skeleton } from "babylonjs/Bones/skeleton";
  32404. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32405. import { Camera } from "babylonjs/Cameras/camera";
  32406. import { AbstractScene } from "babylonjs/abstractScene";
  32407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32408. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32409. import { Material } from "babylonjs/Materials/material";
  32410. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32411. import { Effect } from "babylonjs/Materials/effect";
  32412. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32413. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32414. import { Light } from "babylonjs/Lights/light";
  32415. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32416. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32417. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32418. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32420. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32421. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32422. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32423. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32424. import { Engine } from "babylonjs/Engines/engine";
  32425. import { Node } from "babylonjs/node";
  32426. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32427. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32428. import { WebRequest } from "babylonjs/Misc/webRequest";
  32429. import { Ray } from "babylonjs/Culling/ray";
  32430. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32431. import { Animation } from "babylonjs/Animations/animation";
  32432. import { Animatable } from "babylonjs/Animations/animatable";
  32433. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32434. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32435. import { Collider } from "babylonjs/Collisions/collider";
  32436. /**
  32437. * Define an interface for all classes that will hold resources
  32438. */
  32439. export interface IDisposable {
  32440. /**
  32441. * Releases all held resources
  32442. */
  32443. dispose(): void;
  32444. }
  32445. /** Interface defining initialization parameters for Scene class */
  32446. export interface SceneOptions {
  32447. /**
  32448. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32449. * It will improve performance when the number of geometries becomes important.
  32450. */
  32451. useGeometryUniqueIdsMap?: boolean;
  32452. /**
  32453. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32454. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32455. */
  32456. useMaterialMeshMap?: boolean;
  32457. /**
  32458. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32459. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32460. */
  32461. useClonedMeshhMap?: boolean;
  32462. }
  32463. /**
  32464. * Represents a scene to be rendered by the engine.
  32465. * @see http://doc.babylonjs.com/features/scene
  32466. */
  32467. export class Scene extends AbstractScene implements IAnimatable {
  32468. private static _uniqueIdCounter;
  32469. /** The fog is deactivated */
  32470. static readonly FOGMODE_NONE: number;
  32471. /** The fog density is following an exponential function */
  32472. static readonly FOGMODE_EXP: number;
  32473. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32474. static readonly FOGMODE_EXP2: number;
  32475. /** The fog density is following a linear function. */
  32476. static readonly FOGMODE_LINEAR: number;
  32477. /**
  32478. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32479. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32480. */
  32481. static MinDeltaTime: number;
  32482. /**
  32483. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32484. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32485. */
  32486. static MaxDeltaTime: number;
  32487. /**
  32488. * Factory used to create the default material.
  32489. * @param name The name of the material to create
  32490. * @param scene The scene to create the material for
  32491. * @returns The default material
  32492. */
  32493. static DefaultMaterialFactory(scene: Scene): Material;
  32494. /**
  32495. * Factory used to create the a collision coordinator.
  32496. * @returns The collision coordinator
  32497. */
  32498. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32499. /** @hidden */
  32500. readonly _isScene: boolean;
  32501. /**
  32502. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32503. */
  32504. autoClear: boolean;
  32505. /**
  32506. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32507. */
  32508. autoClearDepthAndStencil: boolean;
  32509. /**
  32510. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32511. */
  32512. clearColor: Color4;
  32513. /**
  32514. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32515. */
  32516. ambientColor: Color3;
  32517. /**
  32518. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32519. * It should only be one of the following (if not the default embedded one):
  32520. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32521. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32522. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32523. * The material properties need to be setup according to the type of texture in use.
  32524. */
  32525. environmentBRDFTexture: BaseTexture;
  32526. /** @hidden */
  32527. protected _environmentTexture: Nullable<BaseTexture>;
  32528. /**
  32529. * Texture used in all pbr material as the reflection texture.
  32530. * As in the majority of the scene they are the same (exception for multi room and so on),
  32531. * this is easier to reference from here than from all the materials.
  32532. */
  32533. /**
  32534. * Texture used in all pbr material as the reflection texture.
  32535. * As in the majority of the scene they are the same (exception for multi room and so on),
  32536. * this is easier to set here than in all the materials.
  32537. */
  32538. environmentTexture: Nullable<BaseTexture>;
  32539. /** @hidden */
  32540. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32541. /**
  32542. * Default image processing configuration used either in the rendering
  32543. * Forward main pass or through the imageProcessingPostProcess if present.
  32544. * As in the majority of the scene they are the same (exception for multi camera),
  32545. * this is easier to reference from here than from all the materials and post process.
  32546. *
  32547. * No setter as we it is a shared configuration, you can set the values instead.
  32548. */
  32549. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32550. private _forceWireframe;
  32551. /**
  32552. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32553. */
  32554. forceWireframe: boolean;
  32555. private _forcePointsCloud;
  32556. /**
  32557. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32558. */
  32559. forcePointsCloud: boolean;
  32560. /**
  32561. * Gets or sets the active clipplane 1
  32562. */
  32563. clipPlane: Nullable<Plane>;
  32564. /**
  32565. * Gets or sets the active clipplane 2
  32566. */
  32567. clipPlane2: Nullable<Plane>;
  32568. /**
  32569. * Gets or sets the active clipplane 3
  32570. */
  32571. clipPlane3: Nullable<Plane>;
  32572. /**
  32573. * Gets or sets the active clipplane 4
  32574. */
  32575. clipPlane4: Nullable<Plane>;
  32576. /**
  32577. * Gets or sets a boolean indicating if animations are enabled
  32578. */
  32579. animationsEnabled: boolean;
  32580. private _animationPropertiesOverride;
  32581. /**
  32582. * Gets or sets the animation properties override
  32583. */
  32584. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32585. /**
  32586. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32587. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32588. */
  32589. useConstantAnimationDeltaTime: boolean;
  32590. /**
  32591. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32592. * Please note that it requires to run a ray cast through the scene on every frame
  32593. */
  32594. constantlyUpdateMeshUnderPointer: boolean;
  32595. /**
  32596. * Defines the HTML cursor to use when hovering over interactive elements
  32597. */
  32598. hoverCursor: string;
  32599. /**
  32600. * Defines the HTML default cursor to use (empty by default)
  32601. */
  32602. defaultCursor: string;
  32603. /**
  32604. * This is used to call preventDefault() on pointer down
  32605. * in order to block unwanted artifacts like system double clicks
  32606. */
  32607. preventDefaultOnPointerDown: boolean;
  32608. /**
  32609. * This is used to call preventDefault() on pointer up
  32610. * in order to block unwanted artifacts like system double clicks
  32611. */
  32612. preventDefaultOnPointerUp: boolean;
  32613. /**
  32614. * Gets or sets user defined metadata
  32615. */
  32616. metadata: any;
  32617. /**
  32618. * For internal use only. Please do not use.
  32619. */
  32620. reservedDataStore: any;
  32621. /**
  32622. * Gets the name of the plugin used to load this scene (null by default)
  32623. */
  32624. loadingPluginName: string;
  32625. /**
  32626. * Use this array to add regular expressions used to disable offline support for specific urls
  32627. */
  32628. disableOfflineSupportExceptionRules: RegExp[];
  32629. /**
  32630. * An event triggered when the scene is disposed.
  32631. */
  32632. onDisposeObservable: Observable<Scene>;
  32633. private _onDisposeObserver;
  32634. /** Sets a function to be executed when this scene is disposed. */
  32635. onDispose: () => void;
  32636. /**
  32637. * An event triggered before rendering the scene (right after animations and physics)
  32638. */
  32639. onBeforeRenderObservable: Observable<Scene>;
  32640. private _onBeforeRenderObserver;
  32641. /** Sets a function to be executed before rendering this scene */
  32642. beforeRender: Nullable<() => void>;
  32643. /**
  32644. * An event triggered after rendering the scene
  32645. */
  32646. onAfterRenderObservable: Observable<Scene>;
  32647. private _onAfterRenderObserver;
  32648. /** Sets a function to be executed after rendering this scene */
  32649. afterRender: Nullable<() => void>;
  32650. /**
  32651. * An event triggered before animating the scene
  32652. */
  32653. onBeforeAnimationsObservable: Observable<Scene>;
  32654. /**
  32655. * An event triggered after animations processing
  32656. */
  32657. onAfterAnimationsObservable: Observable<Scene>;
  32658. /**
  32659. * An event triggered before draw calls are ready to be sent
  32660. */
  32661. onBeforeDrawPhaseObservable: Observable<Scene>;
  32662. /**
  32663. * An event triggered after draw calls have been sent
  32664. */
  32665. onAfterDrawPhaseObservable: Observable<Scene>;
  32666. /**
  32667. * An event triggered when the scene is ready
  32668. */
  32669. onReadyObservable: Observable<Scene>;
  32670. /**
  32671. * An event triggered before rendering a camera
  32672. */
  32673. onBeforeCameraRenderObservable: Observable<Camera>;
  32674. private _onBeforeCameraRenderObserver;
  32675. /** Sets a function to be executed before rendering a camera*/
  32676. beforeCameraRender: () => void;
  32677. /**
  32678. * An event triggered after rendering a camera
  32679. */
  32680. onAfterCameraRenderObservable: Observable<Camera>;
  32681. private _onAfterCameraRenderObserver;
  32682. /** Sets a function to be executed after rendering a camera*/
  32683. afterCameraRender: () => void;
  32684. /**
  32685. * An event triggered when active meshes evaluation is about to start
  32686. */
  32687. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32688. /**
  32689. * An event triggered when active meshes evaluation is done
  32690. */
  32691. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32692. /**
  32693. * An event triggered when particles rendering is about to start
  32694. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32695. */
  32696. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32697. /**
  32698. * An event triggered when particles rendering is done
  32699. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32700. */
  32701. onAfterParticlesRenderingObservable: Observable<Scene>;
  32702. /**
  32703. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32704. */
  32705. onDataLoadedObservable: Observable<Scene>;
  32706. /**
  32707. * An event triggered when a camera is created
  32708. */
  32709. onNewCameraAddedObservable: Observable<Camera>;
  32710. /**
  32711. * An event triggered when a camera is removed
  32712. */
  32713. onCameraRemovedObservable: Observable<Camera>;
  32714. /**
  32715. * An event triggered when a light is created
  32716. */
  32717. onNewLightAddedObservable: Observable<Light>;
  32718. /**
  32719. * An event triggered when a light is removed
  32720. */
  32721. onLightRemovedObservable: Observable<Light>;
  32722. /**
  32723. * An event triggered when a geometry is created
  32724. */
  32725. onNewGeometryAddedObservable: Observable<Geometry>;
  32726. /**
  32727. * An event triggered when a geometry is removed
  32728. */
  32729. onGeometryRemovedObservable: Observable<Geometry>;
  32730. /**
  32731. * An event triggered when a transform node is created
  32732. */
  32733. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32734. /**
  32735. * An event triggered when a transform node is removed
  32736. */
  32737. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32738. /**
  32739. * An event triggered when a mesh is created
  32740. */
  32741. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32742. /**
  32743. * An event triggered when a mesh is removed
  32744. */
  32745. onMeshRemovedObservable: Observable<AbstractMesh>;
  32746. /**
  32747. * An event triggered when a skeleton is created
  32748. */
  32749. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32750. /**
  32751. * An event triggered when a skeleton is removed
  32752. */
  32753. onSkeletonRemovedObservable: Observable<Skeleton>;
  32754. /**
  32755. * An event triggered when a material is created
  32756. */
  32757. onNewMaterialAddedObservable: Observable<Material>;
  32758. /**
  32759. * An event triggered when a material is removed
  32760. */
  32761. onMaterialRemovedObservable: Observable<Material>;
  32762. /**
  32763. * An event triggered when a texture is created
  32764. */
  32765. onNewTextureAddedObservable: Observable<BaseTexture>;
  32766. /**
  32767. * An event triggered when a texture is removed
  32768. */
  32769. onTextureRemovedObservable: Observable<BaseTexture>;
  32770. /**
  32771. * An event triggered when render targets are about to be rendered
  32772. * Can happen multiple times per frame.
  32773. */
  32774. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32775. /**
  32776. * An event triggered when render targets were rendered.
  32777. * Can happen multiple times per frame.
  32778. */
  32779. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32780. /**
  32781. * An event triggered before calculating deterministic simulation step
  32782. */
  32783. onBeforeStepObservable: Observable<Scene>;
  32784. /**
  32785. * An event triggered after calculating deterministic simulation step
  32786. */
  32787. onAfterStepObservable: Observable<Scene>;
  32788. /**
  32789. * An event triggered when the activeCamera property is updated
  32790. */
  32791. onActiveCameraChanged: Observable<Scene>;
  32792. /**
  32793. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32794. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32795. * 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)
  32796. */
  32797. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32798. /**
  32799. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32800. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32801. * 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)
  32802. */
  32803. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32804. /**
  32805. * This Observable will when a mesh has been imported into the scene.
  32806. */
  32807. onMeshImportedObservable: Observable<AbstractMesh>;
  32808. /**
  32809. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32810. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32811. */
  32812. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32813. /** @hidden */
  32814. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32815. /**
  32816. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32817. */
  32818. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32819. /**
  32820. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32821. */
  32822. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32823. /**
  32824. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32825. */
  32826. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32827. private _onPointerMove;
  32828. private _onPointerDown;
  32829. private _onPointerUp;
  32830. /** Callback called when a pointer move is detected */
  32831. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32832. /** Callback called when a pointer down is detected */
  32833. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32834. /** Callback called when a pointer up is detected */
  32835. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32836. /** Callback called when a pointer pick is detected */
  32837. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32838. /**
  32839. * 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).
  32840. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32841. */
  32842. onPrePointerObservable: Observable<PointerInfoPre>;
  32843. /**
  32844. * Observable event triggered each time an input event is received from the rendering canvas
  32845. */
  32846. onPointerObservable: Observable<PointerInfo>;
  32847. /**
  32848. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32849. */
  32850. readonly unTranslatedPointer: Vector2;
  32851. /** The distance in pixel that you have to move to prevent some events */
  32852. static DragMovementThreshold: number;
  32853. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32854. static LongPressDelay: number;
  32855. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32856. static DoubleClickDelay: number;
  32857. /** If you need to check double click without raising a single click at first click, enable this flag */
  32858. static ExclusiveDoubleClickMode: boolean;
  32859. private _initClickEvent;
  32860. private _initActionManager;
  32861. private _delayedSimpleClick;
  32862. private _delayedSimpleClickTimeout;
  32863. private _previousDelayedSimpleClickTimeout;
  32864. private _meshPickProceed;
  32865. private _previousButtonPressed;
  32866. private _currentPickResult;
  32867. private _previousPickResult;
  32868. private _totalPointersPressed;
  32869. private _doubleClickOccured;
  32870. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32871. cameraToUseForPointers: Nullable<Camera>;
  32872. private _pointerX;
  32873. private _pointerY;
  32874. private _unTranslatedPointerX;
  32875. private _unTranslatedPointerY;
  32876. private _startingPointerPosition;
  32877. private _previousStartingPointerPosition;
  32878. private _startingPointerTime;
  32879. private _previousStartingPointerTime;
  32880. private _pointerCaptures;
  32881. private _timeAccumulator;
  32882. private _currentStepId;
  32883. private _currentInternalStep;
  32884. /** @hidden */
  32885. _mirroredCameraPosition: Nullable<Vector3>;
  32886. /**
  32887. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32888. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32889. */
  32890. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32891. /**
  32892. * Observable event triggered each time an keyboard event is received from the hosting window
  32893. */
  32894. onKeyboardObservable: Observable<KeyboardInfo>;
  32895. private _onKeyDown;
  32896. private _onKeyUp;
  32897. private _onCanvasFocusObserver;
  32898. private _onCanvasBlurObserver;
  32899. private _useRightHandedSystem;
  32900. /**
  32901. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32902. */
  32903. useRightHandedSystem: boolean;
  32904. /**
  32905. * Sets the step Id used by deterministic lock step
  32906. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32907. * @param newStepId defines the step Id
  32908. */
  32909. setStepId(newStepId: number): void;
  32910. /**
  32911. * Gets the step Id used by deterministic lock step
  32912. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32913. * @returns the step Id
  32914. */
  32915. getStepId(): number;
  32916. /**
  32917. * Gets the internal step used by deterministic lock step
  32918. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32919. * @returns the internal step
  32920. */
  32921. getInternalStep(): number;
  32922. private _fogEnabled;
  32923. /**
  32924. * Gets or sets a boolean indicating if fog is enabled on this scene
  32925. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32926. * (Default is true)
  32927. */
  32928. fogEnabled: boolean;
  32929. private _fogMode;
  32930. /**
  32931. * Gets or sets the fog mode to use
  32932. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32933. * | mode | value |
  32934. * | --- | --- |
  32935. * | FOGMODE_NONE | 0 |
  32936. * | FOGMODE_EXP | 1 |
  32937. * | FOGMODE_EXP2 | 2 |
  32938. * | FOGMODE_LINEAR | 3 |
  32939. */
  32940. fogMode: number;
  32941. /**
  32942. * Gets or sets the fog color to use
  32943. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32944. * (Default is Color3(0.2, 0.2, 0.3))
  32945. */
  32946. fogColor: Color3;
  32947. /**
  32948. * Gets or sets the fog density to use
  32949. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32950. * (Default is 0.1)
  32951. */
  32952. fogDensity: number;
  32953. /**
  32954. * Gets or sets the fog start distance to use
  32955. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32956. * (Default is 0)
  32957. */
  32958. fogStart: number;
  32959. /**
  32960. * Gets or sets the fog end distance to use
  32961. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32962. * (Default is 1000)
  32963. */
  32964. fogEnd: number;
  32965. private _shadowsEnabled;
  32966. /**
  32967. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32968. */
  32969. shadowsEnabled: boolean;
  32970. private _lightsEnabled;
  32971. /**
  32972. * Gets or sets a boolean indicating if lights are enabled on this scene
  32973. */
  32974. lightsEnabled: boolean;
  32975. /** All of the active cameras added to this scene. */
  32976. activeCameras: Camera[];
  32977. private _activeCamera;
  32978. /** Gets or sets the current active camera */
  32979. activeCamera: Nullable<Camera>;
  32980. private _defaultMaterial;
  32981. /** The default material used on meshes when no material is affected */
  32982. /** The default material used on meshes when no material is affected */
  32983. defaultMaterial: Material;
  32984. private _texturesEnabled;
  32985. /**
  32986. * Gets or sets a boolean indicating if textures are enabled on this scene
  32987. */
  32988. texturesEnabled: boolean;
  32989. /**
  32990. * Gets or sets a boolean indicating if particles are enabled on this scene
  32991. */
  32992. particlesEnabled: boolean;
  32993. /**
  32994. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32995. */
  32996. spritesEnabled: boolean;
  32997. private _skeletonsEnabled;
  32998. /**
  32999. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33000. */
  33001. skeletonsEnabled: boolean;
  33002. /**
  33003. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33004. */
  33005. lensFlaresEnabled: boolean;
  33006. /**
  33007. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33008. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33009. */
  33010. collisionsEnabled: boolean;
  33011. private _collisionCoordinator;
  33012. /** @hidden */
  33013. readonly collisionCoordinator: ICollisionCoordinator;
  33014. /**
  33015. * Defines the gravity applied to this scene (used only for collisions)
  33016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33017. */
  33018. gravity: Vector3;
  33019. /**
  33020. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33021. */
  33022. postProcessesEnabled: boolean;
  33023. /**
  33024. * The list of postprocesses added to the scene
  33025. */
  33026. postProcesses: PostProcess[];
  33027. /**
  33028. * Gets the current postprocess manager
  33029. */
  33030. postProcessManager: PostProcessManager;
  33031. /**
  33032. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33033. */
  33034. renderTargetsEnabled: boolean;
  33035. /**
  33036. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33037. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33038. */
  33039. dumpNextRenderTargets: boolean;
  33040. /**
  33041. * The list of user defined render targets added to the scene
  33042. */
  33043. customRenderTargets: RenderTargetTexture[];
  33044. /**
  33045. * Defines if texture loading must be delayed
  33046. * If true, textures will only be loaded when they need to be rendered
  33047. */
  33048. useDelayedTextureLoading: boolean;
  33049. /**
  33050. * Gets the list of meshes imported to the scene through SceneLoader
  33051. */
  33052. importedMeshesFiles: String[];
  33053. /**
  33054. * Gets or sets a boolean indicating if probes are enabled on this scene
  33055. */
  33056. probesEnabled: boolean;
  33057. /**
  33058. * Gets or sets the current offline provider to use to store scene data
  33059. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33060. */
  33061. offlineProvider: IOfflineProvider;
  33062. /**
  33063. * Gets or sets the action manager associated with the scene
  33064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33065. */
  33066. actionManager: AbstractActionManager;
  33067. private _meshesForIntersections;
  33068. /**
  33069. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33070. */
  33071. proceduralTexturesEnabled: boolean;
  33072. private _engine;
  33073. private _totalVertices;
  33074. /** @hidden */
  33075. _activeIndices: PerfCounter;
  33076. /** @hidden */
  33077. _activeParticles: PerfCounter;
  33078. /** @hidden */
  33079. _activeBones: PerfCounter;
  33080. private _animationRatio;
  33081. /** @hidden */
  33082. _animationTimeLast: number;
  33083. /** @hidden */
  33084. _animationTime: number;
  33085. /**
  33086. * Gets or sets a general scale for animation speed
  33087. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33088. */
  33089. animationTimeScale: number;
  33090. /** @hidden */
  33091. _cachedMaterial: Nullable<Material>;
  33092. /** @hidden */
  33093. _cachedEffect: Nullable<Effect>;
  33094. /** @hidden */
  33095. _cachedVisibility: Nullable<number>;
  33096. private _renderId;
  33097. private _frameId;
  33098. private _executeWhenReadyTimeoutId;
  33099. private _intermediateRendering;
  33100. private _viewUpdateFlag;
  33101. private _projectionUpdateFlag;
  33102. /** @hidden */
  33103. _toBeDisposed: Nullable<IDisposable>[];
  33104. private _activeRequests;
  33105. /** @hidden */
  33106. _pendingData: any[];
  33107. private _isDisposed;
  33108. /**
  33109. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33110. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33111. */
  33112. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33113. private _activeMeshes;
  33114. private _processedMaterials;
  33115. private _renderTargets;
  33116. /** @hidden */
  33117. _activeParticleSystems: SmartArray<IParticleSystem>;
  33118. private _activeSkeletons;
  33119. private _softwareSkinnedMeshes;
  33120. private _renderingManager;
  33121. /** @hidden */
  33122. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33123. private _transformMatrix;
  33124. private _transformMatrixR;
  33125. private _sceneUbo;
  33126. private _multiviewSceneUbo;
  33127. private _viewMatrix;
  33128. private _projectionMatrix;
  33129. private _wheelEventName;
  33130. /** @hidden */
  33131. _forcedViewPosition: Nullable<Vector3>;
  33132. private _frustumPlanes;
  33133. /**
  33134. * Gets the list of frustum planes (built from the active camera)
  33135. */
  33136. readonly frustumPlanes: Plane[];
  33137. /**
  33138. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33139. * This is useful if there are more lights that the maximum simulteanous authorized
  33140. */
  33141. requireLightSorting: boolean;
  33142. /** @hidden */
  33143. readonly useMaterialMeshMap: boolean;
  33144. /** @hidden */
  33145. readonly useClonedMeshhMap: boolean;
  33146. private _pointerOverMesh;
  33147. private _pickedDownMesh;
  33148. private _pickedUpMesh;
  33149. private _externalData;
  33150. private _uid;
  33151. /**
  33152. * @hidden
  33153. * Backing store of defined scene components.
  33154. */
  33155. _components: ISceneComponent[];
  33156. /**
  33157. * @hidden
  33158. * Backing store of defined scene components.
  33159. */
  33160. _serializableComponents: ISceneSerializableComponent[];
  33161. /**
  33162. * List of components to register on the next registration step.
  33163. */
  33164. private _transientComponents;
  33165. /**
  33166. * Registers the transient components if needed.
  33167. */
  33168. private _registerTransientComponents;
  33169. /**
  33170. * @hidden
  33171. * Add a component to the scene.
  33172. * Note that the ccomponent could be registered on th next frame if this is called after
  33173. * the register component stage.
  33174. * @param component Defines the component to add to the scene
  33175. */
  33176. _addComponent(component: ISceneComponent): void;
  33177. /**
  33178. * @hidden
  33179. * Gets a component from the scene.
  33180. * @param name defines the name of the component to retrieve
  33181. * @returns the component or null if not present
  33182. */
  33183. _getComponent(name: string): Nullable<ISceneComponent>;
  33184. /**
  33185. * @hidden
  33186. * Defines the actions happening before camera updates.
  33187. */
  33188. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33189. /**
  33190. * @hidden
  33191. * Defines the actions happening before clear the canvas.
  33192. */
  33193. _beforeClearStage: Stage<SimpleStageAction>;
  33194. /**
  33195. * @hidden
  33196. * Defines the actions when collecting render targets for the frame.
  33197. */
  33198. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33199. /**
  33200. * @hidden
  33201. * Defines the actions happening for one camera in the frame.
  33202. */
  33203. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33204. /**
  33205. * @hidden
  33206. * Defines the actions happening during the per mesh ready checks.
  33207. */
  33208. _isReadyForMeshStage: Stage<MeshStageAction>;
  33209. /**
  33210. * @hidden
  33211. * Defines the actions happening before evaluate active mesh checks.
  33212. */
  33213. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33214. /**
  33215. * @hidden
  33216. * Defines the actions happening during the evaluate sub mesh checks.
  33217. */
  33218. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33219. /**
  33220. * @hidden
  33221. * Defines the actions happening during the active mesh stage.
  33222. */
  33223. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33224. /**
  33225. * @hidden
  33226. * Defines the actions happening during the per camera render target step.
  33227. */
  33228. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33229. /**
  33230. * @hidden
  33231. * Defines the actions happening just before the active camera is drawing.
  33232. */
  33233. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33234. /**
  33235. * @hidden
  33236. * Defines the actions happening just before a render target is drawing.
  33237. */
  33238. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33239. /**
  33240. * @hidden
  33241. * Defines the actions happening just before a rendering group is drawing.
  33242. */
  33243. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33244. /**
  33245. * @hidden
  33246. * Defines the actions happening just before a mesh is drawing.
  33247. */
  33248. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33249. /**
  33250. * @hidden
  33251. * Defines the actions happening just after a mesh has been drawn.
  33252. */
  33253. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33254. /**
  33255. * @hidden
  33256. * Defines the actions happening just after a rendering group has been drawn.
  33257. */
  33258. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33259. /**
  33260. * @hidden
  33261. * Defines the actions happening just after the active camera has been drawn.
  33262. */
  33263. _afterCameraDrawStage: Stage<CameraStageAction>;
  33264. /**
  33265. * @hidden
  33266. * Defines the actions happening just after a render target has been drawn.
  33267. */
  33268. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33269. /**
  33270. * @hidden
  33271. * Defines the actions happening just after rendering all cameras and computing intersections.
  33272. */
  33273. _afterRenderStage: Stage<SimpleStageAction>;
  33274. /**
  33275. * @hidden
  33276. * Defines the actions happening when a pointer move event happens.
  33277. */
  33278. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33279. /**
  33280. * @hidden
  33281. * Defines the actions happening when a pointer down event happens.
  33282. */
  33283. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33284. /**
  33285. * @hidden
  33286. * Defines the actions happening when a pointer up event happens.
  33287. */
  33288. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33289. /**
  33290. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33291. */
  33292. private geometriesByUniqueId;
  33293. /**
  33294. * Creates a new Scene
  33295. * @param engine defines the engine to use to render this scene
  33296. * @param options defines the scene options
  33297. */
  33298. constructor(engine: Engine, options?: SceneOptions);
  33299. private _defaultMeshCandidates;
  33300. /**
  33301. * @hidden
  33302. */
  33303. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33304. private _defaultSubMeshCandidates;
  33305. /**
  33306. * @hidden
  33307. */
  33308. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33309. /**
  33310. * Sets the default candidate providers for the scene.
  33311. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33312. * and getCollidingSubMeshCandidates to their default function
  33313. */
  33314. setDefaultCandidateProviders(): void;
  33315. /**
  33316. * Gets the mesh that is currently under the pointer
  33317. */
  33318. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33319. /**
  33320. * Gets or sets the current on-screen X position of the pointer
  33321. */
  33322. pointerX: number;
  33323. /**
  33324. * Gets or sets the current on-screen Y position of the pointer
  33325. */
  33326. pointerY: number;
  33327. /**
  33328. * Gets the cached material (ie. the latest rendered one)
  33329. * @returns the cached material
  33330. */
  33331. getCachedMaterial(): Nullable<Material>;
  33332. /**
  33333. * Gets the cached effect (ie. the latest rendered one)
  33334. * @returns the cached effect
  33335. */
  33336. getCachedEffect(): Nullable<Effect>;
  33337. /**
  33338. * Gets the cached visibility state (ie. the latest rendered one)
  33339. * @returns the cached visibility state
  33340. */
  33341. getCachedVisibility(): Nullable<number>;
  33342. /**
  33343. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33344. * @param material defines the current material
  33345. * @param effect defines the current effect
  33346. * @param visibility defines the current visibility state
  33347. * @returns true if one parameter is not cached
  33348. */
  33349. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33350. /**
  33351. * Gets the engine associated with the scene
  33352. * @returns an Engine
  33353. */
  33354. getEngine(): Engine;
  33355. /**
  33356. * Gets the total number of vertices rendered per frame
  33357. * @returns the total number of vertices rendered per frame
  33358. */
  33359. getTotalVertices(): number;
  33360. /**
  33361. * Gets the performance counter for total vertices
  33362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33363. */
  33364. readonly totalVerticesPerfCounter: PerfCounter;
  33365. /**
  33366. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33367. * @returns the total number of active indices rendered per frame
  33368. */
  33369. getActiveIndices(): number;
  33370. /**
  33371. * Gets the performance counter for active indices
  33372. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33373. */
  33374. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33375. /**
  33376. * Gets the total number of active particles rendered per frame
  33377. * @returns the total number of active particles rendered per frame
  33378. */
  33379. getActiveParticles(): number;
  33380. /**
  33381. * Gets the performance counter for active particles
  33382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33383. */
  33384. readonly activeParticlesPerfCounter: PerfCounter;
  33385. /**
  33386. * Gets the total number of active bones rendered per frame
  33387. * @returns the total number of active bones rendered per frame
  33388. */
  33389. getActiveBones(): number;
  33390. /**
  33391. * Gets the performance counter for active bones
  33392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33393. */
  33394. readonly activeBonesPerfCounter: PerfCounter;
  33395. /**
  33396. * Gets the array of active meshes
  33397. * @returns an array of AbstractMesh
  33398. */
  33399. getActiveMeshes(): SmartArray<AbstractMesh>;
  33400. /**
  33401. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33402. * @returns a number
  33403. */
  33404. getAnimationRatio(): number;
  33405. /**
  33406. * Gets an unique Id for the current render phase
  33407. * @returns a number
  33408. */
  33409. getRenderId(): number;
  33410. /**
  33411. * Gets an unique Id for the current frame
  33412. * @returns a number
  33413. */
  33414. getFrameId(): number;
  33415. /** Call this function if you want to manually increment the render Id*/
  33416. incrementRenderId(): void;
  33417. private _updatePointerPosition;
  33418. private _createUbo;
  33419. private _createMultiviewUbo;
  33420. private _setRayOnPointerInfo;
  33421. /**
  33422. * Use this method to simulate a pointer move on a mesh
  33423. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33424. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33425. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33426. * @returns the current scene
  33427. */
  33428. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33429. private _processPointerMove;
  33430. private _checkPrePointerObservable;
  33431. /**
  33432. * Use this method to simulate a pointer down on a mesh
  33433. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33434. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33435. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33436. * @returns the current scene
  33437. */
  33438. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33439. private _processPointerDown;
  33440. /**
  33441. * Use this method to simulate a pointer up on a mesh
  33442. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33443. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33444. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33445. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33446. * @returns the current scene
  33447. */
  33448. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33449. private _processPointerUp;
  33450. /**
  33451. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33452. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33453. * @returns true if the pointer was captured
  33454. */
  33455. isPointerCaptured(pointerId?: number): boolean;
  33456. /** @hidden */
  33457. _isPointerSwiping(): boolean;
  33458. /**
  33459. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33460. * @param attachUp defines if you want to attach events to pointerup
  33461. * @param attachDown defines if you want to attach events to pointerdown
  33462. * @param attachMove defines if you want to attach events to pointermove
  33463. */
  33464. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33465. /** Detaches all event handlers*/
  33466. detachControl(): void;
  33467. /**
  33468. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33469. * Delay loaded resources are not taking in account
  33470. * @return true if all required resources are ready
  33471. */
  33472. isReady(): boolean;
  33473. /** Resets all cached information relative to material (including effect and visibility) */
  33474. resetCachedMaterial(): void;
  33475. /**
  33476. * Registers a function to be called before every frame render
  33477. * @param func defines the function to register
  33478. */
  33479. registerBeforeRender(func: () => void): void;
  33480. /**
  33481. * Unregisters a function called before every frame render
  33482. * @param func defines the function to unregister
  33483. */
  33484. unregisterBeforeRender(func: () => void): void;
  33485. /**
  33486. * Registers a function to be called after every frame render
  33487. * @param func defines the function to register
  33488. */
  33489. registerAfterRender(func: () => void): void;
  33490. /**
  33491. * Unregisters a function called after every frame render
  33492. * @param func defines the function to unregister
  33493. */
  33494. unregisterAfterRender(func: () => void): void;
  33495. private _executeOnceBeforeRender;
  33496. /**
  33497. * The provided function will run before render once and will be disposed afterwards.
  33498. * A timeout delay can be provided so that the function will be executed in N ms.
  33499. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33500. * @param func The function to be executed.
  33501. * @param timeout optional delay in ms
  33502. */
  33503. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33504. /** @hidden */
  33505. _addPendingData(data: any): void;
  33506. /** @hidden */
  33507. _removePendingData(data: any): void;
  33508. /**
  33509. * Returns the number of items waiting to be loaded
  33510. * @returns the number of items waiting to be loaded
  33511. */
  33512. getWaitingItemsCount(): number;
  33513. /**
  33514. * Returns a boolean indicating if the scene is still loading data
  33515. */
  33516. readonly isLoading: boolean;
  33517. /**
  33518. * Registers a function to be executed when the scene is ready
  33519. * @param {Function} func - the function to be executed
  33520. */
  33521. executeWhenReady(func: () => void): void;
  33522. /**
  33523. * Returns a promise that resolves when the scene is ready
  33524. * @returns A promise that resolves when the scene is ready
  33525. */
  33526. whenReadyAsync(): Promise<void>;
  33527. /** @hidden */
  33528. _checkIsReady(): void;
  33529. /**
  33530. * Gets all animatable attached to the scene
  33531. */
  33532. readonly animatables: Animatable[];
  33533. /**
  33534. * Resets the last animation time frame.
  33535. * Useful to override when animations start running when loading a scene for the first time.
  33536. */
  33537. resetLastAnimationTimeFrame(): void;
  33538. /**
  33539. * Gets the current view matrix
  33540. * @returns a Matrix
  33541. */
  33542. getViewMatrix(): Matrix;
  33543. /**
  33544. * Gets the current projection matrix
  33545. * @returns a Matrix
  33546. */
  33547. getProjectionMatrix(): Matrix;
  33548. /**
  33549. * Gets the current transform matrix
  33550. * @returns a Matrix made of View * Projection
  33551. */
  33552. getTransformMatrix(): Matrix;
  33553. /**
  33554. * Sets the current transform matrix
  33555. * @param viewL defines the View matrix to use
  33556. * @param projectionL defines the Projection matrix to use
  33557. * @param viewR defines the right View matrix to use (if provided)
  33558. * @param projectionR defines the right Projection matrix to use (if provided)
  33559. */
  33560. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33561. /**
  33562. * Gets the uniform buffer used to store scene data
  33563. * @returns a UniformBuffer
  33564. */
  33565. getSceneUniformBuffer(): UniformBuffer;
  33566. /**
  33567. * Gets an unique (relatively to the current scene) Id
  33568. * @returns an unique number for the scene
  33569. */
  33570. getUniqueId(): number;
  33571. /**
  33572. * Add a mesh to the list of scene's meshes
  33573. * @param newMesh defines the mesh to add
  33574. * @param recursive if all child meshes should also be added to the scene
  33575. */
  33576. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33577. /**
  33578. * Remove a mesh for the list of scene's meshes
  33579. * @param toRemove defines the mesh to remove
  33580. * @param recursive if all child meshes should also be removed from the scene
  33581. * @returns the index where the mesh was in the mesh list
  33582. */
  33583. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33584. /**
  33585. * Add a transform node to the list of scene's transform nodes
  33586. * @param newTransformNode defines the transform node to add
  33587. */
  33588. addTransformNode(newTransformNode: TransformNode): void;
  33589. /**
  33590. * Remove a transform node for the list of scene's transform nodes
  33591. * @param toRemove defines the transform node to remove
  33592. * @returns the index where the transform node was in the transform node list
  33593. */
  33594. removeTransformNode(toRemove: TransformNode): number;
  33595. /**
  33596. * Remove a skeleton for the list of scene's skeletons
  33597. * @param toRemove defines the skeleton to remove
  33598. * @returns the index where the skeleton was in the skeleton list
  33599. */
  33600. removeSkeleton(toRemove: Skeleton): number;
  33601. /**
  33602. * Remove a morph target for the list of scene's morph targets
  33603. * @param toRemove defines the morph target to remove
  33604. * @returns the index where the morph target was in the morph target list
  33605. */
  33606. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33607. /**
  33608. * Remove a light for the list of scene's lights
  33609. * @param toRemove defines the light to remove
  33610. * @returns the index where the light was in the light list
  33611. */
  33612. removeLight(toRemove: Light): number;
  33613. /**
  33614. * Remove a camera for the list of scene's cameras
  33615. * @param toRemove defines the camera to remove
  33616. * @returns the index where the camera was in the camera list
  33617. */
  33618. removeCamera(toRemove: Camera): number;
  33619. /**
  33620. * Remove a particle system for the list of scene's particle systems
  33621. * @param toRemove defines the particle system to remove
  33622. * @returns the index where the particle system was in the particle system list
  33623. */
  33624. removeParticleSystem(toRemove: IParticleSystem): number;
  33625. /**
  33626. * Remove a animation for the list of scene's animations
  33627. * @param toRemove defines the animation to remove
  33628. * @returns the index where the animation was in the animation list
  33629. */
  33630. removeAnimation(toRemove: Animation): number;
  33631. /**
  33632. * Removes the given animation group from this scene.
  33633. * @param toRemove The animation group to remove
  33634. * @returns The index of the removed animation group
  33635. */
  33636. removeAnimationGroup(toRemove: AnimationGroup): number;
  33637. /**
  33638. * Removes the given multi-material from this scene.
  33639. * @param toRemove The multi-material to remove
  33640. * @returns The index of the removed multi-material
  33641. */
  33642. removeMultiMaterial(toRemove: MultiMaterial): number;
  33643. /**
  33644. * Removes the given material from this scene.
  33645. * @param toRemove The material to remove
  33646. * @returns The index of the removed material
  33647. */
  33648. removeMaterial(toRemove: Material): number;
  33649. /**
  33650. * Removes the given action manager from this scene.
  33651. * @param toRemove The action manager to remove
  33652. * @returns The index of the removed action manager
  33653. */
  33654. removeActionManager(toRemove: AbstractActionManager): number;
  33655. /**
  33656. * Removes the given texture from this scene.
  33657. * @param toRemove The texture to remove
  33658. * @returns The index of the removed texture
  33659. */
  33660. removeTexture(toRemove: BaseTexture): number;
  33661. /**
  33662. * Adds the given light to this scene
  33663. * @param newLight The light to add
  33664. */
  33665. addLight(newLight: Light): void;
  33666. /**
  33667. * Sorts the list list based on light priorities
  33668. */
  33669. sortLightsByPriority(): void;
  33670. /**
  33671. * Adds the given camera to this scene
  33672. * @param newCamera The camera to add
  33673. */
  33674. addCamera(newCamera: Camera): void;
  33675. /**
  33676. * Adds the given skeleton to this scene
  33677. * @param newSkeleton The skeleton to add
  33678. */
  33679. addSkeleton(newSkeleton: Skeleton): void;
  33680. /**
  33681. * Adds the given particle system to this scene
  33682. * @param newParticleSystem The particle system to add
  33683. */
  33684. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33685. /**
  33686. * Adds the given animation to this scene
  33687. * @param newAnimation The animation to add
  33688. */
  33689. addAnimation(newAnimation: Animation): void;
  33690. /**
  33691. * Adds the given animation group to this scene.
  33692. * @param newAnimationGroup The animation group to add
  33693. */
  33694. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33695. /**
  33696. * Adds the given multi-material to this scene
  33697. * @param newMultiMaterial The multi-material to add
  33698. */
  33699. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33700. /**
  33701. * Adds the given material to this scene
  33702. * @param newMaterial The material to add
  33703. */
  33704. addMaterial(newMaterial: Material): void;
  33705. /**
  33706. * Adds the given morph target to this scene
  33707. * @param newMorphTargetManager The morph target to add
  33708. */
  33709. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33710. /**
  33711. * Adds the given geometry to this scene
  33712. * @param newGeometry The geometry to add
  33713. */
  33714. addGeometry(newGeometry: Geometry): void;
  33715. /**
  33716. * Adds the given action manager to this scene
  33717. * @param newActionManager The action manager to add
  33718. */
  33719. addActionManager(newActionManager: AbstractActionManager): void;
  33720. /**
  33721. * Adds the given texture to this scene.
  33722. * @param newTexture The texture to add
  33723. */
  33724. addTexture(newTexture: BaseTexture): void;
  33725. /**
  33726. * Switch active camera
  33727. * @param newCamera defines the new active camera
  33728. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33729. */
  33730. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33731. /**
  33732. * sets the active camera of the scene using its ID
  33733. * @param id defines the camera's ID
  33734. * @return the new active camera or null if none found.
  33735. */
  33736. setActiveCameraByID(id: string): Nullable<Camera>;
  33737. /**
  33738. * sets the active camera of the scene using its name
  33739. * @param name defines the camera's name
  33740. * @returns the new active camera or null if none found.
  33741. */
  33742. setActiveCameraByName(name: string): Nullable<Camera>;
  33743. /**
  33744. * get an animation group using its name
  33745. * @param name defines the material's name
  33746. * @return the animation group or null if none found.
  33747. */
  33748. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33749. /**
  33750. * Get a material using its unique id
  33751. * @param uniqueId defines the material's unique id
  33752. * @return the material or null if none found.
  33753. */
  33754. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33755. /**
  33756. * get a material using its id
  33757. * @param id defines the material's ID
  33758. * @return the material or null if none found.
  33759. */
  33760. getMaterialByID(id: string): Nullable<Material>;
  33761. /**
  33762. * Gets a material using its name
  33763. * @param name defines the material's name
  33764. * @return the material or null if none found.
  33765. */
  33766. getMaterialByName(name: string): Nullable<Material>;
  33767. /**
  33768. * Gets a camera using its id
  33769. * @param id defines the id to look for
  33770. * @returns the camera or null if not found
  33771. */
  33772. getCameraByID(id: string): Nullable<Camera>;
  33773. /**
  33774. * Gets a camera using its unique id
  33775. * @param uniqueId defines the unique id to look for
  33776. * @returns the camera or null if not found
  33777. */
  33778. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33779. /**
  33780. * Gets a camera using its name
  33781. * @param name defines the camera's name
  33782. * @return the camera or null if none found.
  33783. */
  33784. getCameraByName(name: string): Nullable<Camera>;
  33785. /**
  33786. * Gets a bone using its id
  33787. * @param id defines the bone's id
  33788. * @return the bone or null if not found
  33789. */
  33790. getBoneByID(id: string): Nullable<Bone>;
  33791. /**
  33792. * Gets a bone using its id
  33793. * @param name defines the bone's name
  33794. * @return the bone or null if not found
  33795. */
  33796. getBoneByName(name: string): Nullable<Bone>;
  33797. /**
  33798. * Gets a light node using its name
  33799. * @param name defines the the light's name
  33800. * @return the light or null if none found.
  33801. */
  33802. getLightByName(name: string): Nullable<Light>;
  33803. /**
  33804. * Gets a light node using its id
  33805. * @param id defines the light's id
  33806. * @return the light or null if none found.
  33807. */
  33808. getLightByID(id: string): Nullable<Light>;
  33809. /**
  33810. * Gets a light node using its scene-generated unique ID
  33811. * @param uniqueId defines the light's unique id
  33812. * @return the light or null if none found.
  33813. */
  33814. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33815. /**
  33816. * Gets a particle system by id
  33817. * @param id defines the particle system id
  33818. * @return the corresponding system or null if none found
  33819. */
  33820. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33821. /**
  33822. * Gets a geometry using its ID
  33823. * @param id defines the geometry's id
  33824. * @return the geometry or null if none found.
  33825. */
  33826. getGeometryByID(id: string): Nullable<Geometry>;
  33827. private _getGeometryByUniqueID;
  33828. /**
  33829. * Add a new geometry to this scene
  33830. * @param geometry defines the geometry to be added to the scene.
  33831. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33832. * @return a boolean defining if the geometry was added or not
  33833. */
  33834. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33835. /**
  33836. * Removes an existing geometry
  33837. * @param geometry defines the geometry to be removed from the scene
  33838. * @return a boolean defining if the geometry was removed or not
  33839. */
  33840. removeGeometry(geometry: Geometry): boolean;
  33841. /**
  33842. * Gets the list of geometries attached to the scene
  33843. * @returns an array of Geometry
  33844. */
  33845. getGeometries(): Geometry[];
  33846. /**
  33847. * Gets the first added mesh found of a given ID
  33848. * @param id defines the id to search for
  33849. * @return the mesh found or null if not found at all
  33850. */
  33851. getMeshByID(id: string): Nullable<AbstractMesh>;
  33852. /**
  33853. * Gets a list of meshes using their id
  33854. * @param id defines the id to search for
  33855. * @returns a list of meshes
  33856. */
  33857. getMeshesByID(id: string): Array<AbstractMesh>;
  33858. /**
  33859. * Gets the first added transform node found of a given ID
  33860. * @param id defines the id to search for
  33861. * @return the found transform node or null if not found at all.
  33862. */
  33863. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33864. /**
  33865. * Gets a transform node with its auto-generated unique id
  33866. * @param uniqueId efines the unique id to search for
  33867. * @return the found transform node or null if not found at all.
  33868. */
  33869. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33870. /**
  33871. * Gets a list of transform nodes using their id
  33872. * @param id defines the id to search for
  33873. * @returns a list of transform nodes
  33874. */
  33875. getTransformNodesByID(id: string): Array<TransformNode>;
  33876. /**
  33877. * Gets a mesh with its auto-generated unique id
  33878. * @param uniqueId defines the unique id to search for
  33879. * @return the found mesh or null if not found at all.
  33880. */
  33881. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33882. /**
  33883. * Gets a the last added mesh using a given id
  33884. * @param id defines the id to search for
  33885. * @return the found mesh or null if not found at all.
  33886. */
  33887. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33888. /**
  33889. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33890. * @param id defines the id to search for
  33891. * @return the found node or null if not found at all
  33892. */
  33893. getLastEntryByID(id: string): Nullable<Node>;
  33894. /**
  33895. * Gets a node (Mesh, Camera, Light) using a given id
  33896. * @param id defines the id to search for
  33897. * @return the found node or null if not found at all
  33898. */
  33899. getNodeByID(id: string): Nullable<Node>;
  33900. /**
  33901. * Gets a node (Mesh, Camera, Light) using a given name
  33902. * @param name defines the name to search for
  33903. * @return the found node or null if not found at all.
  33904. */
  33905. getNodeByName(name: string): Nullable<Node>;
  33906. /**
  33907. * Gets a mesh using a given name
  33908. * @param name defines the name to search for
  33909. * @return the found mesh or null if not found at all.
  33910. */
  33911. getMeshByName(name: string): Nullable<AbstractMesh>;
  33912. /**
  33913. * Gets a transform node using a given name
  33914. * @param name defines the name to search for
  33915. * @return the found transform node or null if not found at all.
  33916. */
  33917. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33918. /**
  33919. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33920. * @param id defines the id to search for
  33921. * @return the found skeleton or null if not found at all.
  33922. */
  33923. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33924. /**
  33925. * Gets a skeleton using a given auto generated unique id
  33926. * @param uniqueId defines the unique id to search for
  33927. * @return the found skeleton or null if not found at all.
  33928. */
  33929. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33930. /**
  33931. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33932. * @param id defines the id to search for
  33933. * @return the found skeleton or null if not found at all.
  33934. */
  33935. getSkeletonById(id: string): Nullable<Skeleton>;
  33936. /**
  33937. * Gets a skeleton using a given name
  33938. * @param name defines the name to search for
  33939. * @return the found skeleton or null if not found at all.
  33940. */
  33941. getSkeletonByName(name: string): Nullable<Skeleton>;
  33942. /**
  33943. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33944. * @param id defines the id to search for
  33945. * @return the found morph target manager or null if not found at all.
  33946. */
  33947. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33948. /**
  33949. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33950. * @param id defines the id to search for
  33951. * @return the found morph target or null if not found at all.
  33952. */
  33953. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33954. /**
  33955. * Gets a boolean indicating if the given mesh is active
  33956. * @param mesh defines the mesh to look for
  33957. * @returns true if the mesh is in the active list
  33958. */
  33959. isActiveMesh(mesh: AbstractMesh): boolean;
  33960. /**
  33961. * Return a unique id as a string which can serve as an identifier for the scene
  33962. */
  33963. readonly uid: string;
  33964. /**
  33965. * Add an externaly attached data from its key.
  33966. * This method call will fail and return false, if such key already exists.
  33967. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33968. * @param key the unique key that identifies the data
  33969. * @param data the data object to associate to the key for this Engine instance
  33970. * @return true if no such key were already present and the data was added successfully, false otherwise
  33971. */
  33972. addExternalData<T>(key: string, data: T): boolean;
  33973. /**
  33974. * Get an externaly attached data from its key
  33975. * @param key the unique key that identifies the data
  33976. * @return the associated data, if present (can be null), or undefined if not present
  33977. */
  33978. getExternalData<T>(key: string): Nullable<T>;
  33979. /**
  33980. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33981. * @param key the unique key that identifies the data
  33982. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33983. * @return the associated data, can be null if the factory returned null.
  33984. */
  33985. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33986. /**
  33987. * Remove an externaly attached data from the Engine instance
  33988. * @param key the unique key that identifies the data
  33989. * @return true if the data was successfully removed, false if it doesn't exist
  33990. */
  33991. removeExternalData(key: string): boolean;
  33992. private _evaluateSubMesh;
  33993. /**
  33994. * Clear the processed materials smart array preventing retention point in material dispose.
  33995. */
  33996. freeProcessedMaterials(): void;
  33997. private _preventFreeActiveMeshesAndRenderingGroups;
  33998. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33999. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34000. * when disposing several meshes in a row or a hierarchy of meshes.
  34001. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34002. */
  34003. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34004. /**
  34005. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34006. */
  34007. freeActiveMeshes(): void;
  34008. /**
  34009. * Clear the info related to rendering groups preventing retention points during dispose.
  34010. */
  34011. freeRenderingGroups(): void;
  34012. /** @hidden */
  34013. _isInIntermediateRendering(): boolean;
  34014. /**
  34015. * Lambda returning the list of potentially active meshes.
  34016. */
  34017. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34018. /**
  34019. * Lambda returning the list of potentially active sub meshes.
  34020. */
  34021. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34022. /**
  34023. * Lambda returning the list of potentially intersecting sub meshes.
  34024. */
  34025. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34026. /**
  34027. * Lambda returning the list of potentially colliding sub meshes.
  34028. */
  34029. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34030. private _activeMeshesFrozen;
  34031. /**
  34032. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34033. * @returns the current scene
  34034. */
  34035. freezeActiveMeshes(): Scene;
  34036. /**
  34037. * Use this function to restart evaluating active meshes on every frame
  34038. * @returns the current scene
  34039. */
  34040. unfreezeActiveMeshes(): Scene;
  34041. private _evaluateActiveMeshes;
  34042. private _activeMesh;
  34043. /**
  34044. * Update the transform matrix to update from the current active camera
  34045. * @param force defines a boolean used to force the update even if cache is up to date
  34046. */
  34047. updateTransformMatrix(force?: boolean): void;
  34048. private _bindFrameBuffer;
  34049. /** @hidden */
  34050. _allowPostProcessClearColor: boolean;
  34051. private _renderForCamera;
  34052. private _processSubCameras;
  34053. private _checkIntersections;
  34054. /** @hidden */
  34055. _advancePhysicsEngineStep(step: number): void;
  34056. /**
  34057. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34058. */
  34059. getDeterministicFrameTime: () => number;
  34060. /** @hidden */
  34061. _animate(): void;
  34062. /**
  34063. * Render the scene
  34064. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34065. */
  34066. render(updateCameras?: boolean): void;
  34067. /**
  34068. * Freeze all materials
  34069. * A frozen material will not be updatable but should be faster to render
  34070. */
  34071. freezeMaterials(): void;
  34072. /**
  34073. * Unfreeze all materials
  34074. * A frozen material will not be updatable but should be faster to render
  34075. */
  34076. unfreezeMaterials(): void;
  34077. /**
  34078. * Releases all held ressources
  34079. */
  34080. dispose(): void;
  34081. /**
  34082. * Gets if the scene is already disposed
  34083. */
  34084. readonly isDisposed: boolean;
  34085. /**
  34086. * Call this function to reduce memory footprint of the scene.
  34087. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34088. */
  34089. clearCachedVertexData(): void;
  34090. /**
  34091. * This function will remove the local cached buffer data from texture.
  34092. * It will save memory but will prevent the texture from being rebuilt
  34093. */
  34094. cleanCachedTextureBuffer(): void;
  34095. /**
  34096. * Get the world extend vectors with an optional filter
  34097. *
  34098. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34099. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34100. */
  34101. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34102. min: Vector3;
  34103. max: Vector3;
  34104. };
  34105. /**
  34106. * Creates a ray that can be used to pick in the scene
  34107. * @param x defines the x coordinate of the origin (on-screen)
  34108. * @param y defines the y coordinate of the origin (on-screen)
  34109. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34110. * @param camera defines the camera to use for the picking
  34111. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34112. * @returns a Ray
  34113. */
  34114. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34115. /**
  34116. * Creates a ray that can be used to pick in the scene
  34117. * @param x defines the x coordinate of the origin (on-screen)
  34118. * @param y defines the y coordinate of the origin (on-screen)
  34119. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34120. * @param result defines the ray where to store the picking ray
  34121. * @param camera defines the camera to use for the picking
  34122. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34123. * @returns the current scene
  34124. */
  34125. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34126. /**
  34127. * Creates a ray that can be used to pick in the scene
  34128. * @param x defines the x coordinate of the origin (on-screen)
  34129. * @param y defines the y coordinate of the origin (on-screen)
  34130. * @param camera defines the camera to use for the picking
  34131. * @returns a Ray
  34132. */
  34133. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34134. /**
  34135. * Creates a ray that can be used to pick in the scene
  34136. * @param x defines the x coordinate of the origin (on-screen)
  34137. * @param y defines the y coordinate of the origin (on-screen)
  34138. * @param result defines the ray where to store the picking ray
  34139. * @param camera defines the camera to use for the picking
  34140. * @returns the current scene
  34141. */
  34142. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34143. /** Launch a ray to try to pick a mesh in the scene
  34144. * @param x position on screen
  34145. * @param y position on screen
  34146. * @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
  34147. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34148. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34149. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34150. * @returns a PickingInfo
  34151. */
  34152. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34153. /** Use the given ray to pick a mesh in the scene
  34154. * @param ray The ray to use to pick meshes
  34155. * @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
  34156. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34157. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34158. * @returns a PickingInfo
  34159. */
  34160. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34161. /**
  34162. * Launch a ray to try to pick a mesh in the scene
  34163. * @param x X position on screen
  34164. * @param y Y position on screen
  34165. * @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
  34166. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34167. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34168. * @returns an array of PickingInfo
  34169. */
  34170. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34171. /**
  34172. * Launch a ray to try to pick a mesh in the scene
  34173. * @param ray Ray to use
  34174. * @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
  34175. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34176. * @returns an array of PickingInfo
  34177. */
  34178. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34179. /**
  34180. * Force the value of meshUnderPointer
  34181. * @param mesh defines the mesh to use
  34182. */
  34183. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34184. /**
  34185. * Gets the mesh under the pointer
  34186. * @returns a Mesh or null if no mesh is under the pointer
  34187. */
  34188. getPointerOverMesh(): Nullable<AbstractMesh>;
  34189. /** @hidden */
  34190. _rebuildGeometries(): void;
  34191. /** @hidden */
  34192. _rebuildTextures(): void;
  34193. private _getByTags;
  34194. /**
  34195. * Get a list of meshes by tags
  34196. * @param tagsQuery defines the tags query to use
  34197. * @param forEach defines a predicate used to filter results
  34198. * @returns an array of Mesh
  34199. */
  34200. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34201. /**
  34202. * Get a list of cameras by tags
  34203. * @param tagsQuery defines the tags query to use
  34204. * @param forEach defines a predicate used to filter results
  34205. * @returns an array of Camera
  34206. */
  34207. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34208. /**
  34209. * Get a list of lights by tags
  34210. * @param tagsQuery defines the tags query to use
  34211. * @param forEach defines a predicate used to filter results
  34212. * @returns an array of Light
  34213. */
  34214. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34215. /**
  34216. * Get a list of materials by tags
  34217. * @param tagsQuery defines the tags query to use
  34218. * @param forEach defines a predicate used to filter results
  34219. * @returns an array of Material
  34220. */
  34221. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34222. /**
  34223. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34224. * This allowed control for front to back rendering or reversly depending of the special needs.
  34225. *
  34226. * @param renderingGroupId The rendering group id corresponding to its index
  34227. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34228. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34229. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34230. */
  34231. 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;
  34232. /**
  34233. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34234. *
  34235. * @param renderingGroupId The rendering group id corresponding to its index
  34236. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34237. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34238. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34239. */
  34240. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34241. /**
  34242. * Gets the current auto clear configuration for one rendering group of the rendering
  34243. * manager.
  34244. * @param index the rendering group index to get the information for
  34245. * @returns The auto clear setup for the requested rendering group
  34246. */
  34247. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34248. private _blockMaterialDirtyMechanism;
  34249. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34250. blockMaterialDirtyMechanism: boolean;
  34251. /**
  34252. * Will flag all materials as dirty to trigger new shader compilation
  34253. * @param flag defines the flag used to specify which material part must be marked as dirty
  34254. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34255. */
  34256. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34257. /** @hidden */
  34258. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34259. /** @hidden */
  34260. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34261. }
  34262. }
  34263. declare module "babylonjs/assetContainer" {
  34264. import { AbstractScene } from "babylonjs/abstractScene";
  34265. import { Scene } from "babylonjs/scene";
  34266. import { Mesh } from "babylonjs/Meshes/mesh";
  34267. /**
  34268. * Set of assets to keep when moving a scene into an asset container.
  34269. */
  34270. export class KeepAssets extends AbstractScene {
  34271. }
  34272. /**
  34273. * Container with a set of assets that can be added or removed from a scene.
  34274. */
  34275. export class AssetContainer extends AbstractScene {
  34276. /**
  34277. * The scene the AssetContainer belongs to.
  34278. */
  34279. scene: Scene;
  34280. /**
  34281. * Instantiates an AssetContainer.
  34282. * @param scene The scene the AssetContainer belongs to.
  34283. */
  34284. constructor(scene: Scene);
  34285. /**
  34286. * Adds all the assets from the container to the scene.
  34287. */
  34288. addAllToScene(): void;
  34289. /**
  34290. * Removes all the assets in the container from the scene
  34291. */
  34292. removeAllFromScene(): void;
  34293. /**
  34294. * Disposes all the assets in the container
  34295. */
  34296. dispose(): void;
  34297. private _moveAssets;
  34298. /**
  34299. * Removes all the assets contained in the scene and adds them to the container.
  34300. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34301. */
  34302. moveAllFromScene(keepAssets?: KeepAssets): void;
  34303. /**
  34304. * 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.
  34305. * @returns the root mesh
  34306. */
  34307. createRootMesh(): Mesh;
  34308. }
  34309. }
  34310. declare module "babylonjs/abstractScene" {
  34311. import { Scene } from "babylonjs/scene";
  34312. import { Nullable } from "babylonjs/types";
  34313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34314. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34315. import { Geometry } from "babylonjs/Meshes/geometry";
  34316. import { Skeleton } from "babylonjs/Bones/skeleton";
  34317. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34318. import { AssetContainer } from "babylonjs/assetContainer";
  34319. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34320. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34321. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34322. import { Material } from "babylonjs/Materials/material";
  34323. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34324. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34325. import { Camera } from "babylonjs/Cameras/camera";
  34326. import { Light } from "babylonjs/Lights/light";
  34327. import { Node } from "babylonjs/node";
  34328. import { Animation } from "babylonjs/Animations/animation";
  34329. /**
  34330. * Defines how the parser contract is defined.
  34331. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34332. */
  34333. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34334. /**
  34335. * Defines how the individual parser contract is defined.
  34336. * These parser can parse an individual asset
  34337. */
  34338. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34339. /**
  34340. * Base class of the scene acting as a container for the different elements composing a scene.
  34341. * This class is dynamically extended by the different components of the scene increasing
  34342. * flexibility and reducing coupling
  34343. */
  34344. export abstract class AbstractScene {
  34345. /**
  34346. * Stores the list of available parsers in the application.
  34347. */
  34348. private static _BabylonFileParsers;
  34349. /**
  34350. * Stores the list of available individual parsers in the application.
  34351. */
  34352. private static _IndividualBabylonFileParsers;
  34353. /**
  34354. * Adds a parser in the list of available ones
  34355. * @param name Defines the name of the parser
  34356. * @param parser Defines the parser to add
  34357. */
  34358. static AddParser(name: string, parser: BabylonFileParser): void;
  34359. /**
  34360. * Gets a general parser from the list of avaialble ones
  34361. * @param name Defines the name of the parser
  34362. * @returns the requested parser or null
  34363. */
  34364. static GetParser(name: string): Nullable<BabylonFileParser>;
  34365. /**
  34366. * Adds n individual parser in the list of available ones
  34367. * @param name Defines the name of the parser
  34368. * @param parser Defines the parser to add
  34369. */
  34370. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34371. /**
  34372. * Gets an individual parser from the list of avaialble ones
  34373. * @param name Defines the name of the parser
  34374. * @returns the requested parser or null
  34375. */
  34376. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34377. /**
  34378. * Parser json data and populate both a scene and its associated container object
  34379. * @param jsonData Defines the data to parse
  34380. * @param scene Defines the scene to parse the data for
  34381. * @param container Defines the container attached to the parsing sequence
  34382. * @param rootUrl Defines the root url of the data
  34383. */
  34384. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34385. /**
  34386. * Gets the list of root nodes (ie. nodes with no parent)
  34387. */
  34388. rootNodes: Node[];
  34389. /** All of the cameras added to this scene
  34390. * @see http://doc.babylonjs.com/babylon101/cameras
  34391. */
  34392. cameras: Camera[];
  34393. /**
  34394. * All of the lights added to this scene
  34395. * @see http://doc.babylonjs.com/babylon101/lights
  34396. */
  34397. lights: Light[];
  34398. /**
  34399. * All of the (abstract) meshes added to this scene
  34400. */
  34401. meshes: AbstractMesh[];
  34402. /**
  34403. * The list of skeletons added to the scene
  34404. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34405. */
  34406. skeletons: Skeleton[];
  34407. /**
  34408. * All of the particle systems added to this scene
  34409. * @see http://doc.babylonjs.com/babylon101/particles
  34410. */
  34411. particleSystems: IParticleSystem[];
  34412. /**
  34413. * Gets a list of Animations associated with the scene
  34414. */
  34415. animations: Animation[];
  34416. /**
  34417. * All of the animation groups added to this scene
  34418. * @see http://doc.babylonjs.com/how_to/group
  34419. */
  34420. animationGroups: AnimationGroup[];
  34421. /**
  34422. * All of the multi-materials added to this scene
  34423. * @see http://doc.babylonjs.com/how_to/multi_materials
  34424. */
  34425. multiMaterials: MultiMaterial[];
  34426. /**
  34427. * All of the materials added to this scene
  34428. * In the context of a Scene, it is not supposed to be modified manually.
  34429. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34430. * Note also that the order of the Material wihin the array is not significant and might change.
  34431. * @see http://doc.babylonjs.com/babylon101/materials
  34432. */
  34433. materials: Material[];
  34434. /**
  34435. * The list of morph target managers added to the scene
  34436. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34437. */
  34438. morphTargetManagers: MorphTargetManager[];
  34439. /**
  34440. * The list of geometries used in the scene.
  34441. */
  34442. geometries: Geometry[];
  34443. /**
  34444. * All of the tranform nodes added to this scene
  34445. * In the context of a Scene, it is not supposed to be modified manually.
  34446. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34447. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34448. * @see http://doc.babylonjs.com/how_to/transformnode
  34449. */
  34450. transformNodes: TransformNode[];
  34451. /**
  34452. * ActionManagers available on the scene.
  34453. */
  34454. actionManagers: AbstractActionManager[];
  34455. /**
  34456. * Textures to keep.
  34457. */
  34458. textures: BaseTexture[];
  34459. /**
  34460. * Environment texture for the scene
  34461. */
  34462. environmentTexture: Nullable<BaseTexture>;
  34463. }
  34464. }
  34465. declare module "babylonjs/Audio/sound" {
  34466. import { Observable } from "babylonjs/Misc/observable";
  34467. import { Vector3 } from "babylonjs/Maths/math";
  34468. import { Nullable } from "babylonjs/types";
  34469. import { Scene } from "babylonjs/scene";
  34470. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34471. /**
  34472. * Defines a sound that can be played in the application.
  34473. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34475. */
  34476. export class Sound {
  34477. /**
  34478. * The name of the sound in the scene.
  34479. */
  34480. name: string;
  34481. /**
  34482. * Does the sound autoplay once loaded.
  34483. */
  34484. autoplay: boolean;
  34485. /**
  34486. * Does the sound loop after it finishes playing once.
  34487. */
  34488. loop: boolean;
  34489. /**
  34490. * Does the sound use a custom attenuation curve to simulate the falloff
  34491. * happening when the source gets further away from the camera.
  34492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34493. */
  34494. useCustomAttenuation: boolean;
  34495. /**
  34496. * The sound track id this sound belongs to.
  34497. */
  34498. soundTrackId: number;
  34499. /**
  34500. * Is this sound currently played.
  34501. */
  34502. isPlaying: boolean;
  34503. /**
  34504. * Is this sound currently paused.
  34505. */
  34506. isPaused: boolean;
  34507. /**
  34508. * Does this sound enables spatial sound.
  34509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34510. */
  34511. spatialSound: boolean;
  34512. /**
  34513. * Define the reference distance the sound should be heard perfectly.
  34514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34515. */
  34516. refDistance: number;
  34517. /**
  34518. * Define the roll off factor of spatial sounds.
  34519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34520. */
  34521. rolloffFactor: number;
  34522. /**
  34523. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34525. */
  34526. maxDistance: number;
  34527. /**
  34528. * Define the distance attenuation model the sound will follow.
  34529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34530. */
  34531. distanceModel: string;
  34532. /**
  34533. * @hidden
  34534. * Back Compat
  34535. **/
  34536. onended: () => any;
  34537. /**
  34538. * Observable event when the current playing sound finishes.
  34539. */
  34540. onEndedObservable: Observable<Sound>;
  34541. private _panningModel;
  34542. private _playbackRate;
  34543. private _streaming;
  34544. private _startTime;
  34545. private _startOffset;
  34546. private _position;
  34547. /** @hidden */
  34548. _positionInEmitterSpace: boolean;
  34549. private _localDirection;
  34550. private _volume;
  34551. private _isReadyToPlay;
  34552. private _isDirectional;
  34553. private _readyToPlayCallback;
  34554. private _audioBuffer;
  34555. private _soundSource;
  34556. private _streamingSource;
  34557. private _soundPanner;
  34558. private _soundGain;
  34559. private _inputAudioNode;
  34560. private _outputAudioNode;
  34561. private _coneInnerAngle;
  34562. private _coneOuterAngle;
  34563. private _coneOuterGain;
  34564. private _scene;
  34565. private _connectedTransformNode;
  34566. private _customAttenuationFunction;
  34567. private _registerFunc;
  34568. private _isOutputConnected;
  34569. private _htmlAudioElement;
  34570. private _urlType;
  34571. /** @hidden */
  34572. static _SceneComponentInitialization: (scene: Scene) => void;
  34573. /**
  34574. * Create a sound and attach it to a scene
  34575. * @param name Name of your sound
  34576. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34577. * @param scene defines the scene the sound belongs to
  34578. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34579. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34580. */
  34581. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34582. /**
  34583. * Release the sound and its associated resources
  34584. */
  34585. dispose(): void;
  34586. /**
  34587. * Gets if the sounds is ready to be played or not.
  34588. * @returns true if ready, otherwise false
  34589. */
  34590. isReady(): boolean;
  34591. private _soundLoaded;
  34592. /**
  34593. * Sets the data of the sound from an audiobuffer
  34594. * @param audioBuffer The audioBuffer containing the data
  34595. */
  34596. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34597. /**
  34598. * Updates the current sounds options such as maxdistance, loop...
  34599. * @param options A JSON object containing values named as the object properties
  34600. */
  34601. updateOptions(options: any): void;
  34602. private _createSpatialParameters;
  34603. private _updateSpatialParameters;
  34604. /**
  34605. * Switch the panning model to HRTF:
  34606. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34608. */
  34609. switchPanningModelToHRTF(): void;
  34610. /**
  34611. * Switch the panning model to Equal Power:
  34612. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34614. */
  34615. switchPanningModelToEqualPower(): void;
  34616. private _switchPanningModel;
  34617. /**
  34618. * Connect this sound to a sound track audio node like gain...
  34619. * @param soundTrackAudioNode the sound track audio node to connect to
  34620. */
  34621. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34622. /**
  34623. * Transform this sound into a directional source
  34624. * @param coneInnerAngle Size of the inner cone in degree
  34625. * @param coneOuterAngle Size of the outer cone in degree
  34626. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34627. */
  34628. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34629. /**
  34630. * Gets or sets the inner angle for the directional cone.
  34631. */
  34632. /**
  34633. * Gets or sets the inner angle for the directional cone.
  34634. */
  34635. directionalConeInnerAngle: number;
  34636. /**
  34637. * Gets or sets the outer angle for the directional cone.
  34638. */
  34639. /**
  34640. * Gets or sets the outer angle for the directional cone.
  34641. */
  34642. directionalConeOuterAngle: number;
  34643. /**
  34644. * Sets the position of the emitter if spatial sound is enabled
  34645. * @param newPosition Defines the new posisiton
  34646. */
  34647. setPosition(newPosition: Vector3): void;
  34648. /**
  34649. * Sets the local direction of the emitter if spatial sound is enabled
  34650. * @param newLocalDirection Defines the new local direction
  34651. */
  34652. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34653. private _updateDirection;
  34654. /** @hidden */
  34655. updateDistanceFromListener(): void;
  34656. /**
  34657. * Sets a new custom attenuation function for the sound.
  34658. * @param callback Defines the function used for the attenuation
  34659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34660. */
  34661. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34662. /**
  34663. * Play the sound
  34664. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34665. * @param offset (optional) Start the sound setting it at a specific time
  34666. */
  34667. play(time?: number, offset?: number): void;
  34668. private _onended;
  34669. /**
  34670. * Stop the sound
  34671. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34672. */
  34673. stop(time?: number): void;
  34674. /**
  34675. * Put the sound in pause
  34676. */
  34677. pause(): void;
  34678. /**
  34679. * Sets a dedicated volume for this sounds
  34680. * @param newVolume Define the new volume of the sound
  34681. * @param time Define in how long the sound should be at this value
  34682. */
  34683. setVolume(newVolume: number, time?: number): void;
  34684. /**
  34685. * Set the sound play back rate
  34686. * @param newPlaybackRate Define the playback rate the sound should be played at
  34687. */
  34688. setPlaybackRate(newPlaybackRate: number): void;
  34689. /**
  34690. * Gets the volume of the sound.
  34691. * @returns the volume of the sound
  34692. */
  34693. getVolume(): number;
  34694. /**
  34695. * Attach the sound to a dedicated mesh
  34696. * @param transformNode The transform node to connect the sound with
  34697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34698. */
  34699. attachToMesh(transformNode: TransformNode): void;
  34700. /**
  34701. * Detach the sound from the previously attached mesh
  34702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34703. */
  34704. detachFromMesh(): void;
  34705. private _onRegisterAfterWorldMatrixUpdate;
  34706. /**
  34707. * Clone the current sound in the scene.
  34708. * @returns the new sound clone
  34709. */
  34710. clone(): Nullable<Sound>;
  34711. /**
  34712. * Gets the current underlying audio buffer containing the data
  34713. * @returns the audio buffer
  34714. */
  34715. getAudioBuffer(): Nullable<AudioBuffer>;
  34716. /**
  34717. * Serializes the Sound in a JSON representation
  34718. * @returns the JSON representation of the sound
  34719. */
  34720. serialize(): any;
  34721. /**
  34722. * Parse a JSON representation of a sound to innstantiate in a given scene
  34723. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34724. * @param scene Define the scene the new parsed sound should be created in
  34725. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34726. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34727. * @returns the newly parsed sound
  34728. */
  34729. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34730. }
  34731. }
  34732. declare module "babylonjs/Actions/directAudioActions" {
  34733. import { Action } from "babylonjs/Actions/action";
  34734. import { Condition } from "babylonjs/Actions/condition";
  34735. import { Sound } from "babylonjs/Audio/sound";
  34736. /**
  34737. * This defines an action helpful to play a defined sound on a triggered action.
  34738. */
  34739. export class PlaySoundAction extends Action {
  34740. private _sound;
  34741. /**
  34742. * Instantiate the action
  34743. * @param triggerOptions defines the trigger options
  34744. * @param sound defines the sound to play
  34745. * @param condition defines the trigger related conditions
  34746. */
  34747. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34748. /** @hidden */
  34749. _prepare(): void;
  34750. /**
  34751. * Execute the action and play the sound.
  34752. */
  34753. execute(): void;
  34754. /**
  34755. * Serializes the actions and its related information.
  34756. * @param parent defines the object to serialize in
  34757. * @returns the serialized object
  34758. */
  34759. serialize(parent: any): any;
  34760. }
  34761. /**
  34762. * This defines an action helpful to stop a defined sound on a triggered action.
  34763. */
  34764. export class StopSoundAction extends Action {
  34765. private _sound;
  34766. /**
  34767. * Instantiate the action
  34768. * @param triggerOptions defines the trigger options
  34769. * @param sound defines the sound to stop
  34770. * @param condition defines the trigger related conditions
  34771. */
  34772. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34773. /** @hidden */
  34774. _prepare(): void;
  34775. /**
  34776. * Execute the action and stop the sound.
  34777. */
  34778. execute(): void;
  34779. /**
  34780. * Serializes the actions and its related information.
  34781. * @param parent defines the object to serialize in
  34782. * @returns the serialized object
  34783. */
  34784. serialize(parent: any): any;
  34785. }
  34786. }
  34787. declare module "babylonjs/Actions/interpolateValueAction" {
  34788. import { Action } from "babylonjs/Actions/action";
  34789. import { Condition } from "babylonjs/Actions/condition";
  34790. import { Observable } from "babylonjs/Misc/observable";
  34791. /**
  34792. * This defines an action responsible to change the value of a property
  34793. * by interpolating between its current value and the newly set one once triggered.
  34794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34795. */
  34796. export class InterpolateValueAction extends Action {
  34797. /**
  34798. * Defines the path of the property where the value should be interpolated
  34799. */
  34800. propertyPath: string;
  34801. /**
  34802. * Defines the target value at the end of the interpolation.
  34803. */
  34804. value: any;
  34805. /**
  34806. * Defines the time it will take for the property to interpolate to the value.
  34807. */
  34808. duration: number;
  34809. /**
  34810. * Defines if the other scene animations should be stopped when the action has been triggered
  34811. */
  34812. stopOtherAnimations?: boolean;
  34813. /**
  34814. * Defines a callback raised once the interpolation animation has been done.
  34815. */
  34816. onInterpolationDone?: () => void;
  34817. /**
  34818. * Observable triggered once the interpolation animation has been done.
  34819. */
  34820. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34821. private _target;
  34822. private _effectiveTarget;
  34823. private _property;
  34824. /**
  34825. * Instantiate the action
  34826. * @param triggerOptions defines the trigger options
  34827. * @param target defines the object containing the value to interpolate
  34828. * @param propertyPath defines the path to the property in the target object
  34829. * @param value defines the target value at the end of the interpolation
  34830. * @param duration deines the time it will take for the property to interpolate to the value.
  34831. * @param condition defines the trigger related conditions
  34832. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34833. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34834. */
  34835. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34836. /** @hidden */
  34837. _prepare(): void;
  34838. /**
  34839. * Execute the action starts the value interpolation.
  34840. */
  34841. execute(): void;
  34842. /**
  34843. * Serializes the actions and its related information.
  34844. * @param parent defines the object to serialize in
  34845. * @returns the serialized object
  34846. */
  34847. serialize(parent: any): any;
  34848. }
  34849. }
  34850. declare module "babylonjs/Actions/index" {
  34851. export * from "babylonjs/Actions/action";
  34852. export * from "babylonjs/Actions/actionEvent";
  34853. export * from "babylonjs/Actions/actionManager";
  34854. export * from "babylonjs/Actions/condition";
  34855. export * from "babylonjs/Actions/directActions";
  34856. export * from "babylonjs/Actions/directAudioActions";
  34857. export * from "babylonjs/Actions/interpolateValueAction";
  34858. }
  34859. declare module "babylonjs/Animations/index" {
  34860. export * from "babylonjs/Animations/animatable";
  34861. export * from "babylonjs/Animations/animation";
  34862. export * from "babylonjs/Animations/animationGroup";
  34863. export * from "babylonjs/Animations/animationPropertiesOverride";
  34864. export * from "babylonjs/Animations/easing";
  34865. export * from "babylonjs/Animations/runtimeAnimation";
  34866. export * from "babylonjs/Animations/animationEvent";
  34867. export * from "babylonjs/Animations/animationGroup";
  34868. export * from "babylonjs/Animations/animationKey";
  34869. export * from "babylonjs/Animations/animationRange";
  34870. }
  34871. declare module "babylonjs/Audio/soundTrack" {
  34872. import { Sound } from "babylonjs/Audio/sound";
  34873. import { Analyser } from "babylonjs/Audio/analyser";
  34874. import { Scene } from "babylonjs/scene";
  34875. /**
  34876. * Options allowed during the creation of a sound track.
  34877. */
  34878. export interface ISoundTrackOptions {
  34879. /**
  34880. * The volume the sound track should take during creation
  34881. */
  34882. volume?: number;
  34883. /**
  34884. * Define if the sound track is the main sound track of the scene
  34885. */
  34886. mainTrack?: boolean;
  34887. }
  34888. /**
  34889. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34890. * It will be also used in a future release to apply effects on a specific track.
  34891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34892. */
  34893. export class SoundTrack {
  34894. /**
  34895. * The unique identifier of the sound track in the scene.
  34896. */
  34897. id: number;
  34898. /**
  34899. * The list of sounds included in the sound track.
  34900. */
  34901. soundCollection: Array<Sound>;
  34902. private _outputAudioNode;
  34903. private _scene;
  34904. private _isMainTrack;
  34905. private _connectedAnalyser;
  34906. private _options;
  34907. private _isInitialized;
  34908. /**
  34909. * Creates a new sound track.
  34910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34911. * @param scene Define the scene the sound track belongs to
  34912. * @param options
  34913. */
  34914. constructor(scene: Scene, options?: ISoundTrackOptions);
  34915. private _initializeSoundTrackAudioGraph;
  34916. /**
  34917. * Release the sound track and its associated resources
  34918. */
  34919. dispose(): void;
  34920. /**
  34921. * Adds a sound to this sound track
  34922. * @param sound define the cound to add
  34923. * @ignoreNaming
  34924. */
  34925. AddSound(sound: Sound): void;
  34926. /**
  34927. * Removes a sound to this sound track
  34928. * @param sound define the cound to remove
  34929. * @ignoreNaming
  34930. */
  34931. RemoveSound(sound: Sound): void;
  34932. /**
  34933. * Set a global volume for the full sound track.
  34934. * @param newVolume Define the new volume of the sound track
  34935. */
  34936. setVolume(newVolume: number): void;
  34937. /**
  34938. * Switch the panning model to HRTF:
  34939. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34941. */
  34942. switchPanningModelToHRTF(): void;
  34943. /**
  34944. * Switch the panning model to Equal Power:
  34945. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34947. */
  34948. switchPanningModelToEqualPower(): void;
  34949. /**
  34950. * Connect the sound track to an audio analyser allowing some amazing
  34951. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34953. * @param analyser The analyser to connect to the engine
  34954. */
  34955. connectToAnalyser(analyser: Analyser): void;
  34956. }
  34957. }
  34958. declare module "babylonjs/Audio/audioSceneComponent" {
  34959. import { Sound } from "babylonjs/Audio/sound";
  34960. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34961. import { Nullable } from "babylonjs/types";
  34962. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34963. import { Scene } from "babylonjs/scene";
  34964. import { AbstractScene } from "babylonjs/abstractScene";
  34965. module "babylonjs/abstractScene" {
  34966. interface AbstractScene {
  34967. /**
  34968. * The list of sounds used in the scene.
  34969. */
  34970. sounds: Nullable<Array<Sound>>;
  34971. }
  34972. }
  34973. module "babylonjs/scene" {
  34974. interface Scene {
  34975. /**
  34976. * @hidden
  34977. * Backing field
  34978. */
  34979. _mainSoundTrack: SoundTrack;
  34980. /**
  34981. * The main sound track played by the scene.
  34982. * It cotains your primary collection of sounds.
  34983. */
  34984. mainSoundTrack: SoundTrack;
  34985. /**
  34986. * The list of sound tracks added to the scene
  34987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34988. */
  34989. soundTracks: Nullable<Array<SoundTrack>>;
  34990. /**
  34991. * Gets a sound using a given name
  34992. * @param name defines the name to search for
  34993. * @return the found sound or null if not found at all.
  34994. */
  34995. getSoundByName(name: string): Nullable<Sound>;
  34996. /**
  34997. * Gets or sets if audio support is enabled
  34998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34999. */
  35000. audioEnabled: boolean;
  35001. /**
  35002. * Gets or sets if audio will be output to headphones
  35003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35004. */
  35005. headphone: boolean;
  35006. }
  35007. }
  35008. /**
  35009. * Defines the sound scene component responsible to manage any sounds
  35010. * in a given scene.
  35011. */
  35012. export class AudioSceneComponent implements ISceneSerializableComponent {
  35013. /**
  35014. * The component name helpfull to identify the component in the list of scene components.
  35015. */
  35016. readonly name: string;
  35017. /**
  35018. * The scene the component belongs to.
  35019. */
  35020. scene: Scene;
  35021. private _audioEnabled;
  35022. /**
  35023. * Gets whether audio is enabled or not.
  35024. * Please use related enable/disable method to switch state.
  35025. */
  35026. readonly audioEnabled: boolean;
  35027. private _headphone;
  35028. /**
  35029. * Gets whether audio is outputing to headphone or not.
  35030. * Please use the according Switch methods to change output.
  35031. */
  35032. readonly headphone: boolean;
  35033. /**
  35034. * Creates a new instance of the component for the given scene
  35035. * @param scene Defines the scene to register the component in
  35036. */
  35037. constructor(scene: Scene);
  35038. /**
  35039. * Registers the component in a given scene
  35040. */
  35041. register(): void;
  35042. /**
  35043. * Rebuilds the elements related to this component in case of
  35044. * context lost for instance.
  35045. */
  35046. rebuild(): void;
  35047. /**
  35048. * Serializes the component data to the specified json object
  35049. * @param serializationObject The object to serialize to
  35050. */
  35051. serialize(serializationObject: any): void;
  35052. /**
  35053. * Adds all the element from the container to the scene
  35054. * @param container the container holding the elements
  35055. */
  35056. addFromContainer(container: AbstractScene): void;
  35057. /**
  35058. * Removes all the elements in the container from the scene
  35059. * @param container contains the elements to remove
  35060. * @param dispose if the removed element should be disposed (default: false)
  35061. */
  35062. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35063. /**
  35064. * Disposes the component and the associated ressources.
  35065. */
  35066. dispose(): void;
  35067. /**
  35068. * Disables audio in the associated scene.
  35069. */
  35070. disableAudio(): void;
  35071. /**
  35072. * Enables audio in the associated scene.
  35073. */
  35074. enableAudio(): void;
  35075. /**
  35076. * Switch audio to headphone output.
  35077. */
  35078. switchAudioModeForHeadphones(): void;
  35079. /**
  35080. * Switch audio to normal speakers.
  35081. */
  35082. switchAudioModeForNormalSpeakers(): void;
  35083. private _afterRender;
  35084. }
  35085. }
  35086. declare module "babylonjs/Audio/weightedsound" {
  35087. import { Sound } from "babylonjs/Audio/sound";
  35088. /**
  35089. * Wraps one or more Sound objects and selects one with random weight for playback.
  35090. */
  35091. export class WeightedSound {
  35092. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35093. loop: boolean;
  35094. private _coneInnerAngle;
  35095. private _coneOuterAngle;
  35096. private _volume;
  35097. /** A Sound is currently playing. */
  35098. isPlaying: boolean;
  35099. /** A Sound is currently paused. */
  35100. isPaused: boolean;
  35101. private _sounds;
  35102. private _weights;
  35103. private _currentIndex?;
  35104. /**
  35105. * Creates a new WeightedSound from the list of sounds given.
  35106. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35107. * @param sounds Array of Sounds that will be selected from.
  35108. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35109. */
  35110. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35111. /**
  35112. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35113. */
  35114. /**
  35115. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35116. */
  35117. directionalConeInnerAngle: number;
  35118. /**
  35119. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35120. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35121. */
  35122. /**
  35123. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35124. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35125. */
  35126. directionalConeOuterAngle: number;
  35127. /**
  35128. * Playback volume.
  35129. */
  35130. /**
  35131. * Playback volume.
  35132. */
  35133. volume: number;
  35134. private _onended;
  35135. /**
  35136. * Suspend playback
  35137. */
  35138. pause(): void;
  35139. /**
  35140. * Stop playback
  35141. */
  35142. stop(): void;
  35143. /**
  35144. * Start playback.
  35145. * @param startOffset Position the clip head at a specific time in seconds.
  35146. */
  35147. play(startOffset?: number): void;
  35148. }
  35149. }
  35150. declare module "babylonjs/Audio/index" {
  35151. export * from "babylonjs/Audio/analyser";
  35152. export * from "babylonjs/Audio/audioEngine";
  35153. export * from "babylonjs/Audio/audioSceneComponent";
  35154. export * from "babylonjs/Audio/sound";
  35155. export * from "babylonjs/Audio/soundTrack";
  35156. export * from "babylonjs/Audio/weightedsound";
  35157. }
  35158. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35159. import { Behavior } from "babylonjs/Behaviors/behavior";
  35160. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35161. import { BackEase } from "babylonjs/Animations/easing";
  35162. /**
  35163. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35164. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35165. */
  35166. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35167. /**
  35168. * Gets the name of the behavior.
  35169. */
  35170. readonly name: string;
  35171. /**
  35172. * The easing function used by animations
  35173. */
  35174. static EasingFunction: BackEase;
  35175. /**
  35176. * The easing mode used by animations
  35177. */
  35178. static EasingMode: number;
  35179. /**
  35180. * The duration of the animation, in milliseconds
  35181. */
  35182. transitionDuration: number;
  35183. /**
  35184. * Length of the distance animated by the transition when lower radius is reached
  35185. */
  35186. lowerRadiusTransitionRange: number;
  35187. /**
  35188. * Length of the distance animated by the transition when upper radius is reached
  35189. */
  35190. upperRadiusTransitionRange: number;
  35191. private _autoTransitionRange;
  35192. /**
  35193. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35194. */
  35195. /**
  35196. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35197. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35198. */
  35199. autoTransitionRange: boolean;
  35200. private _attachedCamera;
  35201. private _onAfterCheckInputsObserver;
  35202. private _onMeshTargetChangedObserver;
  35203. /**
  35204. * Initializes the behavior.
  35205. */
  35206. init(): void;
  35207. /**
  35208. * Attaches the behavior to its arc rotate camera.
  35209. * @param camera Defines the camera to attach the behavior to
  35210. */
  35211. attach(camera: ArcRotateCamera): void;
  35212. /**
  35213. * Detaches the behavior from its current arc rotate camera.
  35214. */
  35215. detach(): void;
  35216. private _radiusIsAnimating;
  35217. private _radiusBounceTransition;
  35218. private _animatables;
  35219. private _cachedWheelPrecision;
  35220. /**
  35221. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35222. * @param radiusLimit The limit to check against.
  35223. * @return Bool to indicate if at limit.
  35224. */
  35225. private _isRadiusAtLimit;
  35226. /**
  35227. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35228. * @param radiusDelta The delta by which to animate to. Can be negative.
  35229. */
  35230. private _applyBoundRadiusAnimation;
  35231. /**
  35232. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35233. */
  35234. protected _clearAnimationLocks(): void;
  35235. /**
  35236. * Stops and removes all animations that have been applied to the camera
  35237. */
  35238. stopAllAnimations(): void;
  35239. }
  35240. }
  35241. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35242. import { Behavior } from "babylonjs/Behaviors/behavior";
  35243. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35244. import { ExponentialEase } from "babylonjs/Animations/easing";
  35245. import { Nullable } from "babylonjs/types";
  35246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35247. import { Vector3 } from "babylonjs/Maths/math";
  35248. /**
  35249. * 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.
  35250. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35251. */
  35252. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35253. /**
  35254. * Gets the name of the behavior.
  35255. */
  35256. readonly name: string;
  35257. private _mode;
  35258. private _radiusScale;
  35259. private _positionScale;
  35260. private _defaultElevation;
  35261. private _elevationReturnTime;
  35262. private _elevationReturnWaitTime;
  35263. private _zoomStopsAnimation;
  35264. private _framingTime;
  35265. /**
  35266. * The easing function used by animations
  35267. */
  35268. static EasingFunction: ExponentialEase;
  35269. /**
  35270. * The easing mode used by animations
  35271. */
  35272. static EasingMode: number;
  35273. /**
  35274. * Sets the current mode used by the behavior
  35275. */
  35276. /**
  35277. * Gets current mode used by the behavior.
  35278. */
  35279. mode: number;
  35280. /**
  35281. * Sets the scale applied to the radius (1 by default)
  35282. */
  35283. /**
  35284. * Gets the scale applied to the radius
  35285. */
  35286. radiusScale: number;
  35287. /**
  35288. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35289. */
  35290. /**
  35291. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35292. */
  35293. positionScale: number;
  35294. /**
  35295. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35296. * behaviour is triggered, in radians.
  35297. */
  35298. /**
  35299. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35300. * behaviour is triggered, in radians.
  35301. */
  35302. defaultElevation: number;
  35303. /**
  35304. * Sets the time (in milliseconds) taken to return to the default beta position.
  35305. * Negative value indicates camera should not return to default.
  35306. */
  35307. /**
  35308. * Gets the time (in milliseconds) taken to return to the default beta position.
  35309. * Negative value indicates camera should not return to default.
  35310. */
  35311. elevationReturnTime: number;
  35312. /**
  35313. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35314. */
  35315. /**
  35316. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35317. */
  35318. elevationReturnWaitTime: number;
  35319. /**
  35320. * Sets the flag that indicates if user zooming should stop animation.
  35321. */
  35322. /**
  35323. * Gets the flag that indicates if user zooming should stop animation.
  35324. */
  35325. zoomStopsAnimation: boolean;
  35326. /**
  35327. * Sets the transition time when framing the mesh, in milliseconds
  35328. */
  35329. /**
  35330. * Gets the transition time when framing the mesh, in milliseconds
  35331. */
  35332. framingTime: number;
  35333. /**
  35334. * Define if the behavior should automatically change the configured
  35335. * camera limits and sensibilities.
  35336. */
  35337. autoCorrectCameraLimitsAndSensibility: boolean;
  35338. private _onPrePointerObservableObserver;
  35339. private _onAfterCheckInputsObserver;
  35340. private _onMeshTargetChangedObserver;
  35341. private _attachedCamera;
  35342. private _isPointerDown;
  35343. private _lastInteractionTime;
  35344. /**
  35345. * Initializes the behavior.
  35346. */
  35347. init(): void;
  35348. /**
  35349. * Attaches the behavior to its arc rotate camera.
  35350. * @param camera Defines the camera to attach the behavior to
  35351. */
  35352. attach(camera: ArcRotateCamera): void;
  35353. /**
  35354. * Detaches the behavior from its current arc rotate camera.
  35355. */
  35356. detach(): void;
  35357. private _animatables;
  35358. private _betaIsAnimating;
  35359. private _betaTransition;
  35360. private _radiusTransition;
  35361. private _vectorTransition;
  35362. /**
  35363. * Targets the given mesh and updates zoom level accordingly.
  35364. * @param mesh The mesh to target.
  35365. * @param radius Optional. If a cached radius position already exists, overrides default.
  35366. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35367. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35368. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35369. */
  35370. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35371. /**
  35372. * Targets the given mesh with its children and updates zoom level accordingly.
  35373. * @param mesh The mesh to target.
  35374. * @param radius Optional. If a cached radius position already exists, overrides default.
  35375. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35376. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35377. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35378. */
  35379. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35380. /**
  35381. * Targets the given meshes with their children and updates zoom level accordingly.
  35382. * @param meshes The mesh to target.
  35383. * @param radius Optional. If a cached radius position already exists, overrides default.
  35384. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35385. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35386. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35387. */
  35388. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35389. /**
  35390. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35391. * @param minimumWorld Determines the smaller position of the bounding box extend
  35392. * @param maximumWorld Determines the bigger position of the bounding box extend
  35393. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35394. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35395. */
  35396. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35397. /**
  35398. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35399. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35400. * frustum width.
  35401. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35402. * to fully enclose the mesh in the viewing frustum.
  35403. */
  35404. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35405. /**
  35406. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35407. * is automatically returned to its default position (expected to be above ground plane).
  35408. */
  35409. private _maintainCameraAboveGround;
  35410. /**
  35411. * Returns the frustum slope based on the canvas ratio and camera FOV
  35412. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35413. */
  35414. private _getFrustumSlope;
  35415. /**
  35416. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35417. */
  35418. private _clearAnimationLocks;
  35419. /**
  35420. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35421. */
  35422. private _applyUserInteraction;
  35423. /**
  35424. * Stops and removes all animations that have been applied to the camera
  35425. */
  35426. stopAllAnimations(): void;
  35427. /**
  35428. * Gets a value indicating if the user is moving the camera
  35429. */
  35430. readonly isUserIsMoving: boolean;
  35431. /**
  35432. * The camera can move all the way towards the mesh.
  35433. */
  35434. static IgnoreBoundsSizeMode: number;
  35435. /**
  35436. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35437. */
  35438. static FitFrustumSidesMode: number;
  35439. }
  35440. }
  35441. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35442. import { Nullable } from "babylonjs/types";
  35443. import { Camera } from "babylonjs/Cameras/camera";
  35444. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35445. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35446. /**
  35447. * Base class for Camera Pointer Inputs.
  35448. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35449. * for example usage.
  35450. */
  35451. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35452. /**
  35453. * Defines the camera the input is attached to.
  35454. */
  35455. abstract camera: Camera;
  35456. /**
  35457. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35458. */
  35459. protected _altKey: boolean;
  35460. protected _ctrlKey: boolean;
  35461. protected _metaKey: boolean;
  35462. protected _shiftKey: boolean;
  35463. /**
  35464. * Which mouse buttons were pressed at time of last mouse event.
  35465. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35466. */
  35467. protected _buttonsPressed: number;
  35468. /**
  35469. * Defines the buttons associated with the input to handle camera move.
  35470. */
  35471. buttons: number[];
  35472. /**
  35473. * Attach the input controls to a specific dom element to get the input from.
  35474. * @param element Defines the element the controls should be listened from
  35475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35476. */
  35477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35478. /**
  35479. * Detach the current controls from the specified dom element.
  35480. * @param element Defines the element to stop listening the inputs from
  35481. */
  35482. detachControl(element: Nullable<HTMLElement>): void;
  35483. /**
  35484. * Gets the class name of the current input.
  35485. * @returns the class name
  35486. */
  35487. getClassName(): string;
  35488. /**
  35489. * Get the friendly name associated with the input class.
  35490. * @returns the input friendly name
  35491. */
  35492. getSimpleName(): string;
  35493. /**
  35494. * Called on pointer POINTERDOUBLETAP event.
  35495. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35496. */
  35497. protected onDoubleTap(type: string): void;
  35498. /**
  35499. * Called on pointer POINTERMOVE event if only a single touch is active.
  35500. * Override this method to provide functionality.
  35501. */
  35502. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35503. /**
  35504. * Called on pointer POINTERMOVE event if multiple touches are active.
  35505. * Override this method to provide functionality.
  35506. */
  35507. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35508. /**
  35509. * Called on JS contextmenu event.
  35510. * Override this method to provide functionality.
  35511. */
  35512. protected onContextMenu(evt: PointerEvent): void;
  35513. /**
  35514. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35515. * press.
  35516. * Override this method to provide functionality.
  35517. */
  35518. protected onButtonDown(evt: PointerEvent): void;
  35519. /**
  35520. * Called each time a new POINTERUP event occurs. Ie, for each button
  35521. * release.
  35522. * Override this method to provide functionality.
  35523. */
  35524. protected onButtonUp(evt: PointerEvent): void;
  35525. /**
  35526. * Called when window becomes inactive.
  35527. * Override this method to provide functionality.
  35528. */
  35529. protected onLostFocus(): void;
  35530. private _pointerInput;
  35531. private _observer;
  35532. private _onLostFocus;
  35533. private pointA;
  35534. private pointB;
  35535. }
  35536. }
  35537. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35538. import { Nullable } from "babylonjs/types";
  35539. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35540. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35541. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35542. /**
  35543. * Manage the pointers inputs to control an arc rotate camera.
  35544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35545. */
  35546. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35547. /**
  35548. * Defines the camera the input is attached to.
  35549. */
  35550. camera: ArcRotateCamera;
  35551. /**
  35552. * Gets the class name of the current input.
  35553. * @returns the class name
  35554. */
  35555. getClassName(): string;
  35556. /**
  35557. * Defines the buttons associated with the input to handle camera move.
  35558. */
  35559. buttons: number[];
  35560. /**
  35561. * Defines the pointer angular sensibility along the X axis or how fast is
  35562. * the camera rotating.
  35563. */
  35564. angularSensibilityX: number;
  35565. /**
  35566. * Defines the pointer angular sensibility along the Y axis or how fast is
  35567. * the camera rotating.
  35568. */
  35569. angularSensibilityY: number;
  35570. /**
  35571. * Defines the pointer pinch precision or how fast is the camera zooming.
  35572. */
  35573. pinchPrecision: number;
  35574. /**
  35575. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35576. * from 0.
  35577. * It defines the percentage of current camera.radius to use as delta when
  35578. * pinch zoom is used.
  35579. */
  35580. pinchDeltaPercentage: number;
  35581. /**
  35582. * Defines the pointer panning sensibility or how fast is the camera moving.
  35583. */
  35584. panningSensibility: number;
  35585. /**
  35586. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35587. */
  35588. multiTouchPanning: boolean;
  35589. /**
  35590. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35591. * zoom (pinch) through multitouch.
  35592. */
  35593. multiTouchPanAndZoom: boolean;
  35594. /**
  35595. * Revers pinch action direction.
  35596. */
  35597. pinchInwards: boolean;
  35598. private _isPanClick;
  35599. private _twoFingerActivityCount;
  35600. private _isPinching;
  35601. /**
  35602. * Called on pointer POINTERMOVE event if only a single touch is active.
  35603. */
  35604. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35605. /**
  35606. * Called on pointer POINTERDOUBLETAP event.
  35607. */
  35608. protected onDoubleTap(type: string): void;
  35609. /**
  35610. * Called on pointer POINTERMOVE event if multiple touches are active.
  35611. */
  35612. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35613. /**
  35614. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35615. * press.
  35616. */
  35617. protected onButtonDown(evt: PointerEvent): void;
  35618. /**
  35619. * Called each time a new POINTERUP event occurs. Ie, for each button
  35620. * release.
  35621. */
  35622. protected onButtonUp(evt: PointerEvent): void;
  35623. /**
  35624. * Called when window becomes inactive.
  35625. */
  35626. protected onLostFocus(): void;
  35627. }
  35628. }
  35629. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35630. import { Nullable } from "babylonjs/types";
  35631. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35632. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35633. /**
  35634. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35636. */
  35637. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35638. /**
  35639. * Defines the camera the input is attached to.
  35640. */
  35641. camera: ArcRotateCamera;
  35642. /**
  35643. * Defines the list of key codes associated with the up action (increase alpha)
  35644. */
  35645. keysUp: number[];
  35646. /**
  35647. * Defines the list of key codes associated with the down action (decrease alpha)
  35648. */
  35649. keysDown: number[];
  35650. /**
  35651. * Defines the list of key codes associated with the left action (increase beta)
  35652. */
  35653. keysLeft: number[];
  35654. /**
  35655. * Defines the list of key codes associated with the right action (decrease beta)
  35656. */
  35657. keysRight: number[];
  35658. /**
  35659. * Defines the list of key codes associated with the reset action.
  35660. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35661. */
  35662. keysReset: number[];
  35663. /**
  35664. * Defines the panning sensibility of the inputs.
  35665. * (How fast is the camera paning)
  35666. */
  35667. panningSensibility: number;
  35668. /**
  35669. * Defines the zooming sensibility of the inputs.
  35670. * (How fast is the camera zooming)
  35671. */
  35672. zoomingSensibility: number;
  35673. /**
  35674. * Defines wether maintaining the alt key down switch the movement mode from
  35675. * orientation to zoom.
  35676. */
  35677. useAltToZoom: boolean;
  35678. /**
  35679. * Rotation speed of the camera
  35680. */
  35681. angularSpeed: number;
  35682. private _keys;
  35683. private _ctrlPressed;
  35684. private _altPressed;
  35685. private _onCanvasBlurObserver;
  35686. private _onKeyboardObserver;
  35687. private _engine;
  35688. private _scene;
  35689. /**
  35690. * Attach the input controls to a specific dom element to get the input from.
  35691. * @param element Defines the element the controls should be listened from
  35692. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35693. */
  35694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35695. /**
  35696. * Detach the current controls from the specified dom element.
  35697. * @param element Defines the element to stop listening the inputs from
  35698. */
  35699. detachControl(element: Nullable<HTMLElement>): void;
  35700. /**
  35701. * Update the current camera state depending on the inputs that have been used this frame.
  35702. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35703. */
  35704. checkInputs(): void;
  35705. /**
  35706. * Gets the class name of the current intput.
  35707. * @returns the class name
  35708. */
  35709. getClassName(): string;
  35710. /**
  35711. * Get the friendly name associated with the input class.
  35712. * @returns the input friendly name
  35713. */
  35714. getSimpleName(): string;
  35715. }
  35716. }
  35717. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35718. import { Nullable } from "babylonjs/types";
  35719. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35720. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35721. /**
  35722. * Manage the mouse wheel inputs to control an arc rotate camera.
  35723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35724. */
  35725. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35726. /**
  35727. * Defines the camera the input is attached to.
  35728. */
  35729. camera: ArcRotateCamera;
  35730. /**
  35731. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35732. */
  35733. wheelPrecision: number;
  35734. /**
  35735. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35736. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35737. */
  35738. wheelDeltaPercentage: number;
  35739. private _wheel;
  35740. private _observer;
  35741. /**
  35742. * Attach the input controls to a specific dom element to get the input from.
  35743. * @param element Defines the element the controls should be listened from
  35744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35745. */
  35746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35747. /**
  35748. * Detach the current controls from the specified dom element.
  35749. * @param element Defines the element to stop listening the inputs from
  35750. */
  35751. detachControl(element: Nullable<HTMLElement>): void;
  35752. /**
  35753. * Gets the class name of the current intput.
  35754. * @returns the class name
  35755. */
  35756. getClassName(): string;
  35757. /**
  35758. * Get the friendly name associated with the input class.
  35759. * @returns the input friendly name
  35760. */
  35761. getSimpleName(): string;
  35762. }
  35763. }
  35764. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35765. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35766. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35767. /**
  35768. * Default Inputs manager for the ArcRotateCamera.
  35769. * It groups all the default supported inputs for ease of use.
  35770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35771. */
  35772. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35773. /**
  35774. * Instantiates a new ArcRotateCameraInputsManager.
  35775. * @param camera Defines the camera the inputs belong to
  35776. */
  35777. constructor(camera: ArcRotateCamera);
  35778. /**
  35779. * Add mouse wheel input support to the input manager.
  35780. * @returns the current input manager
  35781. */
  35782. addMouseWheel(): ArcRotateCameraInputsManager;
  35783. /**
  35784. * Add pointers input support to the input manager.
  35785. * @returns the current input manager
  35786. */
  35787. addPointers(): ArcRotateCameraInputsManager;
  35788. /**
  35789. * Add keyboard input support to the input manager.
  35790. * @returns the current input manager
  35791. */
  35792. addKeyboard(): ArcRotateCameraInputsManager;
  35793. }
  35794. }
  35795. declare module "babylonjs/Cameras/arcRotateCamera" {
  35796. import { Observable } from "babylonjs/Misc/observable";
  35797. import { Nullable } from "babylonjs/types";
  35798. import { Scene } from "babylonjs/scene";
  35799. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35801. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35802. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35803. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35804. import { Camera } from "babylonjs/Cameras/camera";
  35805. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35806. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35807. import { Collider } from "babylonjs/Collisions/collider";
  35808. /**
  35809. * This represents an orbital type of camera.
  35810. *
  35811. * 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.
  35812. * 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.
  35813. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35814. */
  35815. export class ArcRotateCamera extends TargetCamera {
  35816. /**
  35817. * Defines the rotation angle of the camera along the longitudinal axis.
  35818. */
  35819. alpha: number;
  35820. /**
  35821. * Defines the rotation angle of the camera along the latitudinal axis.
  35822. */
  35823. beta: number;
  35824. /**
  35825. * Defines the radius of the camera from it s target point.
  35826. */
  35827. radius: number;
  35828. protected _target: Vector3;
  35829. protected _targetHost: Nullable<AbstractMesh>;
  35830. /**
  35831. * Defines the target point of the camera.
  35832. * The camera looks towards it form the radius distance.
  35833. */
  35834. target: Vector3;
  35835. /**
  35836. * Define the current local position of the camera in the scene
  35837. */
  35838. position: Vector3;
  35839. /**
  35840. * Current inertia value on the longitudinal axis.
  35841. * The bigger this number the longer it will take for the camera to stop.
  35842. */
  35843. inertialAlphaOffset: number;
  35844. /**
  35845. * Current inertia value on the latitudinal axis.
  35846. * The bigger this number the longer it will take for the camera to stop.
  35847. */
  35848. inertialBetaOffset: number;
  35849. /**
  35850. * Current inertia value on the radius axis.
  35851. * The bigger this number the longer it will take for the camera to stop.
  35852. */
  35853. inertialRadiusOffset: number;
  35854. /**
  35855. * Minimum allowed angle on the longitudinal axis.
  35856. * This can help limiting how the Camera is able to move in the scene.
  35857. */
  35858. lowerAlphaLimit: Nullable<number>;
  35859. /**
  35860. * Maximum allowed angle on the longitudinal axis.
  35861. * This can help limiting how the Camera is able to move in the scene.
  35862. */
  35863. upperAlphaLimit: Nullable<number>;
  35864. /**
  35865. * Minimum allowed angle on the latitudinal axis.
  35866. * This can help limiting how the Camera is able to move in the scene.
  35867. */
  35868. lowerBetaLimit: number;
  35869. /**
  35870. * Maximum allowed angle on the latitudinal axis.
  35871. * This can help limiting how the Camera is able to move in the scene.
  35872. */
  35873. upperBetaLimit: number;
  35874. /**
  35875. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35876. * This can help limiting how the Camera is able to move in the scene.
  35877. */
  35878. lowerRadiusLimit: Nullable<number>;
  35879. /**
  35880. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35881. * This can help limiting how the Camera is able to move in the scene.
  35882. */
  35883. upperRadiusLimit: Nullable<number>;
  35884. /**
  35885. * Defines the current inertia value used during panning of the camera along the X axis.
  35886. */
  35887. inertialPanningX: number;
  35888. /**
  35889. * Defines the current inertia value used during panning of the camera along the Y axis.
  35890. */
  35891. inertialPanningY: number;
  35892. /**
  35893. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35894. * Basically if your fingers moves away from more than this distance you will be considered
  35895. * in pinch mode.
  35896. */
  35897. pinchToPanMaxDistance: number;
  35898. /**
  35899. * Defines the maximum distance the camera can pan.
  35900. * This could help keeping the cammera always in your scene.
  35901. */
  35902. panningDistanceLimit: Nullable<number>;
  35903. /**
  35904. * Defines the target of the camera before paning.
  35905. */
  35906. panningOriginTarget: Vector3;
  35907. /**
  35908. * Defines the value of the inertia used during panning.
  35909. * 0 would mean stop inertia and one would mean no decelleration at all.
  35910. */
  35911. panningInertia: number;
  35912. /**
  35913. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35914. */
  35915. angularSensibilityX: number;
  35916. /**
  35917. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35918. */
  35919. angularSensibilityY: number;
  35920. /**
  35921. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35922. */
  35923. pinchPrecision: number;
  35924. /**
  35925. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35926. * It will be used instead of pinchDeltaPrecision if different from 0.
  35927. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35928. */
  35929. pinchDeltaPercentage: number;
  35930. /**
  35931. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35932. */
  35933. panningSensibility: number;
  35934. /**
  35935. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35936. */
  35937. keysUp: number[];
  35938. /**
  35939. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35940. */
  35941. keysDown: number[];
  35942. /**
  35943. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35944. */
  35945. keysLeft: number[];
  35946. /**
  35947. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35948. */
  35949. keysRight: number[];
  35950. /**
  35951. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35952. */
  35953. wheelPrecision: number;
  35954. /**
  35955. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35956. * It will be used instead of pinchDeltaPrecision if different from 0.
  35957. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35958. */
  35959. wheelDeltaPercentage: number;
  35960. /**
  35961. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35962. */
  35963. zoomOnFactor: number;
  35964. /**
  35965. * Defines a screen offset for the camera position.
  35966. */
  35967. targetScreenOffset: Vector2;
  35968. /**
  35969. * Allows the camera to be completely reversed.
  35970. * If false the camera can not arrive upside down.
  35971. */
  35972. allowUpsideDown: boolean;
  35973. /**
  35974. * Define if double tap/click is used to restore the previously saved state of the camera.
  35975. */
  35976. useInputToRestoreState: boolean;
  35977. /** @hidden */
  35978. _viewMatrix: Matrix;
  35979. /** @hidden */
  35980. _useCtrlForPanning: boolean;
  35981. /** @hidden */
  35982. _panningMouseButton: number;
  35983. /**
  35984. * Defines the input associated to the camera.
  35985. */
  35986. inputs: ArcRotateCameraInputsManager;
  35987. /** @hidden */
  35988. _reset: () => void;
  35989. /**
  35990. * Defines the allowed panning axis.
  35991. */
  35992. panningAxis: Vector3;
  35993. protected _localDirection: Vector3;
  35994. protected _transformedDirection: Vector3;
  35995. private _bouncingBehavior;
  35996. /**
  35997. * Gets the bouncing behavior of the camera if it has been enabled.
  35998. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35999. */
  36000. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36001. /**
  36002. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36003. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36004. */
  36005. useBouncingBehavior: boolean;
  36006. private _framingBehavior;
  36007. /**
  36008. * Gets the framing behavior of the camera if it has been enabled.
  36009. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36010. */
  36011. readonly framingBehavior: Nullable<FramingBehavior>;
  36012. /**
  36013. * Defines if the framing behavior of the camera is enabled on the camera.
  36014. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36015. */
  36016. useFramingBehavior: boolean;
  36017. private _autoRotationBehavior;
  36018. /**
  36019. * Gets the auto rotation behavior of the camera if it has been enabled.
  36020. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36021. */
  36022. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36023. /**
  36024. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36025. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36026. */
  36027. useAutoRotationBehavior: boolean;
  36028. /**
  36029. * Observable triggered when the mesh target has been changed on the camera.
  36030. */
  36031. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36032. /**
  36033. * Event raised when the camera is colliding with a mesh.
  36034. */
  36035. onCollide: (collidedMesh: AbstractMesh) => void;
  36036. /**
  36037. * Defines whether the camera should check collision with the objects oh the scene.
  36038. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36039. */
  36040. checkCollisions: boolean;
  36041. /**
  36042. * Defines the collision radius of the camera.
  36043. * This simulates a sphere around the camera.
  36044. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36045. */
  36046. collisionRadius: Vector3;
  36047. protected _collider: Collider;
  36048. protected _previousPosition: Vector3;
  36049. protected _collisionVelocity: Vector3;
  36050. protected _newPosition: Vector3;
  36051. protected _previousAlpha: number;
  36052. protected _previousBeta: number;
  36053. protected _previousRadius: number;
  36054. protected _collisionTriggered: boolean;
  36055. protected _targetBoundingCenter: Nullable<Vector3>;
  36056. private _computationVector;
  36057. private _tempAxisVector;
  36058. private _tempAxisRotationMatrix;
  36059. /**
  36060. * Instantiates a new ArcRotateCamera in a given scene
  36061. * @param name Defines the name of the camera
  36062. * @param alpha Defines the camera rotation along the logitudinal axis
  36063. * @param beta Defines the camera rotation along the latitudinal axis
  36064. * @param radius Defines the camera distance from its target
  36065. * @param target Defines the camera target
  36066. * @param scene Defines the scene the camera belongs to
  36067. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36068. */
  36069. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36070. /** @hidden */
  36071. _initCache(): void;
  36072. /** @hidden */
  36073. _updateCache(ignoreParentClass?: boolean): void;
  36074. protected _getTargetPosition(): Vector3;
  36075. private _storedAlpha;
  36076. private _storedBeta;
  36077. private _storedRadius;
  36078. private _storedTarget;
  36079. /**
  36080. * Stores the current state of the camera (alpha, beta, radius and target)
  36081. * @returns the camera itself
  36082. */
  36083. storeState(): Camera;
  36084. /**
  36085. * @hidden
  36086. * Restored camera state. You must call storeState() first
  36087. */
  36088. _restoreStateValues(): boolean;
  36089. /** @hidden */
  36090. _isSynchronizedViewMatrix(): boolean;
  36091. /**
  36092. * Attached controls to the current camera.
  36093. * @param element Defines the element the controls should be listened from
  36094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36095. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36096. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36097. */
  36098. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36099. /**
  36100. * Detach the current controls from the camera.
  36101. * The camera will stop reacting to inputs.
  36102. * @param element Defines the element to stop listening the inputs from
  36103. */
  36104. detachControl(element: HTMLElement): void;
  36105. /** @hidden */
  36106. _checkInputs(): void;
  36107. protected _checkLimits(): void;
  36108. /**
  36109. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36110. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  36111. */
  36112. rebuildAnglesAndRadius(updateView?: boolean): void;
  36113. /**
  36114. * Use a position to define the current camera related information like aplha, beta and radius
  36115. * @param position Defines the position to set the camera at
  36116. */
  36117. setPosition(position: Vector3): void;
  36118. /**
  36119. * Defines the target the camera should look at.
  36120. * This will automatically adapt alpha beta and radius to fit within the new target.
  36121. * @param target Defines the new target as a Vector or a mesh
  36122. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36123. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36124. */
  36125. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36126. /** @hidden */
  36127. _getViewMatrix(): Matrix;
  36128. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36129. /**
  36130. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36131. * @param meshes Defines the mesh to zoom on
  36132. * @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)
  36133. */
  36134. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36135. /**
  36136. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36137. * The target will be changed but the radius
  36138. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36139. * @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)
  36140. */
  36141. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36142. min: Vector3;
  36143. max: Vector3;
  36144. distance: number;
  36145. }, doNotUpdateMaxZ?: boolean): void;
  36146. /**
  36147. * @override
  36148. * Override Camera.createRigCamera
  36149. */
  36150. createRigCamera(name: string, cameraIndex: number): Camera;
  36151. /**
  36152. * @hidden
  36153. * @override
  36154. * Override Camera._updateRigCameras
  36155. */
  36156. _updateRigCameras(): void;
  36157. /**
  36158. * Destroy the camera and release the current resources hold by it.
  36159. */
  36160. dispose(): void;
  36161. /**
  36162. * Gets the current object class name.
  36163. * @return the class name
  36164. */
  36165. getClassName(): string;
  36166. }
  36167. }
  36168. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36169. import { Behavior } from "babylonjs/Behaviors/behavior";
  36170. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36171. /**
  36172. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36173. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36174. */
  36175. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36176. /**
  36177. * Gets the name of the behavior.
  36178. */
  36179. readonly name: string;
  36180. private _zoomStopsAnimation;
  36181. private _idleRotationSpeed;
  36182. private _idleRotationWaitTime;
  36183. private _idleRotationSpinupTime;
  36184. /**
  36185. * Sets the flag that indicates if user zooming should stop animation.
  36186. */
  36187. /**
  36188. * Gets the flag that indicates if user zooming should stop animation.
  36189. */
  36190. zoomStopsAnimation: boolean;
  36191. /**
  36192. * Sets the default speed at which the camera rotates around the model.
  36193. */
  36194. /**
  36195. * Gets the default speed at which the camera rotates around the model.
  36196. */
  36197. idleRotationSpeed: number;
  36198. /**
  36199. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36200. */
  36201. /**
  36202. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36203. */
  36204. idleRotationWaitTime: number;
  36205. /**
  36206. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36207. */
  36208. /**
  36209. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36210. */
  36211. idleRotationSpinupTime: number;
  36212. /**
  36213. * Gets a value indicating if the camera is currently rotating because of this behavior
  36214. */
  36215. readonly rotationInProgress: boolean;
  36216. private _onPrePointerObservableObserver;
  36217. private _onAfterCheckInputsObserver;
  36218. private _attachedCamera;
  36219. private _isPointerDown;
  36220. private _lastFrameTime;
  36221. private _lastInteractionTime;
  36222. private _cameraRotationSpeed;
  36223. /**
  36224. * Initializes the behavior.
  36225. */
  36226. init(): void;
  36227. /**
  36228. * Attaches the behavior to its arc rotate camera.
  36229. * @param camera Defines the camera to attach the behavior to
  36230. */
  36231. attach(camera: ArcRotateCamera): void;
  36232. /**
  36233. * Detaches the behavior from its current arc rotate camera.
  36234. */
  36235. detach(): void;
  36236. /**
  36237. * Returns true if user is scrolling.
  36238. * @return true if user is scrolling.
  36239. */
  36240. private _userIsZooming;
  36241. private _lastFrameRadius;
  36242. private _shouldAnimationStopForInteraction;
  36243. /**
  36244. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36245. */
  36246. private _applyUserInteraction;
  36247. private _userIsMoving;
  36248. }
  36249. }
  36250. declare module "babylonjs/Behaviors/Cameras/index" {
  36251. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36252. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36253. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36254. }
  36255. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36256. import { Mesh } from "babylonjs/Meshes/mesh";
  36257. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36258. import { Behavior } from "babylonjs/Behaviors/behavior";
  36259. /**
  36260. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36261. */
  36262. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36263. private ui;
  36264. /**
  36265. * The name of the behavior
  36266. */
  36267. name: string;
  36268. /**
  36269. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36270. */
  36271. distanceAwayFromFace: number;
  36272. /**
  36273. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36274. */
  36275. distanceAwayFromBottomOfFace: number;
  36276. private _faceVectors;
  36277. private _target;
  36278. private _scene;
  36279. private _onRenderObserver;
  36280. private _tmpMatrix;
  36281. private _tmpVector;
  36282. /**
  36283. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36284. * @param ui The transform node that should be attched to the mesh
  36285. */
  36286. constructor(ui: TransformNode);
  36287. /**
  36288. * Initializes the behavior
  36289. */
  36290. init(): void;
  36291. private _closestFace;
  36292. private _zeroVector;
  36293. private _lookAtTmpMatrix;
  36294. private _lookAtToRef;
  36295. /**
  36296. * Attaches the AttachToBoxBehavior to the passed in mesh
  36297. * @param target The mesh that the specified node will be attached to
  36298. */
  36299. attach(target: Mesh): void;
  36300. /**
  36301. * Detaches the behavior from the mesh
  36302. */
  36303. detach(): void;
  36304. }
  36305. }
  36306. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36307. import { Behavior } from "babylonjs/Behaviors/behavior";
  36308. import { Mesh } from "babylonjs/Meshes/mesh";
  36309. /**
  36310. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36311. */
  36312. export class FadeInOutBehavior implements Behavior<Mesh> {
  36313. /**
  36314. * Time in milliseconds to delay before fading in (Default: 0)
  36315. */
  36316. delay: number;
  36317. /**
  36318. * Time in milliseconds for the mesh to fade in (Default: 300)
  36319. */
  36320. fadeInTime: number;
  36321. private _millisecondsPerFrame;
  36322. private _hovered;
  36323. private _hoverValue;
  36324. private _ownerNode;
  36325. /**
  36326. * Instatiates the FadeInOutBehavior
  36327. */
  36328. constructor();
  36329. /**
  36330. * The name of the behavior
  36331. */
  36332. readonly name: string;
  36333. /**
  36334. * Initializes the behavior
  36335. */
  36336. init(): void;
  36337. /**
  36338. * Attaches the fade behavior on the passed in mesh
  36339. * @param ownerNode The mesh that will be faded in/out once attached
  36340. */
  36341. attach(ownerNode: Mesh): void;
  36342. /**
  36343. * Detaches the behavior from the mesh
  36344. */
  36345. detach(): void;
  36346. /**
  36347. * Triggers the mesh to begin fading in or out
  36348. * @param value if the object should fade in or out (true to fade in)
  36349. */
  36350. fadeIn(value: boolean): void;
  36351. private _update;
  36352. private _setAllVisibility;
  36353. }
  36354. }
  36355. declare module "babylonjs/Misc/pivotTools" {
  36356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36357. /**
  36358. * Class containing a set of static utilities functions for managing Pivots
  36359. * @hidden
  36360. */
  36361. export class PivotTools {
  36362. private static _PivotCached;
  36363. private static _OldPivotPoint;
  36364. private static _PivotTranslation;
  36365. private static _PivotTmpVector;
  36366. /** @hidden */
  36367. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36368. /** @hidden */
  36369. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36370. }
  36371. }
  36372. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36373. import { Scene } from "babylonjs/scene";
  36374. import { Vector4, Plane } from "babylonjs/Maths/math";
  36375. import { Mesh } from "babylonjs/Meshes/mesh";
  36376. /**
  36377. * Class containing static functions to help procedurally build meshes
  36378. */
  36379. export class PlaneBuilder {
  36380. /**
  36381. * Creates a plane mesh
  36382. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36383. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36384. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36388. * @param name defines the name of the mesh
  36389. * @param options defines the options used to create the mesh
  36390. * @param scene defines the hosting scene
  36391. * @returns the plane mesh
  36392. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36393. */
  36394. static CreatePlane(name: string, options: {
  36395. size?: number;
  36396. width?: number;
  36397. height?: number;
  36398. sideOrientation?: number;
  36399. frontUVs?: Vector4;
  36400. backUVs?: Vector4;
  36401. updatable?: boolean;
  36402. sourcePlane?: Plane;
  36403. }, scene: Scene): Mesh;
  36404. }
  36405. }
  36406. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36407. import { Behavior } from "babylonjs/Behaviors/behavior";
  36408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36409. import { Observable } from "babylonjs/Misc/observable";
  36410. import { Vector3 } from "babylonjs/Maths/math";
  36411. import { Ray } from "babylonjs/Culling/ray";
  36412. import "babylonjs/Meshes/Builders/planeBuilder";
  36413. /**
  36414. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36415. */
  36416. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36417. private static _AnyMouseID;
  36418. private _attachedNode;
  36419. private _dragPlane;
  36420. private _scene;
  36421. private _pointerObserver;
  36422. private _beforeRenderObserver;
  36423. private static _planeScene;
  36424. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36425. /**
  36426. * 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)
  36427. */
  36428. maxDragAngle: number;
  36429. /**
  36430. * @hidden
  36431. */
  36432. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36433. /**
  36434. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36435. */
  36436. currentDraggingPointerID: number;
  36437. /**
  36438. * The last position where the pointer hit the drag plane in world space
  36439. */
  36440. lastDragPosition: Vector3;
  36441. /**
  36442. * If the behavior is currently in a dragging state
  36443. */
  36444. dragging: boolean;
  36445. /**
  36446. * 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)
  36447. */
  36448. dragDeltaRatio: number;
  36449. /**
  36450. * If the drag plane orientation should be updated during the dragging (Default: true)
  36451. */
  36452. updateDragPlane: boolean;
  36453. private _debugMode;
  36454. private _moving;
  36455. /**
  36456. * Fires each time the attached mesh is dragged with the pointer
  36457. * * delta between last drag position and current drag position in world space
  36458. * * dragDistance along the drag axis
  36459. * * dragPlaneNormal normal of the current drag plane used during the drag
  36460. * * dragPlanePoint in world space where the drag intersects the drag plane
  36461. */
  36462. onDragObservable: Observable<{
  36463. delta: Vector3;
  36464. dragPlanePoint: Vector3;
  36465. dragPlaneNormal: Vector3;
  36466. dragDistance: number;
  36467. pointerId: number;
  36468. }>;
  36469. /**
  36470. * Fires each time a drag begins (eg. mouse down on mesh)
  36471. */
  36472. onDragStartObservable: Observable<{
  36473. dragPlanePoint: Vector3;
  36474. pointerId: number;
  36475. }>;
  36476. /**
  36477. * Fires each time a drag ends (eg. mouse release after drag)
  36478. */
  36479. onDragEndObservable: Observable<{
  36480. dragPlanePoint: Vector3;
  36481. pointerId: number;
  36482. }>;
  36483. /**
  36484. * If the attached mesh should be moved when dragged
  36485. */
  36486. moveAttached: boolean;
  36487. /**
  36488. * If the drag behavior will react to drag events (Default: true)
  36489. */
  36490. enabled: boolean;
  36491. /**
  36492. * If camera controls should be detached during the drag
  36493. */
  36494. detachCameraControls: boolean;
  36495. /**
  36496. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36497. */
  36498. useObjectOrienationForDragging: boolean;
  36499. private _options;
  36500. /**
  36501. * Creates a pointer drag behavior that can be attached to a mesh
  36502. * @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)
  36503. */
  36504. constructor(options?: {
  36505. dragAxis?: Vector3;
  36506. dragPlaneNormal?: Vector3;
  36507. });
  36508. /**
  36509. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36510. */
  36511. validateDrag: (targetPosition: Vector3) => boolean;
  36512. /**
  36513. * The name of the behavior
  36514. */
  36515. readonly name: string;
  36516. /**
  36517. * Initializes the behavior
  36518. */
  36519. init(): void;
  36520. private _tmpVector;
  36521. private _alternatePickedPoint;
  36522. private _worldDragAxis;
  36523. private _targetPosition;
  36524. private _attachedElement;
  36525. /**
  36526. * Attaches the drag behavior the passed in mesh
  36527. * @param ownerNode The mesh that will be dragged around once attached
  36528. */
  36529. attach(ownerNode: AbstractMesh): void;
  36530. /**
  36531. * Force relase the drag action by code.
  36532. */
  36533. releaseDrag(): void;
  36534. private _startDragRay;
  36535. private _lastPointerRay;
  36536. /**
  36537. * Simulates the start of a pointer drag event on the behavior
  36538. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36539. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36540. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36541. */
  36542. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36543. private _startDrag;
  36544. private _dragDelta;
  36545. private _moveDrag;
  36546. private _pickWithRayOnDragPlane;
  36547. private _pointA;
  36548. private _pointB;
  36549. private _pointC;
  36550. private _lineA;
  36551. private _lineB;
  36552. private _localAxis;
  36553. private _lookAt;
  36554. private _updateDragPlanePosition;
  36555. /**
  36556. * Detaches the behavior from the mesh
  36557. */
  36558. detach(): void;
  36559. }
  36560. }
  36561. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36562. import { Mesh } from "babylonjs/Meshes/mesh";
  36563. import { Behavior } from "babylonjs/Behaviors/behavior";
  36564. /**
  36565. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36566. */
  36567. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36568. private _dragBehaviorA;
  36569. private _dragBehaviorB;
  36570. private _startDistance;
  36571. private _initialScale;
  36572. private _targetScale;
  36573. private _ownerNode;
  36574. private _sceneRenderObserver;
  36575. /**
  36576. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36577. */
  36578. constructor();
  36579. /**
  36580. * The name of the behavior
  36581. */
  36582. readonly name: string;
  36583. /**
  36584. * Initializes the behavior
  36585. */
  36586. init(): void;
  36587. private _getCurrentDistance;
  36588. /**
  36589. * Attaches the scale behavior the passed in mesh
  36590. * @param ownerNode The mesh that will be scaled around once attached
  36591. */
  36592. attach(ownerNode: Mesh): void;
  36593. /**
  36594. * Detaches the behavior from the mesh
  36595. */
  36596. detach(): void;
  36597. }
  36598. }
  36599. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36600. import { Behavior } from "babylonjs/Behaviors/behavior";
  36601. import { Mesh } from "babylonjs/Meshes/mesh";
  36602. import { Observable } from "babylonjs/Misc/observable";
  36603. /**
  36604. * 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
  36605. */
  36606. export class SixDofDragBehavior implements Behavior<Mesh> {
  36607. private static _virtualScene;
  36608. private _ownerNode;
  36609. private _sceneRenderObserver;
  36610. private _scene;
  36611. private _targetPosition;
  36612. private _virtualOriginMesh;
  36613. private _virtualDragMesh;
  36614. private _pointerObserver;
  36615. private _moving;
  36616. private _startingOrientation;
  36617. /**
  36618. * 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)
  36619. */
  36620. private zDragFactor;
  36621. /**
  36622. * If the object should rotate to face the drag origin
  36623. */
  36624. rotateDraggedObject: boolean;
  36625. /**
  36626. * If the behavior is currently in a dragging state
  36627. */
  36628. dragging: boolean;
  36629. /**
  36630. * 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)
  36631. */
  36632. dragDeltaRatio: number;
  36633. /**
  36634. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36635. */
  36636. currentDraggingPointerID: number;
  36637. /**
  36638. * If camera controls should be detached during the drag
  36639. */
  36640. detachCameraControls: boolean;
  36641. /**
  36642. * Fires each time a drag starts
  36643. */
  36644. onDragStartObservable: Observable<{}>;
  36645. /**
  36646. * Fires each time a drag ends (eg. mouse release after drag)
  36647. */
  36648. onDragEndObservable: Observable<{}>;
  36649. /**
  36650. * 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
  36651. */
  36652. constructor();
  36653. /**
  36654. * The name of the behavior
  36655. */
  36656. readonly name: string;
  36657. /**
  36658. * Initializes the behavior
  36659. */
  36660. init(): void;
  36661. /**
  36662. * Attaches the scale behavior the passed in mesh
  36663. * @param ownerNode The mesh that will be scaled around once attached
  36664. */
  36665. attach(ownerNode: Mesh): void;
  36666. /**
  36667. * Detaches the behavior from the mesh
  36668. */
  36669. detach(): void;
  36670. }
  36671. }
  36672. declare module "babylonjs/Behaviors/Meshes/index" {
  36673. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36674. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36675. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36676. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36677. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36678. }
  36679. declare module "babylonjs/Behaviors/index" {
  36680. export * from "babylonjs/Behaviors/behavior";
  36681. export * from "babylonjs/Behaviors/Cameras/index";
  36682. export * from "babylonjs/Behaviors/Meshes/index";
  36683. }
  36684. declare module "babylonjs/Bones/boneIKController" {
  36685. import { Bone } from "babylonjs/Bones/bone";
  36686. import { Vector3 } from "babylonjs/Maths/math";
  36687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36688. import { Nullable } from "babylonjs/types";
  36689. /**
  36690. * Class used to apply inverse kinematics to bones
  36691. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36692. */
  36693. export class BoneIKController {
  36694. private static _tmpVecs;
  36695. private static _tmpQuat;
  36696. private static _tmpMats;
  36697. /**
  36698. * Gets or sets the target mesh
  36699. */
  36700. targetMesh: AbstractMesh;
  36701. /** Gets or sets the mesh used as pole */
  36702. poleTargetMesh: AbstractMesh;
  36703. /**
  36704. * Gets or sets the bone used as pole
  36705. */
  36706. poleTargetBone: Nullable<Bone>;
  36707. /**
  36708. * Gets or sets the target position
  36709. */
  36710. targetPosition: Vector3;
  36711. /**
  36712. * Gets or sets the pole target position
  36713. */
  36714. poleTargetPosition: Vector3;
  36715. /**
  36716. * Gets or sets the pole target local offset
  36717. */
  36718. poleTargetLocalOffset: Vector3;
  36719. /**
  36720. * Gets or sets the pole angle
  36721. */
  36722. poleAngle: number;
  36723. /**
  36724. * Gets or sets the mesh associated with the controller
  36725. */
  36726. mesh: AbstractMesh;
  36727. /**
  36728. * 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)
  36729. */
  36730. slerpAmount: number;
  36731. private _bone1Quat;
  36732. private _bone1Mat;
  36733. private _bone2Ang;
  36734. private _bone1;
  36735. private _bone2;
  36736. private _bone1Length;
  36737. private _bone2Length;
  36738. private _maxAngle;
  36739. private _maxReach;
  36740. private _rightHandedSystem;
  36741. private _bendAxis;
  36742. private _slerping;
  36743. private _adjustRoll;
  36744. /**
  36745. * Gets or sets maximum allowed angle
  36746. */
  36747. maxAngle: number;
  36748. /**
  36749. * Creates a new BoneIKController
  36750. * @param mesh defines the mesh to control
  36751. * @param bone defines the bone to control
  36752. * @param options defines options to set up the controller
  36753. */
  36754. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36755. targetMesh?: AbstractMesh;
  36756. poleTargetMesh?: AbstractMesh;
  36757. poleTargetBone?: Bone;
  36758. poleTargetLocalOffset?: Vector3;
  36759. poleAngle?: number;
  36760. bendAxis?: Vector3;
  36761. maxAngle?: number;
  36762. slerpAmount?: number;
  36763. });
  36764. private _setMaxAngle;
  36765. /**
  36766. * Force the controller to update the bones
  36767. */
  36768. update(): void;
  36769. }
  36770. }
  36771. declare module "babylonjs/Bones/boneLookController" {
  36772. import { Vector3, Space } from "babylonjs/Maths/math";
  36773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36774. import { Bone } from "babylonjs/Bones/bone";
  36775. /**
  36776. * Class used to make a bone look toward a point in space
  36777. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36778. */
  36779. export class BoneLookController {
  36780. private static _tmpVecs;
  36781. private static _tmpQuat;
  36782. private static _tmpMats;
  36783. /**
  36784. * The target Vector3 that the bone will look at
  36785. */
  36786. target: Vector3;
  36787. /**
  36788. * The mesh that the bone is attached to
  36789. */
  36790. mesh: AbstractMesh;
  36791. /**
  36792. * The bone that will be looking to the target
  36793. */
  36794. bone: Bone;
  36795. /**
  36796. * The up axis of the coordinate system that is used when the bone is rotated
  36797. */
  36798. upAxis: Vector3;
  36799. /**
  36800. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36801. */
  36802. upAxisSpace: Space;
  36803. /**
  36804. * Used to make an adjustment to the yaw of the bone
  36805. */
  36806. adjustYaw: number;
  36807. /**
  36808. * Used to make an adjustment to the pitch of the bone
  36809. */
  36810. adjustPitch: number;
  36811. /**
  36812. * Used to make an adjustment to the roll of the bone
  36813. */
  36814. adjustRoll: number;
  36815. /**
  36816. * 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)
  36817. */
  36818. slerpAmount: number;
  36819. private _minYaw;
  36820. private _maxYaw;
  36821. private _minPitch;
  36822. private _maxPitch;
  36823. private _minYawSin;
  36824. private _minYawCos;
  36825. private _maxYawSin;
  36826. private _maxYawCos;
  36827. private _midYawConstraint;
  36828. private _minPitchTan;
  36829. private _maxPitchTan;
  36830. private _boneQuat;
  36831. private _slerping;
  36832. private _transformYawPitch;
  36833. private _transformYawPitchInv;
  36834. private _firstFrameSkipped;
  36835. private _yawRange;
  36836. private _fowardAxis;
  36837. /**
  36838. * Gets or sets the minimum yaw angle that the bone can look to
  36839. */
  36840. minYaw: number;
  36841. /**
  36842. * Gets or sets the maximum yaw angle that the bone can look to
  36843. */
  36844. maxYaw: number;
  36845. /**
  36846. * Gets or sets the minimum pitch angle that the bone can look to
  36847. */
  36848. minPitch: number;
  36849. /**
  36850. * Gets or sets the maximum pitch angle that the bone can look to
  36851. */
  36852. maxPitch: number;
  36853. /**
  36854. * Create a BoneLookController
  36855. * @param mesh the mesh that the bone belongs to
  36856. * @param bone the bone that will be looking to the target
  36857. * @param target the target Vector3 to look at
  36858. * @param options optional settings:
  36859. * * maxYaw: the maximum angle the bone will yaw to
  36860. * * minYaw: the minimum angle the bone will yaw to
  36861. * * maxPitch: the maximum angle the bone will pitch to
  36862. * * minPitch: the minimum angle the bone will yaw to
  36863. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36864. * * upAxis: the up axis of the coordinate system
  36865. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36866. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36867. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36868. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36869. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36870. * * adjustRoll: used to make an adjustment to the roll of the bone
  36871. **/
  36872. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36873. maxYaw?: number;
  36874. minYaw?: number;
  36875. maxPitch?: number;
  36876. minPitch?: number;
  36877. slerpAmount?: number;
  36878. upAxis?: Vector3;
  36879. upAxisSpace?: Space;
  36880. yawAxis?: Vector3;
  36881. pitchAxis?: Vector3;
  36882. adjustYaw?: number;
  36883. adjustPitch?: number;
  36884. adjustRoll?: number;
  36885. });
  36886. /**
  36887. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36888. */
  36889. update(): void;
  36890. private _getAngleDiff;
  36891. private _getAngleBetween;
  36892. private _isAngleBetween;
  36893. }
  36894. }
  36895. declare module "babylonjs/Bones/index" {
  36896. export * from "babylonjs/Bones/bone";
  36897. export * from "babylonjs/Bones/boneIKController";
  36898. export * from "babylonjs/Bones/boneLookController";
  36899. export * from "babylonjs/Bones/skeleton";
  36900. }
  36901. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36902. import { Nullable } from "babylonjs/types";
  36903. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36904. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36905. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36906. /**
  36907. * Manage the gamepad inputs to control an arc rotate camera.
  36908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36909. */
  36910. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36911. /**
  36912. * Defines the camera the input is attached to.
  36913. */
  36914. camera: ArcRotateCamera;
  36915. /**
  36916. * Defines the gamepad the input is gathering event from.
  36917. */
  36918. gamepad: Nullable<Gamepad>;
  36919. /**
  36920. * Defines the gamepad rotation sensiblity.
  36921. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36922. */
  36923. gamepadRotationSensibility: number;
  36924. /**
  36925. * Defines the gamepad move sensiblity.
  36926. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36927. */
  36928. gamepadMoveSensibility: number;
  36929. private _onGamepadConnectedObserver;
  36930. private _onGamepadDisconnectedObserver;
  36931. /**
  36932. * Attach the input controls to a specific dom element to get the input from.
  36933. * @param element Defines the element the controls should be listened from
  36934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36935. */
  36936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36937. /**
  36938. * Detach the current controls from the specified dom element.
  36939. * @param element Defines the element to stop listening the inputs from
  36940. */
  36941. detachControl(element: Nullable<HTMLElement>): void;
  36942. /**
  36943. * Update the current camera state depending on the inputs that have been used this frame.
  36944. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36945. */
  36946. checkInputs(): void;
  36947. /**
  36948. * Gets the class name of the current intput.
  36949. * @returns the class name
  36950. */
  36951. getClassName(): string;
  36952. /**
  36953. * Get the friendly name associated with the input class.
  36954. * @returns the input friendly name
  36955. */
  36956. getSimpleName(): string;
  36957. }
  36958. }
  36959. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36960. import { Nullable } from "babylonjs/types";
  36961. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36962. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36963. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36964. interface ArcRotateCameraInputsManager {
  36965. /**
  36966. * Add orientation input support to the input manager.
  36967. * @returns the current input manager
  36968. */
  36969. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36970. }
  36971. }
  36972. /**
  36973. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36974. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36975. */
  36976. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36977. /**
  36978. * Defines the camera the input is attached to.
  36979. */
  36980. camera: ArcRotateCamera;
  36981. /**
  36982. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36983. */
  36984. alphaCorrection: number;
  36985. /**
  36986. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36987. */
  36988. gammaCorrection: number;
  36989. private _alpha;
  36990. private _gamma;
  36991. private _dirty;
  36992. private _deviceOrientationHandler;
  36993. /**
  36994. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36995. */
  36996. constructor();
  36997. /**
  36998. * Attach the input controls to a specific dom element to get the input from.
  36999. * @param element Defines the element the controls should be listened from
  37000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37001. */
  37002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37003. /** @hidden */
  37004. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37005. /**
  37006. * Update the current camera state depending on the inputs that have been used this frame.
  37007. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37008. */
  37009. checkInputs(): void;
  37010. /**
  37011. * Detach the current controls from the specified dom element.
  37012. * @param element Defines the element to stop listening the inputs from
  37013. */
  37014. detachControl(element: Nullable<HTMLElement>): void;
  37015. /**
  37016. * Gets the class name of the current intput.
  37017. * @returns the class name
  37018. */
  37019. getClassName(): string;
  37020. /**
  37021. * Get the friendly name associated with the input class.
  37022. * @returns the input friendly name
  37023. */
  37024. getSimpleName(): string;
  37025. }
  37026. }
  37027. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37028. import { Nullable } from "babylonjs/types";
  37029. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37030. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37031. /**
  37032. * Listen to mouse events to control the camera.
  37033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37034. */
  37035. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37036. /**
  37037. * Defines the camera the input is attached to.
  37038. */
  37039. camera: FlyCamera;
  37040. /**
  37041. * Defines if touch is enabled. (Default is true.)
  37042. */
  37043. touchEnabled: boolean;
  37044. /**
  37045. * Defines the buttons associated with the input to handle camera rotation.
  37046. */
  37047. buttons: number[];
  37048. /**
  37049. * Assign buttons for Yaw control.
  37050. */
  37051. buttonsYaw: number[];
  37052. /**
  37053. * Assign buttons for Pitch control.
  37054. */
  37055. buttonsPitch: number[];
  37056. /**
  37057. * Assign buttons for Roll control.
  37058. */
  37059. buttonsRoll: number[];
  37060. /**
  37061. * Detect if any button is being pressed while mouse is moved.
  37062. * -1 = Mouse locked.
  37063. * 0 = Left button.
  37064. * 1 = Middle Button.
  37065. * 2 = Right Button.
  37066. */
  37067. activeButton: number;
  37068. /**
  37069. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37070. * Higher values reduce its sensitivity.
  37071. */
  37072. angularSensibility: number;
  37073. private _mousemoveCallback;
  37074. private _observer;
  37075. private _rollObserver;
  37076. private previousPosition;
  37077. private noPreventDefault;
  37078. private element;
  37079. /**
  37080. * Listen to mouse events to control the camera.
  37081. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37083. */
  37084. constructor(touchEnabled?: boolean);
  37085. /**
  37086. * Attach the mouse control to the HTML DOM element.
  37087. * @param element Defines the element that listens to the input events.
  37088. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37089. */
  37090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37091. /**
  37092. * Detach the current controls from the specified dom element.
  37093. * @param element Defines the element to stop listening the inputs from
  37094. */
  37095. detachControl(element: Nullable<HTMLElement>): void;
  37096. /**
  37097. * Gets the class name of the current input.
  37098. * @returns the class name.
  37099. */
  37100. getClassName(): string;
  37101. /**
  37102. * Get the friendly name associated with the input class.
  37103. * @returns the input's friendly name.
  37104. */
  37105. getSimpleName(): string;
  37106. private _pointerInput;
  37107. private _onMouseMove;
  37108. /**
  37109. * Rotate camera by mouse offset.
  37110. */
  37111. private rotateCamera;
  37112. }
  37113. }
  37114. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37115. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37116. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37117. /**
  37118. * Default Inputs manager for the FlyCamera.
  37119. * It groups all the default supported inputs for ease of use.
  37120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37121. */
  37122. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37123. /**
  37124. * Instantiates a new FlyCameraInputsManager.
  37125. * @param camera Defines the camera the inputs belong to.
  37126. */
  37127. constructor(camera: FlyCamera);
  37128. /**
  37129. * Add keyboard input support to the input manager.
  37130. * @returns the new FlyCameraKeyboardMoveInput().
  37131. */
  37132. addKeyboard(): FlyCameraInputsManager;
  37133. /**
  37134. * Add mouse input support to the input manager.
  37135. * @param touchEnabled Enable touch screen support.
  37136. * @returns the new FlyCameraMouseInput().
  37137. */
  37138. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37139. }
  37140. }
  37141. declare module "babylonjs/Cameras/flyCamera" {
  37142. import { Scene } from "babylonjs/scene";
  37143. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37145. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37146. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37147. /**
  37148. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37149. * such as in a 3D Space Shooter or a Flight Simulator.
  37150. */
  37151. export class FlyCamera extends TargetCamera {
  37152. /**
  37153. * Define the collision ellipsoid of the camera.
  37154. * This is helpful for simulating a camera body, like a player's body.
  37155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37156. */
  37157. ellipsoid: Vector3;
  37158. /**
  37159. * Define an offset for the position of the ellipsoid around the camera.
  37160. * This can be helpful if the camera is attached away from the player's body center,
  37161. * such as at its head.
  37162. */
  37163. ellipsoidOffset: Vector3;
  37164. /**
  37165. * Enable or disable collisions of the camera with the rest of the scene objects.
  37166. */
  37167. checkCollisions: boolean;
  37168. /**
  37169. * Enable or disable gravity on the camera.
  37170. */
  37171. applyGravity: boolean;
  37172. /**
  37173. * Define the current direction the camera is moving to.
  37174. */
  37175. cameraDirection: Vector3;
  37176. /**
  37177. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37178. * This overrides and empties cameraRotation.
  37179. */
  37180. rotationQuaternion: Quaternion;
  37181. /**
  37182. * Track Roll to maintain the wanted Rolling when looking around.
  37183. */
  37184. _trackRoll: number;
  37185. /**
  37186. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37187. */
  37188. rollCorrect: number;
  37189. /**
  37190. * Mimic a banked turn, Rolling the camera when Yawing.
  37191. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37192. */
  37193. bankedTurn: boolean;
  37194. /**
  37195. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37196. */
  37197. bankedTurnLimit: number;
  37198. /**
  37199. * Value of 0 disables the banked Roll.
  37200. * Value of 1 is equal to the Yaw angle in radians.
  37201. */
  37202. bankedTurnMultiplier: number;
  37203. /**
  37204. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37205. */
  37206. inputs: FlyCameraInputsManager;
  37207. /**
  37208. * Gets the input sensibility for mouse input.
  37209. * Higher values reduce sensitivity.
  37210. */
  37211. /**
  37212. * Sets the input sensibility for a mouse input.
  37213. * Higher values reduce sensitivity.
  37214. */
  37215. angularSensibility: number;
  37216. /**
  37217. * Get the keys for camera movement forward.
  37218. */
  37219. /**
  37220. * Set the keys for camera movement forward.
  37221. */
  37222. keysForward: number[];
  37223. /**
  37224. * Get the keys for camera movement backward.
  37225. */
  37226. keysBackward: number[];
  37227. /**
  37228. * Get the keys for camera movement up.
  37229. */
  37230. /**
  37231. * Set the keys for camera movement up.
  37232. */
  37233. keysUp: number[];
  37234. /**
  37235. * Get the keys for camera movement down.
  37236. */
  37237. /**
  37238. * Set the keys for camera movement down.
  37239. */
  37240. keysDown: number[];
  37241. /**
  37242. * Get the keys for camera movement left.
  37243. */
  37244. /**
  37245. * Set the keys for camera movement left.
  37246. */
  37247. keysLeft: number[];
  37248. /**
  37249. * Set the keys for camera movement right.
  37250. */
  37251. /**
  37252. * Set the keys for camera movement right.
  37253. */
  37254. keysRight: number[];
  37255. /**
  37256. * Event raised when the camera collides with a mesh in the scene.
  37257. */
  37258. onCollide: (collidedMesh: AbstractMesh) => void;
  37259. private _collider;
  37260. private _needMoveForGravity;
  37261. private _oldPosition;
  37262. private _diffPosition;
  37263. private _newPosition;
  37264. /** @hidden */
  37265. _localDirection: Vector3;
  37266. /** @hidden */
  37267. _transformedDirection: Vector3;
  37268. /**
  37269. * Instantiates a FlyCamera.
  37270. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37271. * such as in a 3D Space Shooter or a Flight Simulator.
  37272. * @param name Define the name of the camera in the scene.
  37273. * @param position Define the starting position of the camera in the scene.
  37274. * @param scene Define the scene the camera belongs to.
  37275. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37276. */
  37277. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37278. /**
  37279. * Attach a control to the HTML DOM element.
  37280. * @param element Defines the element that listens to the input events.
  37281. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37282. */
  37283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37284. /**
  37285. * Detach a control from the HTML DOM element.
  37286. * The camera will stop reacting to that input.
  37287. * @param element Defines the element that listens to the input events.
  37288. */
  37289. detachControl(element: HTMLElement): void;
  37290. private _collisionMask;
  37291. /**
  37292. * Get the mask that the camera ignores in collision events.
  37293. */
  37294. /**
  37295. * Set the mask that the camera ignores in collision events.
  37296. */
  37297. collisionMask: number;
  37298. /** @hidden */
  37299. _collideWithWorld(displacement: Vector3): void;
  37300. /** @hidden */
  37301. private _onCollisionPositionChange;
  37302. /** @hidden */
  37303. _checkInputs(): void;
  37304. /** @hidden */
  37305. _decideIfNeedsToMove(): boolean;
  37306. /** @hidden */
  37307. _updatePosition(): void;
  37308. /**
  37309. * Restore the Roll to its target value at the rate specified.
  37310. * @param rate - Higher means slower restoring.
  37311. * @hidden
  37312. */
  37313. restoreRoll(rate: number): void;
  37314. /**
  37315. * Destroy the camera and release the current resources held by it.
  37316. */
  37317. dispose(): void;
  37318. /**
  37319. * Get the current object class name.
  37320. * @returns the class name.
  37321. */
  37322. getClassName(): string;
  37323. }
  37324. }
  37325. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37326. import { Nullable } from "babylonjs/types";
  37327. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37328. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37329. /**
  37330. * Listen to keyboard events to control the camera.
  37331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37332. */
  37333. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37334. /**
  37335. * Defines the camera the input is attached to.
  37336. */
  37337. camera: FlyCamera;
  37338. /**
  37339. * The list of keyboard keys used to control the forward move of the camera.
  37340. */
  37341. keysForward: number[];
  37342. /**
  37343. * The list of keyboard keys used to control the backward move of the camera.
  37344. */
  37345. keysBackward: number[];
  37346. /**
  37347. * The list of keyboard keys used to control the forward move of the camera.
  37348. */
  37349. keysUp: number[];
  37350. /**
  37351. * The list of keyboard keys used to control the backward move of the camera.
  37352. */
  37353. keysDown: number[];
  37354. /**
  37355. * The list of keyboard keys used to control the right strafe move of the camera.
  37356. */
  37357. keysRight: number[];
  37358. /**
  37359. * The list of keyboard keys used to control the left strafe move of the camera.
  37360. */
  37361. keysLeft: number[];
  37362. private _keys;
  37363. private _onCanvasBlurObserver;
  37364. private _onKeyboardObserver;
  37365. private _engine;
  37366. private _scene;
  37367. /**
  37368. * Attach the input controls to a specific dom element to get the input from.
  37369. * @param element Defines the element the controls should be listened from
  37370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37371. */
  37372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37373. /**
  37374. * Detach the current controls from the specified dom element.
  37375. * @param element Defines the element to stop listening the inputs from
  37376. */
  37377. detachControl(element: Nullable<HTMLElement>): void;
  37378. /**
  37379. * Gets the class name of the current intput.
  37380. * @returns the class name
  37381. */
  37382. getClassName(): string;
  37383. /** @hidden */
  37384. _onLostFocus(e: FocusEvent): void;
  37385. /**
  37386. * Get the friendly name associated with the input class.
  37387. * @returns the input friendly name
  37388. */
  37389. getSimpleName(): string;
  37390. /**
  37391. * Update the current camera state depending on the inputs that have been used this frame.
  37392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37393. */
  37394. checkInputs(): void;
  37395. }
  37396. }
  37397. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37398. import { Nullable } from "babylonjs/types";
  37399. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37400. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37401. /**
  37402. * Manage the mouse wheel inputs to control a follow camera.
  37403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37404. */
  37405. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37406. /**
  37407. * Defines the camera the input is attached to.
  37408. */
  37409. camera: FollowCamera;
  37410. /**
  37411. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37412. */
  37413. axisControlRadius: boolean;
  37414. /**
  37415. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37416. */
  37417. axisControlHeight: boolean;
  37418. /**
  37419. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37420. */
  37421. axisControlRotation: boolean;
  37422. /**
  37423. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37424. * relation to mouseWheel events.
  37425. */
  37426. wheelPrecision: number;
  37427. /**
  37428. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37429. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37430. */
  37431. wheelDeltaPercentage: number;
  37432. private _wheel;
  37433. private _observer;
  37434. /**
  37435. * Attach the input controls to a specific dom element to get the input from.
  37436. * @param element Defines the element the controls should be listened from
  37437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37438. */
  37439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37440. /**
  37441. * Detach the current controls from the specified dom element.
  37442. * @param element Defines the element to stop listening the inputs from
  37443. */
  37444. detachControl(element: Nullable<HTMLElement>): void;
  37445. /**
  37446. * Gets the class name of the current intput.
  37447. * @returns the class name
  37448. */
  37449. getClassName(): string;
  37450. /**
  37451. * Get the friendly name associated with the input class.
  37452. * @returns the input friendly name
  37453. */
  37454. getSimpleName(): string;
  37455. }
  37456. }
  37457. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37458. import { Nullable } from "babylonjs/types";
  37459. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37460. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37461. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37462. /**
  37463. * Manage the pointers inputs to control an follow camera.
  37464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37465. */
  37466. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37467. /**
  37468. * Defines the camera the input is attached to.
  37469. */
  37470. camera: FollowCamera;
  37471. /**
  37472. * Gets the class name of the current input.
  37473. * @returns the class name
  37474. */
  37475. getClassName(): string;
  37476. /**
  37477. * Defines the pointer angular sensibility along the X axis or how fast is
  37478. * the camera rotating.
  37479. * A negative number will reverse the axis direction.
  37480. */
  37481. angularSensibilityX: number;
  37482. /**
  37483. * Defines the pointer angular sensibility along the Y axis or how fast is
  37484. * the camera rotating.
  37485. * A negative number will reverse the axis direction.
  37486. */
  37487. angularSensibilityY: number;
  37488. /**
  37489. * Defines the pointer pinch precision or how fast is the camera zooming.
  37490. * A negative number will reverse the axis direction.
  37491. */
  37492. pinchPrecision: number;
  37493. /**
  37494. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37495. * from 0.
  37496. * It defines the percentage of current camera.radius to use as delta when
  37497. * pinch zoom is used.
  37498. */
  37499. pinchDeltaPercentage: number;
  37500. /**
  37501. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37502. */
  37503. axisXControlRadius: boolean;
  37504. /**
  37505. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37506. */
  37507. axisXControlHeight: boolean;
  37508. /**
  37509. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37510. */
  37511. axisXControlRotation: boolean;
  37512. /**
  37513. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37514. */
  37515. axisYControlRadius: boolean;
  37516. /**
  37517. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37518. */
  37519. axisYControlHeight: boolean;
  37520. /**
  37521. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37522. */
  37523. axisYControlRotation: boolean;
  37524. /**
  37525. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37526. */
  37527. axisPinchControlRadius: boolean;
  37528. /**
  37529. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37530. */
  37531. axisPinchControlHeight: boolean;
  37532. /**
  37533. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37534. */
  37535. axisPinchControlRotation: boolean;
  37536. /**
  37537. * Log error messages if basic misconfiguration has occurred.
  37538. */
  37539. warningEnable: boolean;
  37540. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37541. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37542. private _warningCounter;
  37543. private _warning;
  37544. }
  37545. }
  37546. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37547. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37548. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37549. /**
  37550. * Default Inputs manager for the FollowCamera.
  37551. * It groups all the default supported inputs for ease of use.
  37552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37553. */
  37554. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37555. /**
  37556. * Instantiates a new FollowCameraInputsManager.
  37557. * @param camera Defines the camera the inputs belong to
  37558. */
  37559. constructor(camera: FollowCamera);
  37560. /**
  37561. * Add keyboard input support to the input manager.
  37562. * @returns the current input manager
  37563. */
  37564. addKeyboard(): FollowCameraInputsManager;
  37565. /**
  37566. * Add mouse wheel input support to the input manager.
  37567. * @returns the current input manager
  37568. */
  37569. addMouseWheel(): FollowCameraInputsManager;
  37570. /**
  37571. * Add pointers input support to the input manager.
  37572. * @returns the current input manager
  37573. */
  37574. addPointers(): FollowCameraInputsManager;
  37575. /**
  37576. * Add orientation input support to the input manager.
  37577. * @returns the current input manager
  37578. */
  37579. addVRDeviceOrientation(): FollowCameraInputsManager;
  37580. }
  37581. }
  37582. declare module "babylonjs/Cameras/followCamera" {
  37583. import { Nullable } from "babylonjs/types";
  37584. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37585. import { Scene } from "babylonjs/scene";
  37586. import { Vector3 } from "babylonjs/Maths/math";
  37587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37588. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37589. /**
  37590. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37591. * an arc rotate version arcFollowCamera are available.
  37592. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37593. */
  37594. export class FollowCamera extends TargetCamera {
  37595. /**
  37596. * Distance the follow camera should follow an object at
  37597. */
  37598. radius: number;
  37599. /**
  37600. * Minimum allowed distance of the camera to the axis of rotation
  37601. * (The camera can not get closer).
  37602. * This can help limiting how the Camera is able to move in the scene.
  37603. */
  37604. lowerRadiusLimit: Nullable<number>;
  37605. /**
  37606. * Maximum allowed distance of the camera to the axis of rotation
  37607. * (The camera can not get further).
  37608. * This can help limiting how the Camera is able to move in the scene.
  37609. */
  37610. upperRadiusLimit: Nullable<number>;
  37611. /**
  37612. * Define a rotation offset between the camera and the object it follows
  37613. */
  37614. rotationOffset: number;
  37615. /**
  37616. * Minimum allowed angle to camera position relative to target object.
  37617. * This can help limiting how the Camera is able to move in the scene.
  37618. */
  37619. lowerRotationOffsetLimit: Nullable<number>;
  37620. /**
  37621. * Maximum allowed angle to camera position relative to target object.
  37622. * This can help limiting how the Camera is able to move in the scene.
  37623. */
  37624. upperRotationOffsetLimit: Nullable<number>;
  37625. /**
  37626. * Define a height offset between the camera and the object it follows.
  37627. * It can help following an object from the top (like a car chaing a plane)
  37628. */
  37629. heightOffset: number;
  37630. /**
  37631. * Minimum allowed height of camera position relative to target object.
  37632. * This can help limiting how the Camera is able to move in the scene.
  37633. */
  37634. lowerHeightOffsetLimit: Nullable<number>;
  37635. /**
  37636. * Maximum allowed height of camera position relative to target object.
  37637. * This can help limiting how the Camera is able to move in the scene.
  37638. */
  37639. upperHeightOffsetLimit: Nullable<number>;
  37640. /**
  37641. * Define how fast the camera can accelerate to follow it s target.
  37642. */
  37643. cameraAcceleration: number;
  37644. /**
  37645. * Define the speed limit of the camera following an object.
  37646. */
  37647. maxCameraSpeed: number;
  37648. /**
  37649. * Define the target of the camera.
  37650. */
  37651. lockedTarget: Nullable<AbstractMesh>;
  37652. /**
  37653. * Defines the input associated with the camera.
  37654. */
  37655. inputs: FollowCameraInputsManager;
  37656. /**
  37657. * Instantiates the follow camera.
  37658. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37659. * @param name Define the name of the camera in the scene
  37660. * @param position Define the position of the camera
  37661. * @param scene Define the scene the camera belong to
  37662. * @param lockedTarget Define the target of the camera
  37663. */
  37664. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37665. private _follow;
  37666. /**
  37667. * Attached controls to the current camera.
  37668. * @param element Defines the element the controls should be listened from
  37669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37670. */
  37671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37672. /**
  37673. * Detach the current controls from the camera.
  37674. * The camera will stop reacting to inputs.
  37675. * @param element Defines the element to stop listening the inputs from
  37676. */
  37677. detachControl(element: HTMLElement): void;
  37678. /** @hidden */
  37679. _checkInputs(): void;
  37680. private _checkLimits;
  37681. /**
  37682. * Gets the camera class name.
  37683. * @returns the class name
  37684. */
  37685. getClassName(): string;
  37686. }
  37687. /**
  37688. * Arc Rotate version of the follow camera.
  37689. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37690. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37691. */
  37692. export class ArcFollowCamera extends TargetCamera {
  37693. /** The longitudinal angle of the camera */
  37694. alpha: number;
  37695. /** The latitudinal angle of the camera */
  37696. beta: number;
  37697. /** The radius of the camera from its target */
  37698. radius: number;
  37699. /** Define the camera target (the messh it should follow) */
  37700. target: Nullable<AbstractMesh>;
  37701. private _cartesianCoordinates;
  37702. /**
  37703. * Instantiates a new ArcFollowCamera
  37704. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37705. * @param name Define the name of the camera
  37706. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37707. * @param beta Define the rotation angle of the camera around the elevation axis
  37708. * @param radius Define the radius of the camera from its target point
  37709. * @param target Define the target of the camera
  37710. * @param scene Define the scene the camera belongs to
  37711. */
  37712. constructor(name: string,
  37713. /** The longitudinal angle of the camera */
  37714. alpha: number,
  37715. /** The latitudinal angle of the camera */
  37716. beta: number,
  37717. /** The radius of the camera from its target */
  37718. radius: number,
  37719. /** Define the camera target (the messh it should follow) */
  37720. target: Nullable<AbstractMesh>, scene: Scene);
  37721. private _follow;
  37722. /** @hidden */
  37723. _checkInputs(): void;
  37724. /**
  37725. * Returns the class name of the object.
  37726. * It is mostly used internally for serialization purposes.
  37727. */
  37728. getClassName(): string;
  37729. }
  37730. }
  37731. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37732. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37733. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37734. import { Nullable } from "babylonjs/types";
  37735. /**
  37736. * Manage the keyboard inputs to control the movement of a follow camera.
  37737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37738. */
  37739. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37740. /**
  37741. * Defines the camera the input is attached to.
  37742. */
  37743. camera: FollowCamera;
  37744. /**
  37745. * Defines the list of key codes associated with the up action (increase heightOffset)
  37746. */
  37747. keysHeightOffsetIncr: number[];
  37748. /**
  37749. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37750. */
  37751. keysHeightOffsetDecr: number[];
  37752. /**
  37753. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37754. */
  37755. keysHeightOffsetModifierAlt: boolean;
  37756. /**
  37757. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37758. */
  37759. keysHeightOffsetModifierCtrl: boolean;
  37760. /**
  37761. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37762. */
  37763. keysHeightOffsetModifierShift: boolean;
  37764. /**
  37765. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37766. */
  37767. keysRotationOffsetIncr: number[];
  37768. /**
  37769. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37770. */
  37771. keysRotationOffsetDecr: number[];
  37772. /**
  37773. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37774. */
  37775. keysRotationOffsetModifierAlt: boolean;
  37776. /**
  37777. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37778. */
  37779. keysRotationOffsetModifierCtrl: boolean;
  37780. /**
  37781. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37782. */
  37783. keysRotationOffsetModifierShift: boolean;
  37784. /**
  37785. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37786. */
  37787. keysRadiusIncr: number[];
  37788. /**
  37789. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37790. */
  37791. keysRadiusDecr: number[];
  37792. /**
  37793. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37794. */
  37795. keysRadiusModifierAlt: boolean;
  37796. /**
  37797. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37798. */
  37799. keysRadiusModifierCtrl: boolean;
  37800. /**
  37801. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37802. */
  37803. keysRadiusModifierShift: boolean;
  37804. /**
  37805. * Defines the rate of change of heightOffset.
  37806. */
  37807. heightSensibility: number;
  37808. /**
  37809. * Defines the rate of change of rotationOffset.
  37810. */
  37811. rotationSensibility: number;
  37812. /**
  37813. * Defines the rate of change of radius.
  37814. */
  37815. radiusSensibility: number;
  37816. private _keys;
  37817. private _ctrlPressed;
  37818. private _altPressed;
  37819. private _shiftPressed;
  37820. private _onCanvasBlurObserver;
  37821. private _onKeyboardObserver;
  37822. private _engine;
  37823. private _scene;
  37824. /**
  37825. * Attach the input controls to a specific dom element to get the input from.
  37826. * @param element Defines the element the controls should be listened from
  37827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37828. */
  37829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37830. /**
  37831. * Detach the current controls from the specified dom element.
  37832. * @param element Defines the element to stop listening the inputs from
  37833. */
  37834. detachControl(element: Nullable<HTMLElement>): void;
  37835. /**
  37836. * Update the current camera state depending on the inputs that have been used this frame.
  37837. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37838. */
  37839. checkInputs(): void;
  37840. /**
  37841. * Gets the class name of the current input.
  37842. * @returns the class name
  37843. */
  37844. getClassName(): string;
  37845. /**
  37846. * Get the friendly name associated with the input class.
  37847. * @returns the input friendly name
  37848. */
  37849. getSimpleName(): string;
  37850. /**
  37851. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37852. * allow modification of the heightOffset value.
  37853. */
  37854. private _modifierHeightOffset;
  37855. /**
  37856. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37857. * allow modification of the rotationOffset value.
  37858. */
  37859. private _modifierRotationOffset;
  37860. /**
  37861. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37862. * allow modification of the radius value.
  37863. */
  37864. private _modifierRadius;
  37865. }
  37866. }
  37867. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37868. import { Nullable } from "babylonjs/types";
  37869. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37870. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37871. module "babylonjs/Cameras/freeCameraInputsManager" {
  37872. interface FreeCameraInputsManager {
  37873. /**
  37874. * Add orientation input support to the input manager.
  37875. * @returns the current input manager
  37876. */
  37877. addDeviceOrientation(): FreeCameraInputsManager;
  37878. }
  37879. }
  37880. /**
  37881. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37882. * Screen rotation is taken into account.
  37883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37884. */
  37885. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37886. private _camera;
  37887. private _screenOrientationAngle;
  37888. private _constantTranform;
  37889. private _screenQuaternion;
  37890. private _alpha;
  37891. private _beta;
  37892. private _gamma;
  37893. /**
  37894. * Instantiates a new input
  37895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37896. */
  37897. constructor();
  37898. /**
  37899. * Define the camera controlled by the input.
  37900. */
  37901. camera: FreeCamera;
  37902. /**
  37903. * Attach the input controls to a specific dom element to get the input from.
  37904. * @param element Defines the element the controls should be listened from
  37905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37906. */
  37907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37908. private _orientationChanged;
  37909. private _deviceOrientation;
  37910. /**
  37911. * Detach the current controls from the specified dom element.
  37912. * @param element Defines the element to stop listening the inputs from
  37913. */
  37914. detachControl(element: Nullable<HTMLElement>): void;
  37915. /**
  37916. * Update the current camera state depending on the inputs that have been used this frame.
  37917. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37918. */
  37919. checkInputs(): void;
  37920. /**
  37921. * Gets the class name of the current intput.
  37922. * @returns the class name
  37923. */
  37924. getClassName(): string;
  37925. /**
  37926. * Get the friendly name associated with the input class.
  37927. * @returns the input friendly name
  37928. */
  37929. getSimpleName(): string;
  37930. }
  37931. }
  37932. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37933. import { Nullable } from "babylonjs/types";
  37934. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37935. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37936. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37937. /**
  37938. * Manage the gamepad inputs to control a free camera.
  37939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37940. */
  37941. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37942. /**
  37943. * Define the camera the input is attached to.
  37944. */
  37945. camera: FreeCamera;
  37946. /**
  37947. * Define the Gamepad controlling the input
  37948. */
  37949. gamepad: Nullable<Gamepad>;
  37950. /**
  37951. * Defines the gamepad rotation sensiblity.
  37952. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37953. */
  37954. gamepadAngularSensibility: number;
  37955. /**
  37956. * Defines the gamepad move sensiblity.
  37957. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37958. */
  37959. gamepadMoveSensibility: number;
  37960. private _onGamepadConnectedObserver;
  37961. private _onGamepadDisconnectedObserver;
  37962. private _cameraTransform;
  37963. private _deltaTransform;
  37964. private _vector3;
  37965. private _vector2;
  37966. /**
  37967. * Attach the input controls to a specific dom element to get the input from.
  37968. * @param element Defines the element the controls should be listened from
  37969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37970. */
  37971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37972. /**
  37973. * Detach the current controls from the specified dom element.
  37974. * @param element Defines the element to stop listening the inputs from
  37975. */
  37976. detachControl(element: Nullable<HTMLElement>): void;
  37977. /**
  37978. * Update the current camera state depending on the inputs that have been used this frame.
  37979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37980. */
  37981. checkInputs(): void;
  37982. /**
  37983. * Gets the class name of the current intput.
  37984. * @returns the class name
  37985. */
  37986. getClassName(): string;
  37987. /**
  37988. * Get the friendly name associated with the input class.
  37989. * @returns the input friendly name
  37990. */
  37991. getSimpleName(): string;
  37992. }
  37993. }
  37994. declare module "babylonjs/Misc/virtualJoystick" {
  37995. import { Nullable } from "babylonjs/types";
  37996. import { Vector3 } from "babylonjs/Maths/math";
  37997. /**
  37998. * Defines the potential axis of a Joystick
  37999. */
  38000. export enum JoystickAxis {
  38001. /** X axis */
  38002. X = 0,
  38003. /** Y axis */
  38004. Y = 1,
  38005. /** Z axis */
  38006. Z = 2
  38007. }
  38008. /**
  38009. * Class used to define virtual joystick (used in touch mode)
  38010. */
  38011. export class VirtualJoystick {
  38012. /**
  38013. * Gets or sets a boolean indicating that left and right values must be inverted
  38014. */
  38015. reverseLeftRight: boolean;
  38016. /**
  38017. * Gets or sets a boolean indicating that up and down values must be inverted
  38018. */
  38019. reverseUpDown: boolean;
  38020. /**
  38021. * Gets the offset value for the position (ie. the change of the position value)
  38022. */
  38023. deltaPosition: Vector3;
  38024. /**
  38025. * Gets a boolean indicating if the virtual joystick was pressed
  38026. */
  38027. pressed: boolean;
  38028. /**
  38029. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38030. */
  38031. static Canvas: Nullable<HTMLCanvasElement>;
  38032. private static _globalJoystickIndex;
  38033. private static vjCanvasContext;
  38034. private static vjCanvasWidth;
  38035. private static vjCanvasHeight;
  38036. private static halfWidth;
  38037. private _action;
  38038. private _axisTargetedByLeftAndRight;
  38039. private _axisTargetedByUpAndDown;
  38040. private _joystickSensibility;
  38041. private _inversedSensibility;
  38042. private _joystickPointerID;
  38043. private _joystickColor;
  38044. private _joystickPointerPos;
  38045. private _joystickPreviousPointerPos;
  38046. private _joystickPointerStartPos;
  38047. private _deltaJoystickVector;
  38048. private _leftJoystick;
  38049. private _touches;
  38050. private _onPointerDownHandlerRef;
  38051. private _onPointerMoveHandlerRef;
  38052. private _onPointerUpHandlerRef;
  38053. private _onResize;
  38054. /**
  38055. * Creates a new virtual joystick
  38056. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38057. */
  38058. constructor(leftJoystick?: boolean);
  38059. /**
  38060. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38061. * @param newJoystickSensibility defines the new sensibility
  38062. */
  38063. setJoystickSensibility(newJoystickSensibility: number): void;
  38064. private _onPointerDown;
  38065. private _onPointerMove;
  38066. private _onPointerUp;
  38067. /**
  38068. * Change the color of the virtual joystick
  38069. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38070. */
  38071. setJoystickColor(newColor: string): void;
  38072. /**
  38073. * Defines a callback to call when the joystick is touched
  38074. * @param action defines the callback
  38075. */
  38076. setActionOnTouch(action: () => any): void;
  38077. /**
  38078. * Defines which axis you'd like to control for left & right
  38079. * @param axis defines the axis to use
  38080. */
  38081. setAxisForLeftRight(axis: JoystickAxis): void;
  38082. /**
  38083. * Defines which axis you'd like to control for up & down
  38084. * @param axis defines the axis to use
  38085. */
  38086. setAxisForUpDown(axis: JoystickAxis): void;
  38087. private _drawVirtualJoystick;
  38088. /**
  38089. * Release internal HTML canvas
  38090. */
  38091. releaseCanvas(): void;
  38092. }
  38093. }
  38094. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38095. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38096. import { Nullable } from "babylonjs/types";
  38097. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38098. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38099. module "babylonjs/Cameras/freeCameraInputsManager" {
  38100. interface FreeCameraInputsManager {
  38101. /**
  38102. * Add virtual joystick input support to the input manager.
  38103. * @returns the current input manager
  38104. */
  38105. addVirtualJoystick(): FreeCameraInputsManager;
  38106. }
  38107. }
  38108. /**
  38109. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38111. */
  38112. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38113. /**
  38114. * Defines the camera the input is attached to.
  38115. */
  38116. camera: FreeCamera;
  38117. private _leftjoystick;
  38118. private _rightjoystick;
  38119. /**
  38120. * Gets the left stick of the virtual joystick.
  38121. * @returns The virtual Joystick
  38122. */
  38123. getLeftJoystick(): VirtualJoystick;
  38124. /**
  38125. * Gets the right stick of the virtual joystick.
  38126. * @returns The virtual Joystick
  38127. */
  38128. getRightJoystick(): VirtualJoystick;
  38129. /**
  38130. * Update the current camera state depending on the inputs that have been used this frame.
  38131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38132. */
  38133. checkInputs(): void;
  38134. /**
  38135. * Attach the input controls to a specific dom element to get the input from.
  38136. * @param element Defines the element the controls should be listened from
  38137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38138. */
  38139. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38140. /**
  38141. * Detach the current controls from the specified dom element.
  38142. * @param element Defines the element to stop listening the inputs from
  38143. */
  38144. detachControl(element: Nullable<HTMLElement>): void;
  38145. /**
  38146. * Gets the class name of the current intput.
  38147. * @returns the class name
  38148. */
  38149. getClassName(): string;
  38150. /**
  38151. * Get the friendly name associated with the input class.
  38152. * @returns the input friendly name
  38153. */
  38154. getSimpleName(): string;
  38155. }
  38156. }
  38157. declare module "babylonjs/Cameras/Inputs/index" {
  38158. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38159. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38160. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38161. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38162. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38163. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38164. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38165. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38166. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38167. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38168. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38169. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38170. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38171. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38172. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38173. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38174. }
  38175. declare module "babylonjs/Cameras/touchCamera" {
  38176. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38177. import { Scene } from "babylonjs/scene";
  38178. import { Vector3 } from "babylonjs/Maths/math";
  38179. /**
  38180. * This represents a FPS type of camera controlled by touch.
  38181. * This is like a universal camera minus the Gamepad controls.
  38182. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38183. */
  38184. export class TouchCamera extends FreeCamera {
  38185. /**
  38186. * Defines the touch sensibility for rotation.
  38187. * The higher the faster.
  38188. */
  38189. touchAngularSensibility: number;
  38190. /**
  38191. * Defines the touch sensibility for move.
  38192. * The higher the faster.
  38193. */
  38194. touchMoveSensibility: number;
  38195. /**
  38196. * Instantiates a new touch camera.
  38197. * This represents a FPS type of camera controlled by touch.
  38198. * This is like a universal camera minus the Gamepad controls.
  38199. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38200. * @param name Define the name of the camera in the scene
  38201. * @param position Define the start position of the camera in the scene
  38202. * @param scene Define the scene the camera belongs to
  38203. */
  38204. constructor(name: string, position: Vector3, scene: Scene);
  38205. /**
  38206. * Gets the current object class name.
  38207. * @return the class name
  38208. */
  38209. getClassName(): string;
  38210. /** @hidden */
  38211. _setupInputs(): void;
  38212. }
  38213. }
  38214. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38215. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38216. import { Scene } from "babylonjs/scene";
  38217. import { Vector3, Axis } from "babylonjs/Maths/math";
  38218. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38219. /**
  38220. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38221. * being tilted forward or back and left or right.
  38222. */
  38223. export class DeviceOrientationCamera extends FreeCamera {
  38224. private _initialQuaternion;
  38225. private _quaternionCache;
  38226. /**
  38227. * Creates a new device orientation camera
  38228. * @param name The name of the camera
  38229. * @param position The start position camera
  38230. * @param scene The scene the camera belongs to
  38231. */
  38232. constructor(name: string, position: Vector3, scene: Scene);
  38233. /**
  38234. * Gets the current instance class name ("DeviceOrientationCamera").
  38235. * This helps avoiding instanceof at run time.
  38236. * @returns the class name
  38237. */
  38238. getClassName(): string;
  38239. /**
  38240. * @hidden
  38241. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38242. */
  38243. _checkInputs(): void;
  38244. /**
  38245. * Reset the camera to its default orientation on the specified axis only.
  38246. * @param axis The axis to reset
  38247. */
  38248. resetToCurrentRotation(axis?: Axis): void;
  38249. }
  38250. }
  38251. declare module "babylonjs/Cameras/universalCamera" {
  38252. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38253. import { Scene } from "babylonjs/scene";
  38254. import { Vector3 } from "babylonjs/Maths/math";
  38255. /**
  38256. * 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,
  38257. * which still works and will still be found in many Playgrounds.
  38258. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38259. */
  38260. export class UniversalCamera extends TouchCamera {
  38261. /**
  38262. * Defines the gamepad rotation sensiblity.
  38263. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38264. */
  38265. gamepadAngularSensibility: number;
  38266. /**
  38267. * Defines the gamepad move sensiblity.
  38268. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38269. */
  38270. gamepadMoveSensibility: number;
  38271. /**
  38272. * 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,
  38273. * which still works and will still be found in many Playgrounds.
  38274. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38275. * @param name Define the name of the camera in the scene
  38276. * @param position Define the start position of the camera in the scene
  38277. * @param scene Define the scene the camera belongs to
  38278. */
  38279. constructor(name: string, position: Vector3, scene: Scene);
  38280. /**
  38281. * Gets the current object class name.
  38282. * @return the class name
  38283. */
  38284. getClassName(): string;
  38285. }
  38286. }
  38287. declare module "babylonjs/Cameras/gamepadCamera" {
  38288. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38289. import { Scene } from "babylonjs/scene";
  38290. import { Vector3 } from "babylonjs/Maths/math";
  38291. /**
  38292. * This represents a FPS type of camera. This is only here for back compat purpose.
  38293. * Please use the UniversalCamera instead as both are identical.
  38294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38295. */
  38296. export class GamepadCamera extends UniversalCamera {
  38297. /**
  38298. * Instantiates a new Gamepad Camera
  38299. * This represents a FPS type of camera. This is only here for back compat purpose.
  38300. * Please use the UniversalCamera instead as both are identical.
  38301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38302. * @param name Define the name of the camera in the scene
  38303. * @param position Define the start position of the camera in the scene
  38304. * @param scene Define the scene the camera belongs to
  38305. */
  38306. constructor(name: string, position: Vector3, scene: Scene);
  38307. /**
  38308. * Gets the current object class name.
  38309. * @return the class name
  38310. */
  38311. getClassName(): string;
  38312. }
  38313. }
  38314. declare module "babylonjs/Shaders/pass.fragment" {
  38315. /** @hidden */
  38316. export var passPixelShader: {
  38317. name: string;
  38318. shader: string;
  38319. };
  38320. }
  38321. declare module "babylonjs/Shaders/passCube.fragment" {
  38322. /** @hidden */
  38323. export var passCubePixelShader: {
  38324. name: string;
  38325. shader: string;
  38326. };
  38327. }
  38328. declare module "babylonjs/PostProcesses/passPostProcess" {
  38329. import { Nullable } from "babylonjs/types";
  38330. import { Camera } from "babylonjs/Cameras/camera";
  38331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38332. import { Engine } from "babylonjs/Engines/engine";
  38333. import "babylonjs/Shaders/pass.fragment";
  38334. import "babylonjs/Shaders/passCube.fragment";
  38335. /**
  38336. * PassPostProcess which produces an output the same as it's input
  38337. */
  38338. export class PassPostProcess extends PostProcess {
  38339. /**
  38340. * Creates the PassPostProcess
  38341. * @param name The name of the effect.
  38342. * @param options The required width/height ratio to downsize to before computing the render pass.
  38343. * @param camera The camera to apply the render pass to.
  38344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38345. * @param engine The engine which the post process will be applied. (default: current engine)
  38346. * @param reusable If the post process can be reused on the same frame. (default: false)
  38347. * @param textureType The type of texture to be used when performing the post processing.
  38348. * @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)
  38349. */
  38350. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38351. }
  38352. /**
  38353. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38354. */
  38355. export class PassCubePostProcess extends PostProcess {
  38356. private _face;
  38357. /**
  38358. * Gets or sets the cube face to display.
  38359. * * 0 is +X
  38360. * * 1 is -X
  38361. * * 2 is +Y
  38362. * * 3 is -Y
  38363. * * 4 is +Z
  38364. * * 5 is -Z
  38365. */
  38366. face: number;
  38367. /**
  38368. * Creates the PassCubePostProcess
  38369. * @param name The name of the effect.
  38370. * @param options The required width/height ratio to downsize to before computing the render pass.
  38371. * @param camera The camera to apply the render pass to.
  38372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38373. * @param engine The engine which the post process will be applied. (default: current engine)
  38374. * @param reusable If the post process can be reused on the same frame. (default: false)
  38375. * @param textureType The type of texture to be used when performing the post processing.
  38376. * @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)
  38377. */
  38378. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38379. }
  38380. }
  38381. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38382. /** @hidden */
  38383. export var anaglyphPixelShader: {
  38384. name: string;
  38385. shader: string;
  38386. };
  38387. }
  38388. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38389. import { Engine } from "babylonjs/Engines/engine";
  38390. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38391. import { Camera } from "babylonjs/Cameras/camera";
  38392. import "babylonjs/Shaders/anaglyph.fragment";
  38393. /**
  38394. * Postprocess used to generate anaglyphic rendering
  38395. */
  38396. export class AnaglyphPostProcess extends PostProcess {
  38397. private _passedProcess;
  38398. /**
  38399. * Creates a new AnaglyphPostProcess
  38400. * @param name defines postprocess name
  38401. * @param options defines creation options or target ratio scale
  38402. * @param rigCameras defines cameras using this postprocess
  38403. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38404. * @param engine defines hosting engine
  38405. * @param reusable defines if the postprocess will be reused multiple times per frame
  38406. */
  38407. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38408. }
  38409. }
  38410. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38411. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38412. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38413. import { Scene } from "babylonjs/scene";
  38414. import { Vector3 } from "babylonjs/Maths/math";
  38415. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38416. /**
  38417. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38418. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38419. */
  38420. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38421. /**
  38422. * Creates a new AnaglyphArcRotateCamera
  38423. * @param name defines camera name
  38424. * @param alpha defines alpha angle (in radians)
  38425. * @param beta defines beta angle (in radians)
  38426. * @param radius defines radius
  38427. * @param target defines camera target
  38428. * @param interaxialDistance defines distance between each color axis
  38429. * @param scene defines the hosting scene
  38430. */
  38431. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38432. /**
  38433. * Gets camera class name
  38434. * @returns AnaglyphArcRotateCamera
  38435. */
  38436. getClassName(): string;
  38437. }
  38438. }
  38439. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38440. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38441. import { Scene } from "babylonjs/scene";
  38442. import { Vector3 } from "babylonjs/Maths/math";
  38443. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38444. /**
  38445. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38446. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38447. */
  38448. export class AnaglyphFreeCamera extends FreeCamera {
  38449. /**
  38450. * Creates a new AnaglyphFreeCamera
  38451. * @param name defines camera name
  38452. * @param position defines initial position
  38453. * @param interaxialDistance defines distance between each color axis
  38454. * @param scene defines the hosting scene
  38455. */
  38456. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38457. /**
  38458. * Gets camera class name
  38459. * @returns AnaglyphFreeCamera
  38460. */
  38461. getClassName(): string;
  38462. }
  38463. }
  38464. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38465. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38466. import { Scene } from "babylonjs/scene";
  38467. import { Vector3 } from "babylonjs/Maths/math";
  38468. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38469. /**
  38470. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38471. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38472. */
  38473. export class AnaglyphGamepadCamera extends GamepadCamera {
  38474. /**
  38475. * Creates a new AnaglyphGamepadCamera
  38476. * @param name defines camera name
  38477. * @param position defines initial position
  38478. * @param interaxialDistance defines distance between each color axis
  38479. * @param scene defines the hosting scene
  38480. */
  38481. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38482. /**
  38483. * Gets camera class name
  38484. * @returns AnaglyphGamepadCamera
  38485. */
  38486. getClassName(): string;
  38487. }
  38488. }
  38489. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38490. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38491. import { Scene } from "babylonjs/scene";
  38492. import { Vector3 } from "babylonjs/Maths/math";
  38493. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38494. /**
  38495. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38496. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38497. */
  38498. export class AnaglyphUniversalCamera extends UniversalCamera {
  38499. /**
  38500. * Creates a new AnaglyphUniversalCamera
  38501. * @param name defines camera name
  38502. * @param position defines initial position
  38503. * @param interaxialDistance defines distance between each color axis
  38504. * @param scene defines the hosting scene
  38505. */
  38506. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38507. /**
  38508. * Gets camera class name
  38509. * @returns AnaglyphUniversalCamera
  38510. */
  38511. getClassName(): string;
  38512. }
  38513. }
  38514. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38515. /** @hidden */
  38516. export var stereoscopicInterlacePixelShader: {
  38517. name: string;
  38518. shader: string;
  38519. };
  38520. }
  38521. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38522. import { Camera } from "babylonjs/Cameras/camera";
  38523. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38524. import { Engine } from "babylonjs/Engines/engine";
  38525. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38526. /**
  38527. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38528. */
  38529. export class StereoscopicInterlacePostProcess extends PostProcess {
  38530. private _stepSize;
  38531. private _passedProcess;
  38532. /**
  38533. * Initializes a StereoscopicInterlacePostProcess
  38534. * @param name The name of the effect.
  38535. * @param rigCameras The rig cameras to be appled to the post process
  38536. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38538. * @param engine The engine which the post process will be applied. (default: current engine)
  38539. * @param reusable If the post process can be reused on the same frame. (default: false)
  38540. */
  38541. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38542. }
  38543. }
  38544. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38545. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38546. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38547. import { Scene } from "babylonjs/scene";
  38548. import { Vector3 } from "babylonjs/Maths/math";
  38549. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38550. /**
  38551. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38552. * @see http://doc.babylonjs.com/features/cameras
  38553. */
  38554. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38555. /**
  38556. * Creates a new StereoscopicArcRotateCamera
  38557. * @param name defines camera name
  38558. * @param alpha defines alpha angle (in radians)
  38559. * @param beta defines beta angle (in radians)
  38560. * @param radius defines radius
  38561. * @param target defines camera target
  38562. * @param interaxialDistance defines distance between each color axis
  38563. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38564. * @param scene defines the hosting scene
  38565. */
  38566. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38567. /**
  38568. * Gets camera class name
  38569. * @returns StereoscopicArcRotateCamera
  38570. */
  38571. getClassName(): string;
  38572. }
  38573. }
  38574. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38575. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38576. import { Scene } from "babylonjs/scene";
  38577. import { Vector3 } from "babylonjs/Maths/math";
  38578. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38579. /**
  38580. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38581. * @see http://doc.babylonjs.com/features/cameras
  38582. */
  38583. export class StereoscopicFreeCamera extends FreeCamera {
  38584. /**
  38585. * Creates a new StereoscopicFreeCamera
  38586. * @param name defines camera name
  38587. * @param position defines initial position
  38588. * @param interaxialDistance defines distance between each color axis
  38589. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38590. * @param scene defines the hosting scene
  38591. */
  38592. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38593. /**
  38594. * Gets camera class name
  38595. * @returns StereoscopicFreeCamera
  38596. */
  38597. getClassName(): string;
  38598. }
  38599. }
  38600. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38601. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38602. import { Scene } from "babylonjs/scene";
  38603. import { Vector3 } from "babylonjs/Maths/math";
  38604. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38605. /**
  38606. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38607. * @see http://doc.babylonjs.com/features/cameras
  38608. */
  38609. export class StereoscopicGamepadCamera extends GamepadCamera {
  38610. /**
  38611. * Creates a new StereoscopicGamepadCamera
  38612. * @param name defines camera name
  38613. * @param position defines initial position
  38614. * @param interaxialDistance defines distance between each color axis
  38615. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38616. * @param scene defines the hosting scene
  38617. */
  38618. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38619. /**
  38620. * Gets camera class name
  38621. * @returns StereoscopicGamepadCamera
  38622. */
  38623. getClassName(): string;
  38624. }
  38625. }
  38626. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38627. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38628. import { Scene } from "babylonjs/scene";
  38629. import { Vector3 } from "babylonjs/Maths/math";
  38630. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38631. /**
  38632. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38633. * @see http://doc.babylonjs.com/features/cameras
  38634. */
  38635. export class StereoscopicUniversalCamera extends UniversalCamera {
  38636. /**
  38637. * Creates a new StereoscopicUniversalCamera
  38638. * @param name defines camera name
  38639. * @param position defines initial position
  38640. * @param interaxialDistance defines distance between each color axis
  38641. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38642. * @param scene defines the hosting scene
  38643. */
  38644. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38645. /**
  38646. * Gets camera class name
  38647. * @returns StereoscopicUniversalCamera
  38648. */
  38649. getClassName(): string;
  38650. }
  38651. }
  38652. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38653. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38654. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38655. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38656. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38657. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38658. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38659. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38660. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38661. }
  38662. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38663. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38664. import { Scene } from "babylonjs/scene";
  38665. import { Vector3 } from "babylonjs/Maths/math";
  38666. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38667. /**
  38668. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38669. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38670. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38671. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38672. */
  38673. export class VirtualJoysticksCamera extends FreeCamera {
  38674. /**
  38675. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38676. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38677. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38678. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38679. * @param name Define the name of the camera in the scene
  38680. * @param position Define the start position of the camera in the scene
  38681. * @param scene Define the scene the camera belongs to
  38682. */
  38683. constructor(name: string, position: Vector3, scene: Scene);
  38684. /**
  38685. * Gets the current object class name.
  38686. * @return the class name
  38687. */
  38688. getClassName(): string;
  38689. }
  38690. }
  38691. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38692. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38693. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38694. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38695. import { Scene } from "babylonjs/scene";
  38696. import { Vector3 } from "babylonjs/Maths/math";
  38697. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38698. import "babylonjs/Cameras/RigModes/vrRigMode";
  38699. /**
  38700. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38701. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38702. */
  38703. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38704. /**
  38705. * Creates a new VRDeviceOrientationArcRotateCamera
  38706. * @param name defines camera name
  38707. * @param alpha defines the camera rotation along the logitudinal axis
  38708. * @param beta defines the camera rotation along the latitudinal axis
  38709. * @param radius defines the camera distance from its target
  38710. * @param target defines the camera target
  38711. * @param scene defines the scene the camera belongs to
  38712. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38713. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38714. */
  38715. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38716. /**
  38717. * Gets camera class name
  38718. * @returns VRDeviceOrientationArcRotateCamera
  38719. */
  38720. getClassName(): string;
  38721. }
  38722. }
  38723. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38724. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38725. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38726. import { Scene } from "babylonjs/scene";
  38727. import { Vector3 } from "babylonjs/Maths/math";
  38728. import "babylonjs/Cameras/RigModes/vrRigMode";
  38729. /**
  38730. * Camera used to simulate VR rendering (based on FreeCamera)
  38731. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38732. */
  38733. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38734. /**
  38735. * Creates a new VRDeviceOrientationFreeCamera
  38736. * @param name defines camera name
  38737. * @param position defines the start position of the camera
  38738. * @param scene defines the scene the camera belongs to
  38739. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38740. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38741. */
  38742. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38743. /**
  38744. * Gets camera class name
  38745. * @returns VRDeviceOrientationFreeCamera
  38746. */
  38747. getClassName(): string;
  38748. }
  38749. }
  38750. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38751. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38752. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38753. import { Scene } from "babylonjs/scene";
  38754. import { Vector3 } from "babylonjs/Maths/math";
  38755. /**
  38756. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38757. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38758. */
  38759. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38760. /**
  38761. * Creates a new VRDeviceOrientationGamepadCamera
  38762. * @param name defines camera name
  38763. * @param position defines the start position of the camera
  38764. * @param scene defines the scene the camera belongs to
  38765. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38766. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38767. */
  38768. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38769. /**
  38770. * Gets camera class name
  38771. * @returns VRDeviceOrientationGamepadCamera
  38772. */
  38773. getClassName(): string;
  38774. }
  38775. }
  38776. declare module "babylonjs/Gamepads/xboxGamepad" {
  38777. import { Observable } from "babylonjs/Misc/observable";
  38778. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38779. /**
  38780. * Defines supported buttons for XBox360 compatible gamepads
  38781. */
  38782. export enum Xbox360Button {
  38783. /** A */
  38784. A = 0,
  38785. /** B */
  38786. B = 1,
  38787. /** X */
  38788. X = 2,
  38789. /** Y */
  38790. Y = 3,
  38791. /** Start */
  38792. Start = 4,
  38793. /** Back */
  38794. Back = 5,
  38795. /** Left button */
  38796. LB = 6,
  38797. /** Right button */
  38798. RB = 7,
  38799. /** Left stick */
  38800. LeftStick = 8,
  38801. /** Right stick */
  38802. RightStick = 9
  38803. }
  38804. /** Defines values for XBox360 DPad */
  38805. export enum Xbox360Dpad {
  38806. /** Up */
  38807. Up = 0,
  38808. /** Down */
  38809. Down = 1,
  38810. /** Left */
  38811. Left = 2,
  38812. /** Right */
  38813. Right = 3
  38814. }
  38815. /**
  38816. * Defines a XBox360 gamepad
  38817. */
  38818. export class Xbox360Pad extends Gamepad {
  38819. private _leftTrigger;
  38820. private _rightTrigger;
  38821. private _onlefttriggerchanged;
  38822. private _onrighttriggerchanged;
  38823. private _onbuttondown;
  38824. private _onbuttonup;
  38825. private _ondpaddown;
  38826. private _ondpadup;
  38827. /** Observable raised when a button is pressed */
  38828. onButtonDownObservable: Observable<Xbox360Button>;
  38829. /** Observable raised when a button is released */
  38830. onButtonUpObservable: Observable<Xbox360Button>;
  38831. /** Observable raised when a pad is pressed */
  38832. onPadDownObservable: Observable<Xbox360Dpad>;
  38833. /** Observable raised when a pad is released */
  38834. onPadUpObservable: Observable<Xbox360Dpad>;
  38835. private _buttonA;
  38836. private _buttonB;
  38837. private _buttonX;
  38838. private _buttonY;
  38839. private _buttonBack;
  38840. private _buttonStart;
  38841. private _buttonLB;
  38842. private _buttonRB;
  38843. private _buttonLeftStick;
  38844. private _buttonRightStick;
  38845. private _dPadUp;
  38846. private _dPadDown;
  38847. private _dPadLeft;
  38848. private _dPadRight;
  38849. private _isXboxOnePad;
  38850. /**
  38851. * Creates a new XBox360 gamepad object
  38852. * @param id defines the id of this gamepad
  38853. * @param index defines its index
  38854. * @param gamepad defines the internal HTML gamepad object
  38855. * @param xboxOne defines if it is a XBox One gamepad
  38856. */
  38857. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38858. /**
  38859. * Defines the callback to call when left trigger is pressed
  38860. * @param callback defines the callback to use
  38861. */
  38862. onlefttriggerchanged(callback: (value: number) => void): void;
  38863. /**
  38864. * Defines the callback to call when right trigger is pressed
  38865. * @param callback defines the callback to use
  38866. */
  38867. onrighttriggerchanged(callback: (value: number) => void): void;
  38868. /**
  38869. * Gets the left trigger value
  38870. */
  38871. /**
  38872. * Sets the left trigger value
  38873. */
  38874. leftTrigger: number;
  38875. /**
  38876. * Gets the right trigger value
  38877. */
  38878. /**
  38879. * Sets the right trigger value
  38880. */
  38881. rightTrigger: number;
  38882. /**
  38883. * Defines the callback to call when a button is pressed
  38884. * @param callback defines the callback to use
  38885. */
  38886. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38887. /**
  38888. * Defines the callback to call when a button is released
  38889. * @param callback defines the callback to use
  38890. */
  38891. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38892. /**
  38893. * Defines the callback to call when a pad is pressed
  38894. * @param callback defines the callback to use
  38895. */
  38896. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38897. /**
  38898. * Defines the callback to call when a pad is released
  38899. * @param callback defines the callback to use
  38900. */
  38901. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38902. private _setButtonValue;
  38903. private _setDPadValue;
  38904. /**
  38905. * Gets the value of the `A` button
  38906. */
  38907. /**
  38908. * Sets the value of the `A` button
  38909. */
  38910. buttonA: number;
  38911. /**
  38912. * Gets the value of the `B` button
  38913. */
  38914. /**
  38915. * Sets the value of the `B` button
  38916. */
  38917. buttonB: number;
  38918. /**
  38919. * Gets the value of the `X` button
  38920. */
  38921. /**
  38922. * Sets the value of the `X` button
  38923. */
  38924. buttonX: number;
  38925. /**
  38926. * Gets the value of the `Y` button
  38927. */
  38928. /**
  38929. * Sets the value of the `Y` button
  38930. */
  38931. buttonY: number;
  38932. /**
  38933. * Gets the value of the `Start` button
  38934. */
  38935. /**
  38936. * Sets the value of the `Start` button
  38937. */
  38938. buttonStart: number;
  38939. /**
  38940. * Gets the value of the `Back` button
  38941. */
  38942. /**
  38943. * Sets the value of the `Back` button
  38944. */
  38945. buttonBack: number;
  38946. /**
  38947. * Gets the value of the `Left` button
  38948. */
  38949. /**
  38950. * Sets the value of the `Left` button
  38951. */
  38952. buttonLB: number;
  38953. /**
  38954. * Gets the value of the `Right` button
  38955. */
  38956. /**
  38957. * Sets the value of the `Right` button
  38958. */
  38959. buttonRB: number;
  38960. /**
  38961. * Gets the value of the Left joystick
  38962. */
  38963. /**
  38964. * Sets the value of the Left joystick
  38965. */
  38966. buttonLeftStick: number;
  38967. /**
  38968. * Gets the value of the Right joystick
  38969. */
  38970. /**
  38971. * Sets the value of the Right joystick
  38972. */
  38973. buttonRightStick: number;
  38974. /**
  38975. * Gets the value of D-pad up
  38976. */
  38977. /**
  38978. * Sets the value of D-pad up
  38979. */
  38980. dPadUp: number;
  38981. /**
  38982. * Gets the value of D-pad down
  38983. */
  38984. /**
  38985. * Sets the value of D-pad down
  38986. */
  38987. dPadDown: number;
  38988. /**
  38989. * Gets the value of D-pad left
  38990. */
  38991. /**
  38992. * Sets the value of D-pad left
  38993. */
  38994. dPadLeft: number;
  38995. /**
  38996. * Gets the value of D-pad right
  38997. */
  38998. /**
  38999. * Sets the value of D-pad right
  39000. */
  39001. dPadRight: number;
  39002. /**
  39003. * Force the gamepad to synchronize with device values
  39004. */
  39005. update(): void;
  39006. /**
  39007. * Disposes the gamepad
  39008. */
  39009. dispose(): void;
  39010. }
  39011. }
  39012. declare module "babylonjs/Materials/pushMaterial" {
  39013. import { Nullable } from "babylonjs/types";
  39014. import { Scene } from "babylonjs/scene";
  39015. import { Matrix } from "babylonjs/Maths/math";
  39016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39017. import { Mesh } from "babylonjs/Meshes/mesh";
  39018. import { Material } from "babylonjs/Materials/material";
  39019. import { Effect } from "babylonjs/Materials/effect";
  39020. /**
  39021. * Base class of materials working in push mode in babylon JS
  39022. * @hidden
  39023. */
  39024. export class PushMaterial extends Material {
  39025. protected _activeEffect: Effect;
  39026. protected _normalMatrix: Matrix;
  39027. /**
  39028. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39029. * This means that the material can keep using a previous shader while a new one is being compiled.
  39030. * This is mostly used when shader parallel compilation is supported (true by default)
  39031. */
  39032. allowShaderHotSwapping: boolean;
  39033. constructor(name: string, scene: Scene);
  39034. getEffect(): Effect;
  39035. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39036. /**
  39037. * Binds the given world matrix to the active effect
  39038. *
  39039. * @param world the matrix to bind
  39040. */
  39041. bindOnlyWorldMatrix(world: Matrix): void;
  39042. /**
  39043. * Binds the given normal matrix to the active effect
  39044. *
  39045. * @param normalMatrix the matrix to bind
  39046. */
  39047. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39048. bind(world: Matrix, mesh?: Mesh): void;
  39049. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39050. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39051. }
  39052. }
  39053. declare module "babylonjs/Materials/materialFlags" {
  39054. /**
  39055. * This groups all the flags used to control the materials channel.
  39056. */
  39057. export class MaterialFlags {
  39058. private static _DiffuseTextureEnabled;
  39059. /**
  39060. * Are diffuse textures enabled in the application.
  39061. */
  39062. static DiffuseTextureEnabled: boolean;
  39063. private static _AmbientTextureEnabled;
  39064. /**
  39065. * Are ambient textures enabled in the application.
  39066. */
  39067. static AmbientTextureEnabled: boolean;
  39068. private static _OpacityTextureEnabled;
  39069. /**
  39070. * Are opacity textures enabled in the application.
  39071. */
  39072. static OpacityTextureEnabled: boolean;
  39073. private static _ReflectionTextureEnabled;
  39074. /**
  39075. * Are reflection textures enabled in the application.
  39076. */
  39077. static ReflectionTextureEnabled: boolean;
  39078. private static _EmissiveTextureEnabled;
  39079. /**
  39080. * Are emissive textures enabled in the application.
  39081. */
  39082. static EmissiveTextureEnabled: boolean;
  39083. private static _SpecularTextureEnabled;
  39084. /**
  39085. * Are specular textures enabled in the application.
  39086. */
  39087. static SpecularTextureEnabled: boolean;
  39088. private static _BumpTextureEnabled;
  39089. /**
  39090. * Are bump textures enabled in the application.
  39091. */
  39092. static BumpTextureEnabled: boolean;
  39093. private static _LightmapTextureEnabled;
  39094. /**
  39095. * Are lightmap textures enabled in the application.
  39096. */
  39097. static LightmapTextureEnabled: boolean;
  39098. private static _RefractionTextureEnabled;
  39099. /**
  39100. * Are refraction textures enabled in the application.
  39101. */
  39102. static RefractionTextureEnabled: boolean;
  39103. private static _ColorGradingTextureEnabled;
  39104. /**
  39105. * Are color grading textures enabled in the application.
  39106. */
  39107. static ColorGradingTextureEnabled: boolean;
  39108. private static _FresnelEnabled;
  39109. /**
  39110. * Are fresnels enabled in the application.
  39111. */
  39112. static FresnelEnabled: boolean;
  39113. private static _ClearCoatTextureEnabled;
  39114. /**
  39115. * Are clear coat textures enabled in the application.
  39116. */
  39117. static ClearCoatTextureEnabled: boolean;
  39118. private static _ClearCoatBumpTextureEnabled;
  39119. /**
  39120. * Are clear coat bump textures enabled in the application.
  39121. */
  39122. static ClearCoatBumpTextureEnabled: boolean;
  39123. private static _ClearCoatTintTextureEnabled;
  39124. /**
  39125. * Are clear coat tint textures enabled in the application.
  39126. */
  39127. static ClearCoatTintTextureEnabled: boolean;
  39128. private static _SheenTextureEnabled;
  39129. /**
  39130. * Are sheen textures enabled in the application.
  39131. */
  39132. static SheenTextureEnabled: boolean;
  39133. private static _AnisotropicTextureEnabled;
  39134. /**
  39135. * Are anisotropic textures enabled in the application.
  39136. */
  39137. static AnisotropicTextureEnabled: boolean;
  39138. }
  39139. }
  39140. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39141. /** @hidden */
  39142. export var defaultFragmentDeclaration: {
  39143. name: string;
  39144. shader: string;
  39145. };
  39146. }
  39147. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39148. /** @hidden */
  39149. export var defaultUboDeclaration: {
  39150. name: string;
  39151. shader: string;
  39152. };
  39153. }
  39154. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39155. /** @hidden */
  39156. export var lightFragmentDeclaration: {
  39157. name: string;
  39158. shader: string;
  39159. };
  39160. }
  39161. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39162. /** @hidden */
  39163. export var lightUboDeclaration: {
  39164. name: string;
  39165. shader: string;
  39166. };
  39167. }
  39168. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39169. /** @hidden */
  39170. export var lightsFragmentFunctions: {
  39171. name: string;
  39172. shader: string;
  39173. };
  39174. }
  39175. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39176. /** @hidden */
  39177. export var shadowsFragmentFunctions: {
  39178. name: string;
  39179. shader: string;
  39180. };
  39181. }
  39182. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39183. /** @hidden */
  39184. export var fresnelFunction: {
  39185. name: string;
  39186. shader: string;
  39187. };
  39188. }
  39189. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39190. /** @hidden */
  39191. export var reflectionFunction: {
  39192. name: string;
  39193. shader: string;
  39194. };
  39195. }
  39196. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39197. /** @hidden */
  39198. export var bumpFragmentFunctions: {
  39199. name: string;
  39200. shader: string;
  39201. };
  39202. }
  39203. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39204. /** @hidden */
  39205. export var logDepthDeclaration: {
  39206. name: string;
  39207. shader: string;
  39208. };
  39209. }
  39210. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39211. /** @hidden */
  39212. export var bumpFragment: {
  39213. name: string;
  39214. shader: string;
  39215. };
  39216. }
  39217. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39218. /** @hidden */
  39219. export var depthPrePass: {
  39220. name: string;
  39221. shader: string;
  39222. };
  39223. }
  39224. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39225. /** @hidden */
  39226. export var lightFragment: {
  39227. name: string;
  39228. shader: string;
  39229. };
  39230. }
  39231. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39232. /** @hidden */
  39233. export var logDepthFragment: {
  39234. name: string;
  39235. shader: string;
  39236. };
  39237. }
  39238. declare module "babylonjs/Shaders/default.fragment" {
  39239. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39240. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39241. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39242. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39243. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39244. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39245. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39246. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39247. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39248. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39249. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39250. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39251. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39252. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39253. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39254. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39255. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39256. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39257. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39258. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39259. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39260. /** @hidden */
  39261. export var defaultPixelShader: {
  39262. name: string;
  39263. shader: string;
  39264. };
  39265. }
  39266. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39267. /** @hidden */
  39268. export var defaultVertexDeclaration: {
  39269. name: string;
  39270. shader: string;
  39271. };
  39272. }
  39273. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39274. /** @hidden */
  39275. export var bumpVertexDeclaration: {
  39276. name: string;
  39277. shader: string;
  39278. };
  39279. }
  39280. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39281. /** @hidden */
  39282. export var bumpVertex: {
  39283. name: string;
  39284. shader: string;
  39285. };
  39286. }
  39287. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39288. /** @hidden */
  39289. export var fogVertex: {
  39290. name: string;
  39291. shader: string;
  39292. };
  39293. }
  39294. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39295. /** @hidden */
  39296. export var shadowsVertex: {
  39297. name: string;
  39298. shader: string;
  39299. };
  39300. }
  39301. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39302. /** @hidden */
  39303. export var pointCloudVertex: {
  39304. name: string;
  39305. shader: string;
  39306. };
  39307. }
  39308. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39309. /** @hidden */
  39310. export var logDepthVertex: {
  39311. name: string;
  39312. shader: string;
  39313. };
  39314. }
  39315. declare module "babylonjs/Shaders/default.vertex" {
  39316. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39317. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39318. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39319. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39320. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39321. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39322. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39323. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39324. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39325. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39326. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39328. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39329. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39330. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39331. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39332. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39333. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39334. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39335. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39336. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39337. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39338. /** @hidden */
  39339. export var defaultVertexShader: {
  39340. name: string;
  39341. shader: string;
  39342. };
  39343. }
  39344. declare module "babylonjs/Materials/standardMaterial" {
  39345. import { SmartArray } from "babylonjs/Misc/smartArray";
  39346. import { IAnimatable } from "babylonjs/Misc/tools";
  39347. import { Nullable } from "babylonjs/types";
  39348. import { Scene } from "babylonjs/scene";
  39349. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39350. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39352. import { Mesh } from "babylonjs/Meshes/mesh";
  39353. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39354. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39355. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39356. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39357. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39359. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39360. import "babylonjs/Shaders/default.fragment";
  39361. import "babylonjs/Shaders/default.vertex";
  39362. /** @hidden */
  39363. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39364. MAINUV1: boolean;
  39365. MAINUV2: boolean;
  39366. DIFFUSE: boolean;
  39367. DIFFUSEDIRECTUV: number;
  39368. AMBIENT: boolean;
  39369. AMBIENTDIRECTUV: number;
  39370. OPACITY: boolean;
  39371. OPACITYDIRECTUV: number;
  39372. OPACITYRGB: boolean;
  39373. REFLECTION: boolean;
  39374. EMISSIVE: boolean;
  39375. EMISSIVEDIRECTUV: number;
  39376. SPECULAR: boolean;
  39377. SPECULARDIRECTUV: number;
  39378. BUMP: boolean;
  39379. BUMPDIRECTUV: number;
  39380. PARALLAX: boolean;
  39381. PARALLAXOCCLUSION: boolean;
  39382. SPECULAROVERALPHA: boolean;
  39383. CLIPPLANE: boolean;
  39384. CLIPPLANE2: boolean;
  39385. CLIPPLANE3: boolean;
  39386. CLIPPLANE4: boolean;
  39387. ALPHATEST: boolean;
  39388. DEPTHPREPASS: boolean;
  39389. ALPHAFROMDIFFUSE: boolean;
  39390. POINTSIZE: boolean;
  39391. FOG: boolean;
  39392. SPECULARTERM: boolean;
  39393. DIFFUSEFRESNEL: boolean;
  39394. OPACITYFRESNEL: boolean;
  39395. REFLECTIONFRESNEL: boolean;
  39396. REFRACTIONFRESNEL: boolean;
  39397. EMISSIVEFRESNEL: boolean;
  39398. FRESNEL: boolean;
  39399. NORMAL: boolean;
  39400. UV1: boolean;
  39401. UV2: boolean;
  39402. VERTEXCOLOR: boolean;
  39403. VERTEXALPHA: boolean;
  39404. NUM_BONE_INFLUENCERS: number;
  39405. BonesPerMesh: number;
  39406. BONETEXTURE: boolean;
  39407. INSTANCES: boolean;
  39408. GLOSSINESS: boolean;
  39409. ROUGHNESS: boolean;
  39410. EMISSIVEASILLUMINATION: boolean;
  39411. LINKEMISSIVEWITHDIFFUSE: boolean;
  39412. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39413. LIGHTMAP: boolean;
  39414. LIGHTMAPDIRECTUV: number;
  39415. OBJECTSPACE_NORMALMAP: boolean;
  39416. USELIGHTMAPASSHADOWMAP: boolean;
  39417. REFLECTIONMAP_3D: boolean;
  39418. REFLECTIONMAP_SPHERICAL: boolean;
  39419. REFLECTIONMAP_PLANAR: boolean;
  39420. REFLECTIONMAP_CUBIC: boolean;
  39421. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39422. REFLECTIONMAP_PROJECTION: boolean;
  39423. REFLECTIONMAP_SKYBOX: boolean;
  39424. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39425. REFLECTIONMAP_EXPLICIT: boolean;
  39426. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39427. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39428. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39429. INVERTCUBICMAP: boolean;
  39430. LOGARITHMICDEPTH: boolean;
  39431. REFRACTION: boolean;
  39432. REFRACTIONMAP_3D: boolean;
  39433. REFLECTIONOVERALPHA: boolean;
  39434. TWOSIDEDLIGHTING: boolean;
  39435. SHADOWFLOAT: boolean;
  39436. MORPHTARGETS: boolean;
  39437. MORPHTARGETS_NORMAL: boolean;
  39438. MORPHTARGETS_TANGENT: boolean;
  39439. NUM_MORPH_INFLUENCERS: number;
  39440. NONUNIFORMSCALING: boolean;
  39441. PREMULTIPLYALPHA: boolean;
  39442. IMAGEPROCESSING: boolean;
  39443. VIGNETTE: boolean;
  39444. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39445. VIGNETTEBLENDMODEOPAQUE: boolean;
  39446. TONEMAPPING: boolean;
  39447. TONEMAPPING_ACES: boolean;
  39448. CONTRAST: boolean;
  39449. COLORCURVES: boolean;
  39450. COLORGRADING: boolean;
  39451. COLORGRADING3D: boolean;
  39452. SAMPLER3DGREENDEPTH: boolean;
  39453. SAMPLER3DBGRMAP: boolean;
  39454. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39455. MULTIVIEW: boolean;
  39456. /**
  39457. * If the reflection texture on this material is in linear color space
  39458. * @hidden
  39459. */
  39460. IS_REFLECTION_LINEAR: boolean;
  39461. /**
  39462. * If the refraction texture on this material is in linear color space
  39463. * @hidden
  39464. */
  39465. IS_REFRACTION_LINEAR: boolean;
  39466. EXPOSURE: boolean;
  39467. constructor();
  39468. setReflectionMode(modeToEnable: string): void;
  39469. }
  39470. /**
  39471. * This is the default material used in Babylon. It is the best trade off between quality
  39472. * and performances.
  39473. * @see http://doc.babylonjs.com/babylon101/materials
  39474. */
  39475. export class StandardMaterial extends PushMaterial {
  39476. private _diffuseTexture;
  39477. /**
  39478. * The basic texture of the material as viewed under a light.
  39479. */
  39480. diffuseTexture: Nullable<BaseTexture>;
  39481. private _ambientTexture;
  39482. /**
  39483. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39484. */
  39485. ambientTexture: Nullable<BaseTexture>;
  39486. private _opacityTexture;
  39487. /**
  39488. * Define the transparency of the material from a texture.
  39489. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39490. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39491. */
  39492. opacityTexture: Nullable<BaseTexture>;
  39493. private _reflectionTexture;
  39494. /**
  39495. * Define the texture used to display the reflection.
  39496. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39497. */
  39498. reflectionTexture: Nullable<BaseTexture>;
  39499. private _emissiveTexture;
  39500. /**
  39501. * Define texture of the material as if self lit.
  39502. * This will be mixed in the final result even in the absence of light.
  39503. */
  39504. emissiveTexture: Nullable<BaseTexture>;
  39505. private _specularTexture;
  39506. /**
  39507. * Define how the color and intensity of the highlight given by the light in the material.
  39508. */
  39509. specularTexture: Nullable<BaseTexture>;
  39510. private _bumpTexture;
  39511. /**
  39512. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39513. * 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.
  39514. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39515. */
  39516. bumpTexture: Nullable<BaseTexture>;
  39517. private _lightmapTexture;
  39518. /**
  39519. * Complex lighting can be computationally expensive to compute at runtime.
  39520. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39521. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39522. */
  39523. lightmapTexture: Nullable<BaseTexture>;
  39524. private _refractionTexture;
  39525. /**
  39526. * Define the texture used to display the refraction.
  39527. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39528. */
  39529. refractionTexture: Nullable<BaseTexture>;
  39530. /**
  39531. * The color of the material lit by the environmental background lighting.
  39532. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39533. */
  39534. ambientColor: Color3;
  39535. /**
  39536. * The basic color of the material as viewed under a light.
  39537. */
  39538. diffuseColor: Color3;
  39539. /**
  39540. * Define how the color and intensity of the highlight given by the light in the material.
  39541. */
  39542. specularColor: Color3;
  39543. /**
  39544. * Define the color of the material as if self lit.
  39545. * This will be mixed in the final result even in the absence of light.
  39546. */
  39547. emissiveColor: Color3;
  39548. /**
  39549. * Defines how sharp are the highlights in the material.
  39550. * The bigger the value the sharper giving a more glossy feeling to the result.
  39551. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39552. */
  39553. specularPower: number;
  39554. private _useAlphaFromDiffuseTexture;
  39555. /**
  39556. * Does the transparency come from the diffuse texture alpha channel.
  39557. */
  39558. useAlphaFromDiffuseTexture: boolean;
  39559. private _useEmissiveAsIllumination;
  39560. /**
  39561. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39562. */
  39563. useEmissiveAsIllumination: boolean;
  39564. private _linkEmissiveWithDiffuse;
  39565. /**
  39566. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39567. * the emissive level when the final color is close to one.
  39568. */
  39569. linkEmissiveWithDiffuse: boolean;
  39570. private _useSpecularOverAlpha;
  39571. /**
  39572. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39573. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39574. */
  39575. useSpecularOverAlpha: boolean;
  39576. private _useReflectionOverAlpha;
  39577. /**
  39578. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39579. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39580. */
  39581. useReflectionOverAlpha: boolean;
  39582. private _disableLighting;
  39583. /**
  39584. * Does lights from the scene impacts this material.
  39585. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39586. */
  39587. disableLighting: boolean;
  39588. private _useObjectSpaceNormalMap;
  39589. /**
  39590. * Allows using an object space normal map (instead of tangent space).
  39591. */
  39592. useObjectSpaceNormalMap: boolean;
  39593. private _useParallax;
  39594. /**
  39595. * Is parallax enabled or not.
  39596. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39597. */
  39598. useParallax: boolean;
  39599. private _useParallaxOcclusion;
  39600. /**
  39601. * Is parallax occlusion enabled or not.
  39602. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39603. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39604. */
  39605. useParallaxOcclusion: boolean;
  39606. /**
  39607. * 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.
  39608. */
  39609. parallaxScaleBias: number;
  39610. private _roughness;
  39611. /**
  39612. * Helps to define how blurry the reflections should appears in the material.
  39613. */
  39614. roughness: number;
  39615. /**
  39616. * In case of refraction, define the value of the indice of refraction.
  39617. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39618. */
  39619. indexOfRefraction: number;
  39620. /**
  39621. * Invert the refraction texture alongside the y axis.
  39622. * It can be useful with procedural textures or probe for instance.
  39623. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39624. */
  39625. invertRefractionY: boolean;
  39626. /**
  39627. * Defines the alpha limits in alpha test mode.
  39628. */
  39629. alphaCutOff: number;
  39630. private _useLightmapAsShadowmap;
  39631. /**
  39632. * In case of light mapping, define whether the map contains light or shadow informations.
  39633. */
  39634. useLightmapAsShadowmap: boolean;
  39635. private _diffuseFresnelParameters;
  39636. /**
  39637. * Define the diffuse fresnel parameters of the material.
  39638. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39639. */
  39640. diffuseFresnelParameters: FresnelParameters;
  39641. private _opacityFresnelParameters;
  39642. /**
  39643. * Define the opacity fresnel parameters of the material.
  39644. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39645. */
  39646. opacityFresnelParameters: FresnelParameters;
  39647. private _reflectionFresnelParameters;
  39648. /**
  39649. * Define the reflection fresnel parameters of the material.
  39650. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39651. */
  39652. reflectionFresnelParameters: FresnelParameters;
  39653. private _refractionFresnelParameters;
  39654. /**
  39655. * Define the refraction fresnel parameters of the material.
  39656. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39657. */
  39658. refractionFresnelParameters: FresnelParameters;
  39659. private _emissiveFresnelParameters;
  39660. /**
  39661. * Define the emissive fresnel parameters of the material.
  39662. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39663. */
  39664. emissiveFresnelParameters: FresnelParameters;
  39665. private _useReflectionFresnelFromSpecular;
  39666. /**
  39667. * If true automatically deducts the fresnels values from the material specularity.
  39668. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39669. */
  39670. useReflectionFresnelFromSpecular: boolean;
  39671. private _useGlossinessFromSpecularMapAlpha;
  39672. /**
  39673. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39674. */
  39675. useGlossinessFromSpecularMapAlpha: boolean;
  39676. private _maxSimultaneousLights;
  39677. /**
  39678. * Defines the maximum number of lights that can be used in the material
  39679. */
  39680. maxSimultaneousLights: number;
  39681. private _invertNormalMapX;
  39682. /**
  39683. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39684. */
  39685. invertNormalMapX: boolean;
  39686. private _invertNormalMapY;
  39687. /**
  39688. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39689. */
  39690. invertNormalMapY: boolean;
  39691. private _twoSidedLighting;
  39692. /**
  39693. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39694. */
  39695. twoSidedLighting: boolean;
  39696. /**
  39697. * Default configuration related to image processing available in the standard Material.
  39698. */
  39699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39700. /**
  39701. * Gets the image processing configuration used either in this material.
  39702. */
  39703. /**
  39704. * Sets the Default image processing configuration used either in the this material.
  39705. *
  39706. * If sets to null, the scene one is in use.
  39707. */
  39708. imageProcessingConfiguration: ImageProcessingConfiguration;
  39709. /**
  39710. * Keep track of the image processing observer to allow dispose and replace.
  39711. */
  39712. private _imageProcessingObserver;
  39713. /**
  39714. * Attaches a new image processing configuration to the Standard Material.
  39715. * @param configuration
  39716. */
  39717. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39718. /**
  39719. * Gets wether the color curves effect is enabled.
  39720. */
  39721. /**
  39722. * Sets wether the color curves effect is enabled.
  39723. */
  39724. cameraColorCurvesEnabled: boolean;
  39725. /**
  39726. * Gets wether the color grading effect is enabled.
  39727. */
  39728. /**
  39729. * Gets wether the color grading effect is enabled.
  39730. */
  39731. cameraColorGradingEnabled: boolean;
  39732. /**
  39733. * Gets wether tonemapping is enabled or not.
  39734. */
  39735. /**
  39736. * Sets wether tonemapping is enabled or not
  39737. */
  39738. cameraToneMappingEnabled: boolean;
  39739. /**
  39740. * The camera exposure used on this material.
  39741. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39742. * This corresponds to a photographic exposure.
  39743. */
  39744. /**
  39745. * The camera exposure used on this material.
  39746. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39747. * This corresponds to a photographic exposure.
  39748. */
  39749. cameraExposure: number;
  39750. /**
  39751. * Gets The camera contrast used on this material.
  39752. */
  39753. /**
  39754. * Sets The camera contrast used on this material.
  39755. */
  39756. cameraContrast: number;
  39757. /**
  39758. * Gets the Color Grading 2D Lookup Texture.
  39759. */
  39760. /**
  39761. * Sets the Color Grading 2D Lookup Texture.
  39762. */
  39763. cameraColorGradingTexture: Nullable<BaseTexture>;
  39764. /**
  39765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39767. * 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;
  39768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39769. */
  39770. /**
  39771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39773. * 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;
  39774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39775. */
  39776. cameraColorCurves: Nullable<ColorCurves>;
  39777. /**
  39778. * Custom callback helping to override the default shader used in the material.
  39779. */
  39780. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39781. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39782. protected _worldViewProjectionMatrix: Matrix;
  39783. protected _globalAmbientColor: Color3;
  39784. protected _useLogarithmicDepth: boolean;
  39785. /**
  39786. * Instantiates a new standard material.
  39787. * This is the default material used in Babylon. It is the best trade off between quality
  39788. * and performances.
  39789. * @see http://doc.babylonjs.com/babylon101/materials
  39790. * @param name Define the name of the material in the scene
  39791. * @param scene Define the scene the material belong to
  39792. */
  39793. constructor(name: string, scene: Scene);
  39794. /**
  39795. * Gets a boolean indicating that current material needs to register RTT
  39796. */
  39797. readonly hasRenderTargetTextures: boolean;
  39798. /**
  39799. * Gets the current class name of the material e.g. "StandardMaterial"
  39800. * Mainly use in serialization.
  39801. * @returns the class name
  39802. */
  39803. getClassName(): string;
  39804. /**
  39805. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39806. * You can try switching to logarithmic depth.
  39807. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39808. */
  39809. useLogarithmicDepth: boolean;
  39810. /**
  39811. * Specifies if the material will require alpha blending
  39812. * @returns a boolean specifying if alpha blending is needed
  39813. */
  39814. needAlphaBlending(): boolean;
  39815. /**
  39816. * Specifies if this material should be rendered in alpha test mode
  39817. * @returns a boolean specifying if an alpha test is needed.
  39818. */
  39819. needAlphaTesting(): boolean;
  39820. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39821. /**
  39822. * Get the texture used for alpha test purpose.
  39823. * @returns the diffuse texture in case of the standard material.
  39824. */
  39825. getAlphaTestTexture(): Nullable<BaseTexture>;
  39826. /**
  39827. * Get if the submesh is ready to be used and all its information available.
  39828. * Child classes can use it to update shaders
  39829. * @param mesh defines the mesh to check
  39830. * @param subMesh defines which submesh to check
  39831. * @param useInstances specifies that instances should be used
  39832. * @returns a boolean indicating that the submesh is ready or not
  39833. */
  39834. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39835. /**
  39836. * Builds the material UBO layouts.
  39837. * Used internally during the effect preparation.
  39838. */
  39839. buildUniformLayout(): void;
  39840. /**
  39841. * Unbinds the material from the mesh
  39842. */
  39843. unbind(): void;
  39844. /**
  39845. * Binds the submesh to this material by preparing the effect and shader to draw
  39846. * @param world defines the world transformation matrix
  39847. * @param mesh defines the mesh containing the submesh
  39848. * @param subMesh defines the submesh to bind the material to
  39849. */
  39850. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39851. /**
  39852. * Get the list of animatables in the material.
  39853. * @returns the list of animatables object used in the material
  39854. */
  39855. getAnimatables(): IAnimatable[];
  39856. /**
  39857. * Gets the active textures from the material
  39858. * @returns an array of textures
  39859. */
  39860. getActiveTextures(): BaseTexture[];
  39861. /**
  39862. * Specifies if the material uses a texture
  39863. * @param texture defines the texture to check against the material
  39864. * @returns a boolean specifying if the material uses the texture
  39865. */
  39866. hasTexture(texture: BaseTexture): boolean;
  39867. /**
  39868. * Disposes the material
  39869. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39870. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39871. */
  39872. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39873. /**
  39874. * Makes a duplicate of the material, and gives it a new name
  39875. * @param name defines the new name for the duplicated material
  39876. * @returns the cloned material
  39877. */
  39878. clone(name: string): StandardMaterial;
  39879. /**
  39880. * Serializes this material in a JSON representation
  39881. * @returns the serialized material object
  39882. */
  39883. serialize(): any;
  39884. /**
  39885. * Creates a standard material from parsed material data
  39886. * @param source defines the JSON representation of the material
  39887. * @param scene defines the hosting scene
  39888. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39889. * @returns a new standard material
  39890. */
  39891. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39892. /**
  39893. * Are diffuse textures enabled in the application.
  39894. */
  39895. static DiffuseTextureEnabled: boolean;
  39896. /**
  39897. * Are ambient textures enabled in the application.
  39898. */
  39899. static AmbientTextureEnabled: boolean;
  39900. /**
  39901. * Are opacity textures enabled in the application.
  39902. */
  39903. static OpacityTextureEnabled: boolean;
  39904. /**
  39905. * Are reflection textures enabled in the application.
  39906. */
  39907. static ReflectionTextureEnabled: boolean;
  39908. /**
  39909. * Are emissive textures enabled in the application.
  39910. */
  39911. static EmissiveTextureEnabled: boolean;
  39912. /**
  39913. * Are specular textures enabled in the application.
  39914. */
  39915. static SpecularTextureEnabled: boolean;
  39916. /**
  39917. * Are bump textures enabled in the application.
  39918. */
  39919. static BumpTextureEnabled: boolean;
  39920. /**
  39921. * Are lightmap textures enabled in the application.
  39922. */
  39923. static LightmapTextureEnabled: boolean;
  39924. /**
  39925. * Are refraction textures enabled in the application.
  39926. */
  39927. static RefractionTextureEnabled: boolean;
  39928. /**
  39929. * Are color grading textures enabled in the application.
  39930. */
  39931. static ColorGradingTextureEnabled: boolean;
  39932. /**
  39933. * Are fresnels enabled in the application.
  39934. */
  39935. static FresnelEnabled: boolean;
  39936. }
  39937. }
  39938. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39939. import { Scene } from "babylonjs/scene";
  39940. import { Texture } from "babylonjs/Materials/Textures/texture";
  39941. /**
  39942. * A class extending Texture allowing drawing on a texture
  39943. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39944. */
  39945. export class DynamicTexture extends Texture {
  39946. private _generateMipMaps;
  39947. private _canvas;
  39948. private _context;
  39949. private _engine;
  39950. /**
  39951. * Creates a DynamicTexture
  39952. * @param name defines the name of the texture
  39953. * @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
  39954. * @param scene defines the scene where you want the texture
  39955. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39956. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39957. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39958. */
  39959. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39960. /**
  39961. * Get the current class name of the texture useful for serialization or dynamic coding.
  39962. * @returns "DynamicTexture"
  39963. */
  39964. getClassName(): string;
  39965. /**
  39966. * Gets the current state of canRescale
  39967. */
  39968. readonly canRescale: boolean;
  39969. private _recreate;
  39970. /**
  39971. * Scales the texture
  39972. * @param ratio the scale factor to apply to both width and height
  39973. */
  39974. scale(ratio: number): void;
  39975. /**
  39976. * Resizes the texture
  39977. * @param width the new width
  39978. * @param height the new height
  39979. */
  39980. scaleTo(width: number, height: number): void;
  39981. /**
  39982. * Gets the context of the canvas used by the texture
  39983. * @returns the canvas context of the dynamic texture
  39984. */
  39985. getContext(): CanvasRenderingContext2D;
  39986. /**
  39987. * Clears the texture
  39988. */
  39989. clear(): void;
  39990. /**
  39991. * Updates the texture
  39992. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39993. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39994. */
  39995. update(invertY?: boolean, premulAlpha?: boolean): void;
  39996. /**
  39997. * Draws text onto the texture
  39998. * @param text defines the text to be drawn
  39999. * @param x defines the placement of the text from the left
  40000. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40001. * @param font defines the font to be used with font-style, font-size, font-name
  40002. * @param color defines the color used for the text
  40003. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40004. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40005. * @param update defines whether texture is immediately update (default is true)
  40006. */
  40007. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40008. /**
  40009. * Clones the texture
  40010. * @returns the clone of the texture.
  40011. */
  40012. clone(): DynamicTexture;
  40013. /**
  40014. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40015. * @returns a serialized dynamic texture object
  40016. */
  40017. serialize(): any;
  40018. /** @hidden */
  40019. _rebuild(): void;
  40020. }
  40021. }
  40022. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40023. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40024. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40025. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40026. /** @hidden */
  40027. export var imageProcessingPixelShader: {
  40028. name: string;
  40029. shader: string;
  40030. };
  40031. }
  40032. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40033. import { Nullable } from "babylonjs/types";
  40034. import { Color4 } from "babylonjs/Maths/math";
  40035. import { Camera } from "babylonjs/Cameras/camera";
  40036. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40037. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40038. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40039. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40040. import { Engine } from "babylonjs/Engines/engine";
  40041. import "babylonjs/Shaders/imageProcessing.fragment";
  40042. import "babylonjs/Shaders/postprocess.vertex";
  40043. /**
  40044. * ImageProcessingPostProcess
  40045. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40046. */
  40047. export class ImageProcessingPostProcess extends PostProcess {
  40048. /**
  40049. * Default configuration related to image processing available in the PBR Material.
  40050. */
  40051. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40052. /**
  40053. * Gets the image processing configuration used either in this material.
  40054. */
  40055. /**
  40056. * Sets the Default image processing configuration used either in the this material.
  40057. *
  40058. * If sets to null, the scene one is in use.
  40059. */
  40060. imageProcessingConfiguration: ImageProcessingConfiguration;
  40061. /**
  40062. * Keep track of the image processing observer to allow dispose and replace.
  40063. */
  40064. private _imageProcessingObserver;
  40065. /**
  40066. * Attaches a new image processing configuration to the PBR Material.
  40067. * @param configuration
  40068. */
  40069. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40070. /**
  40071. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40072. */
  40073. /**
  40074. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40075. */
  40076. colorCurves: Nullable<ColorCurves>;
  40077. /**
  40078. * Gets wether the color curves effect is enabled.
  40079. */
  40080. /**
  40081. * Sets wether the color curves effect is enabled.
  40082. */
  40083. colorCurvesEnabled: boolean;
  40084. /**
  40085. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40086. */
  40087. /**
  40088. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40089. */
  40090. colorGradingTexture: Nullable<BaseTexture>;
  40091. /**
  40092. * Gets wether the color grading effect is enabled.
  40093. */
  40094. /**
  40095. * Gets wether the color grading effect is enabled.
  40096. */
  40097. colorGradingEnabled: boolean;
  40098. /**
  40099. * Gets exposure used in the effect.
  40100. */
  40101. /**
  40102. * Sets exposure used in the effect.
  40103. */
  40104. exposure: number;
  40105. /**
  40106. * Gets wether tonemapping is enabled or not.
  40107. */
  40108. /**
  40109. * Sets wether tonemapping is enabled or not
  40110. */
  40111. toneMappingEnabled: boolean;
  40112. /**
  40113. * Gets the type of tone mapping effect.
  40114. */
  40115. /**
  40116. * Sets the type of tone mapping effect.
  40117. */
  40118. toneMappingType: number;
  40119. /**
  40120. * Gets contrast used in the effect.
  40121. */
  40122. /**
  40123. * Sets contrast used in the effect.
  40124. */
  40125. contrast: number;
  40126. /**
  40127. * Gets Vignette stretch size.
  40128. */
  40129. /**
  40130. * Sets Vignette stretch size.
  40131. */
  40132. vignetteStretch: number;
  40133. /**
  40134. * Gets Vignette centre X Offset.
  40135. */
  40136. /**
  40137. * Sets Vignette centre X Offset.
  40138. */
  40139. vignetteCentreX: number;
  40140. /**
  40141. * Gets Vignette centre Y Offset.
  40142. */
  40143. /**
  40144. * Sets Vignette centre Y Offset.
  40145. */
  40146. vignetteCentreY: number;
  40147. /**
  40148. * Gets Vignette weight or intensity of the vignette effect.
  40149. */
  40150. /**
  40151. * Sets Vignette weight or intensity of the vignette effect.
  40152. */
  40153. vignetteWeight: number;
  40154. /**
  40155. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40156. * if vignetteEnabled is set to true.
  40157. */
  40158. /**
  40159. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40160. * if vignetteEnabled is set to true.
  40161. */
  40162. vignetteColor: Color4;
  40163. /**
  40164. * Gets Camera field of view used by the Vignette effect.
  40165. */
  40166. /**
  40167. * Sets Camera field of view used by the Vignette effect.
  40168. */
  40169. vignetteCameraFov: number;
  40170. /**
  40171. * Gets the vignette blend mode allowing different kind of effect.
  40172. */
  40173. /**
  40174. * Sets the vignette blend mode allowing different kind of effect.
  40175. */
  40176. vignetteBlendMode: number;
  40177. /**
  40178. * Gets wether the vignette effect is enabled.
  40179. */
  40180. /**
  40181. * Sets wether the vignette effect is enabled.
  40182. */
  40183. vignetteEnabled: boolean;
  40184. private _fromLinearSpace;
  40185. /**
  40186. * Gets wether the input of the processing is in Gamma or Linear Space.
  40187. */
  40188. /**
  40189. * Sets wether the input of the processing is in Gamma or Linear Space.
  40190. */
  40191. fromLinearSpace: boolean;
  40192. /**
  40193. * Defines cache preventing GC.
  40194. */
  40195. private _defines;
  40196. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40197. /**
  40198. * "ImageProcessingPostProcess"
  40199. * @returns "ImageProcessingPostProcess"
  40200. */
  40201. getClassName(): string;
  40202. protected _updateParameters(): void;
  40203. dispose(camera?: Camera): void;
  40204. }
  40205. }
  40206. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40207. import { Scene } from "babylonjs/scene";
  40208. import { Color3 } from "babylonjs/Maths/math";
  40209. import { Mesh } from "babylonjs/Meshes/mesh";
  40210. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40211. /**
  40212. * Class containing static functions to help procedurally build meshes
  40213. */
  40214. export class GroundBuilder {
  40215. /**
  40216. * Creates a ground mesh
  40217. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40218. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40220. * @param name defines the name of the mesh
  40221. * @param options defines the options used to create the mesh
  40222. * @param scene defines the hosting scene
  40223. * @returns the ground mesh
  40224. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40225. */
  40226. static CreateGround(name: string, options: {
  40227. width?: number;
  40228. height?: number;
  40229. subdivisions?: number;
  40230. subdivisionsX?: number;
  40231. subdivisionsY?: number;
  40232. updatable?: boolean;
  40233. }, scene: any): Mesh;
  40234. /**
  40235. * Creates a tiled ground mesh
  40236. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40237. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40238. * * 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
  40239. * * 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
  40240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40241. * @param name defines the name of the mesh
  40242. * @param options defines the options used to create the mesh
  40243. * @param scene defines the hosting scene
  40244. * @returns the tiled ground mesh
  40245. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40246. */
  40247. static CreateTiledGround(name: string, options: {
  40248. xmin: number;
  40249. zmin: number;
  40250. xmax: number;
  40251. zmax: number;
  40252. subdivisions?: {
  40253. w: number;
  40254. h: number;
  40255. };
  40256. precision?: {
  40257. w: number;
  40258. h: number;
  40259. };
  40260. updatable?: boolean;
  40261. }, scene: Scene): Mesh;
  40262. /**
  40263. * Creates a ground mesh from a height map
  40264. * * The parameter `url` sets the URL of the height map image resource.
  40265. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40266. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40267. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40268. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40269. * * 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.
  40270. * * 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).
  40271. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40273. * @param name defines the name of the mesh
  40274. * @param url defines the url to the height map
  40275. * @param options defines the options used to create the mesh
  40276. * @param scene defines the hosting scene
  40277. * @returns the ground mesh
  40278. * @see https://doc.babylonjs.com/babylon101/height_map
  40279. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40280. */
  40281. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40282. width?: number;
  40283. height?: number;
  40284. subdivisions?: number;
  40285. minHeight?: number;
  40286. maxHeight?: number;
  40287. colorFilter?: Color3;
  40288. alphaFilter?: number;
  40289. updatable?: boolean;
  40290. onReady?: (mesh: GroundMesh) => void;
  40291. }, scene: Scene): GroundMesh;
  40292. }
  40293. }
  40294. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40295. import { Vector4 } from "babylonjs/Maths/math";
  40296. import { Mesh } from "babylonjs/Meshes/mesh";
  40297. /**
  40298. * Class containing static functions to help procedurally build meshes
  40299. */
  40300. export class TorusBuilder {
  40301. /**
  40302. * Creates a torus mesh
  40303. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40304. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40305. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40309. * @param name defines the name of the mesh
  40310. * @param options defines the options used to create the mesh
  40311. * @param scene defines the hosting scene
  40312. * @returns the torus mesh
  40313. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40314. */
  40315. static CreateTorus(name: string, options: {
  40316. diameter?: number;
  40317. thickness?: number;
  40318. tessellation?: number;
  40319. updatable?: boolean;
  40320. sideOrientation?: number;
  40321. frontUVs?: Vector4;
  40322. backUVs?: Vector4;
  40323. }, scene: any): Mesh;
  40324. }
  40325. }
  40326. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40327. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40328. import { Mesh } from "babylonjs/Meshes/mesh";
  40329. /**
  40330. * Class containing static functions to help procedurally build meshes
  40331. */
  40332. export class CylinderBuilder {
  40333. /**
  40334. * Creates a cylinder or a cone mesh
  40335. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40336. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40337. * * 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.
  40338. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40339. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40340. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40341. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40342. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40343. * * 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).
  40344. * * 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
  40345. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40346. * * 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
  40347. * * 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.
  40348. * * If `enclose` is false, a ring surface is one element.
  40349. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40350. * * 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
  40351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40354. * @param name defines the name of the mesh
  40355. * @param options defines the options used to create the mesh
  40356. * @param scene defines the hosting scene
  40357. * @returns the cylinder mesh
  40358. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40359. */
  40360. static CreateCylinder(name: string, options: {
  40361. height?: number;
  40362. diameterTop?: number;
  40363. diameterBottom?: number;
  40364. diameter?: number;
  40365. tessellation?: number;
  40366. subdivisions?: number;
  40367. arc?: number;
  40368. faceColors?: Color4[];
  40369. faceUV?: Vector4[];
  40370. updatable?: boolean;
  40371. hasRings?: boolean;
  40372. enclose?: boolean;
  40373. sideOrientation?: number;
  40374. frontUVs?: Vector4;
  40375. backUVs?: Vector4;
  40376. }, scene: any): Mesh;
  40377. }
  40378. }
  40379. declare module "babylonjs/Gamepads/gamepadManager" {
  40380. import { Observable } from "babylonjs/Misc/observable";
  40381. import { Nullable } from "babylonjs/types";
  40382. import { Scene } from "babylonjs/scene";
  40383. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40384. /**
  40385. * Manager for handling gamepads
  40386. */
  40387. export class GamepadManager {
  40388. private _scene?;
  40389. private _babylonGamepads;
  40390. private _oneGamepadConnected;
  40391. /** @hidden */
  40392. _isMonitoring: boolean;
  40393. private _gamepadEventSupported;
  40394. private _gamepadSupport;
  40395. /**
  40396. * observable to be triggered when the gamepad controller has been connected
  40397. */
  40398. onGamepadConnectedObservable: Observable<Gamepad>;
  40399. /**
  40400. * observable to be triggered when the gamepad controller has been disconnected
  40401. */
  40402. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40403. private _onGamepadConnectedEvent;
  40404. private _onGamepadDisconnectedEvent;
  40405. /**
  40406. * Initializes the gamepad manager
  40407. * @param _scene BabylonJS scene
  40408. */
  40409. constructor(_scene?: Scene | undefined);
  40410. /**
  40411. * The gamepads in the game pad manager
  40412. */
  40413. readonly gamepads: Gamepad[];
  40414. /**
  40415. * Get the gamepad controllers based on type
  40416. * @param type The type of gamepad controller
  40417. * @returns Nullable gamepad
  40418. */
  40419. getGamepadByType(type?: number): Nullable<Gamepad>;
  40420. /**
  40421. * Disposes the gamepad manager
  40422. */
  40423. dispose(): void;
  40424. private _addNewGamepad;
  40425. private _startMonitoringGamepads;
  40426. private _stopMonitoringGamepads;
  40427. /** @hidden */
  40428. _checkGamepadsStatus(): void;
  40429. private _updateGamepadObjects;
  40430. }
  40431. }
  40432. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40433. import { Nullable } from "babylonjs/types";
  40434. import { Scene } from "babylonjs/scene";
  40435. import { ISceneComponent } from "babylonjs/sceneComponent";
  40436. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40437. module "babylonjs/scene" {
  40438. interface Scene {
  40439. /** @hidden */
  40440. _gamepadManager: Nullable<GamepadManager>;
  40441. /**
  40442. * Gets the gamepad manager associated with the scene
  40443. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40444. */
  40445. gamepadManager: GamepadManager;
  40446. }
  40447. }
  40448. module "babylonjs/Cameras/freeCameraInputsManager" {
  40449. /**
  40450. * Interface representing a free camera inputs manager
  40451. */
  40452. interface FreeCameraInputsManager {
  40453. /**
  40454. * Adds gamepad input support to the FreeCameraInputsManager.
  40455. * @returns the FreeCameraInputsManager
  40456. */
  40457. addGamepad(): FreeCameraInputsManager;
  40458. }
  40459. }
  40460. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40461. /**
  40462. * Interface representing an arc rotate camera inputs manager
  40463. */
  40464. interface ArcRotateCameraInputsManager {
  40465. /**
  40466. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40467. * @returns the camera inputs manager
  40468. */
  40469. addGamepad(): ArcRotateCameraInputsManager;
  40470. }
  40471. }
  40472. /**
  40473. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40474. */
  40475. export class GamepadSystemSceneComponent implements ISceneComponent {
  40476. /**
  40477. * The component name helpfull to identify the component in the list of scene components.
  40478. */
  40479. readonly name: string;
  40480. /**
  40481. * The scene the component belongs to.
  40482. */
  40483. scene: Scene;
  40484. /**
  40485. * Creates a new instance of the component for the given scene
  40486. * @param scene Defines the scene to register the component in
  40487. */
  40488. constructor(scene: Scene);
  40489. /**
  40490. * Registers the component in a given scene
  40491. */
  40492. register(): void;
  40493. /**
  40494. * Rebuilds the elements related to this component in case of
  40495. * context lost for instance.
  40496. */
  40497. rebuild(): void;
  40498. /**
  40499. * Disposes the component and the associated ressources
  40500. */
  40501. dispose(): void;
  40502. private _beforeCameraUpdate;
  40503. }
  40504. }
  40505. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40506. import { Observable } from "babylonjs/Misc/observable";
  40507. import { Nullable } from "babylonjs/types";
  40508. import { Camera } from "babylonjs/Cameras/camera";
  40509. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40510. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40511. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40512. import { Scene } from "babylonjs/scene";
  40513. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40514. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40516. import { Mesh } from "babylonjs/Meshes/mesh";
  40517. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40518. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40519. import "babylonjs/Meshes/Builders/groundBuilder";
  40520. import "babylonjs/Meshes/Builders/torusBuilder";
  40521. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40522. import "babylonjs/Gamepads/gamepadSceneComponent";
  40523. import "babylonjs/Animations/animatable";
  40524. /**
  40525. * Options to modify the vr teleportation behavior.
  40526. */
  40527. export interface VRTeleportationOptions {
  40528. /**
  40529. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40530. */
  40531. floorMeshName?: string;
  40532. /**
  40533. * A list of meshes to be used as the teleportation floor. (default: empty)
  40534. */
  40535. floorMeshes?: Mesh[];
  40536. }
  40537. /**
  40538. * Options to modify the vr experience helper's behavior.
  40539. */
  40540. export interface VRExperienceHelperOptions extends WebVROptions {
  40541. /**
  40542. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40543. */
  40544. createDeviceOrientationCamera?: boolean;
  40545. /**
  40546. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40547. */
  40548. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40549. /**
  40550. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40551. */
  40552. laserToggle?: boolean;
  40553. /**
  40554. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40555. */
  40556. floorMeshes?: Mesh[];
  40557. /**
  40558. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40559. */
  40560. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40561. }
  40562. /**
  40563. * Event containing information after VR has been entered
  40564. */
  40565. export class OnAfterEnteringVRObservableEvent {
  40566. /**
  40567. * If entering vr was successful
  40568. */
  40569. success: boolean;
  40570. }
  40571. /**
  40572. * Helps to quickly add VR support to an existing scene.
  40573. * See http://doc.babylonjs.com/how_to/webvr_helper
  40574. */
  40575. export class VRExperienceHelper {
  40576. /** Options to modify the vr experience helper's behavior. */
  40577. webVROptions: VRExperienceHelperOptions;
  40578. private _scene;
  40579. private _position;
  40580. private _btnVR;
  40581. private _btnVRDisplayed;
  40582. private _webVRsupported;
  40583. private _webVRready;
  40584. private _webVRrequesting;
  40585. private _webVRpresenting;
  40586. private _hasEnteredVR;
  40587. private _fullscreenVRpresenting;
  40588. private _canvas;
  40589. private _webVRCamera;
  40590. private _vrDeviceOrientationCamera;
  40591. private _deviceOrientationCamera;
  40592. private _existingCamera;
  40593. private _onKeyDown;
  40594. private _onVrDisplayPresentChange;
  40595. private _onVRDisplayChanged;
  40596. private _onVRRequestPresentStart;
  40597. private _onVRRequestPresentComplete;
  40598. /**
  40599. * Observable raised right before entering VR.
  40600. */
  40601. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40602. /**
  40603. * Observable raised when entering VR has completed.
  40604. */
  40605. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40606. /**
  40607. * Observable raised when exiting VR.
  40608. */
  40609. onExitingVRObservable: Observable<VRExperienceHelper>;
  40610. /**
  40611. * Observable raised when controller mesh is loaded.
  40612. */
  40613. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40614. /** Return this.onEnteringVRObservable
  40615. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40616. */
  40617. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40618. /** Return this.onExitingVRObservable
  40619. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40620. */
  40621. readonly onExitingVR: Observable<VRExperienceHelper>;
  40622. /** Return this.onControllerMeshLoadedObservable
  40623. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40624. */
  40625. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40626. private _rayLength;
  40627. private _useCustomVRButton;
  40628. private _teleportationRequested;
  40629. private _teleportActive;
  40630. private _floorMeshName;
  40631. private _floorMeshesCollection;
  40632. private _rotationAllowed;
  40633. private _teleportBackwardsVector;
  40634. private _teleportationTarget;
  40635. private _isDefaultTeleportationTarget;
  40636. private _postProcessMove;
  40637. private _teleportationFillColor;
  40638. private _teleportationBorderColor;
  40639. private _rotationAngle;
  40640. private _haloCenter;
  40641. private _cameraGazer;
  40642. private _padSensibilityUp;
  40643. private _padSensibilityDown;
  40644. private _leftController;
  40645. private _rightController;
  40646. /**
  40647. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40648. */
  40649. onNewMeshSelected: Observable<AbstractMesh>;
  40650. /**
  40651. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40652. */
  40653. onNewMeshPicked: Observable<PickingInfo>;
  40654. private _circleEase;
  40655. /**
  40656. * Observable raised before camera teleportation
  40657. */
  40658. onBeforeCameraTeleport: Observable<Vector3>;
  40659. /**
  40660. * Observable raised after camera teleportation
  40661. */
  40662. onAfterCameraTeleport: Observable<Vector3>;
  40663. /**
  40664. * Observable raised when current selected mesh gets unselected
  40665. */
  40666. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40667. private _raySelectionPredicate;
  40668. /**
  40669. * To be optionaly changed by user to define custom ray selection
  40670. */
  40671. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40672. /**
  40673. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40674. */
  40675. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40676. /**
  40677. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40678. */
  40679. teleportationEnabled: boolean;
  40680. private _defaultHeight;
  40681. private _teleportationInitialized;
  40682. private _interactionsEnabled;
  40683. private _interactionsRequested;
  40684. private _displayGaze;
  40685. private _displayLaserPointer;
  40686. /**
  40687. * The mesh used to display where the user is going to teleport.
  40688. */
  40689. /**
  40690. * Sets the mesh to be used to display where the user is going to teleport.
  40691. */
  40692. teleportationTarget: Mesh;
  40693. /**
  40694. * 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
  40695. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40696. * See http://doc.babylonjs.com/resources/baking_transformations
  40697. */
  40698. gazeTrackerMesh: Mesh;
  40699. /**
  40700. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40701. */
  40702. updateGazeTrackerScale: boolean;
  40703. /**
  40704. * If the gaze trackers color should be updated when selecting meshes
  40705. */
  40706. updateGazeTrackerColor: boolean;
  40707. /**
  40708. * The gaze tracking mesh corresponding to the left controller
  40709. */
  40710. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40711. /**
  40712. * The gaze tracking mesh corresponding to the right controller
  40713. */
  40714. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40715. /**
  40716. * If the ray of the gaze should be displayed.
  40717. */
  40718. /**
  40719. * Sets if the ray of the gaze should be displayed.
  40720. */
  40721. displayGaze: boolean;
  40722. /**
  40723. * If the ray of the LaserPointer should be displayed.
  40724. */
  40725. /**
  40726. * Sets if the ray of the LaserPointer should be displayed.
  40727. */
  40728. displayLaserPointer: boolean;
  40729. /**
  40730. * The deviceOrientationCamera used as the camera when not in VR.
  40731. */
  40732. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40733. /**
  40734. * Based on the current WebVR support, returns the current VR camera used.
  40735. */
  40736. readonly currentVRCamera: Nullable<Camera>;
  40737. /**
  40738. * The webVRCamera which is used when in VR.
  40739. */
  40740. readonly webVRCamera: WebVRFreeCamera;
  40741. /**
  40742. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40743. */
  40744. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40745. private readonly _teleportationRequestInitiated;
  40746. /**
  40747. * Defines wether or not Pointer lock should be requested when switching to
  40748. * full screen.
  40749. */
  40750. requestPointerLockOnFullScreen: boolean;
  40751. /**
  40752. * Instantiates a VRExperienceHelper.
  40753. * Helps to quickly add VR support to an existing scene.
  40754. * @param scene The scene the VRExperienceHelper belongs to.
  40755. * @param webVROptions Options to modify the vr experience helper's behavior.
  40756. */
  40757. constructor(scene: Scene,
  40758. /** Options to modify the vr experience helper's behavior. */
  40759. webVROptions?: VRExperienceHelperOptions);
  40760. private _onDefaultMeshLoaded;
  40761. private _onResize;
  40762. private _onFullscreenChange;
  40763. /**
  40764. * Gets a value indicating if we are currently in VR mode.
  40765. */
  40766. readonly isInVRMode: boolean;
  40767. private onVrDisplayPresentChange;
  40768. private onVRDisplayChanged;
  40769. private moveButtonToBottomRight;
  40770. private displayVRButton;
  40771. private updateButtonVisibility;
  40772. private _cachedAngularSensibility;
  40773. /**
  40774. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40775. * Otherwise, will use the fullscreen API.
  40776. */
  40777. enterVR(): void;
  40778. /**
  40779. * Attempt to exit VR, or fullscreen.
  40780. */
  40781. exitVR(): void;
  40782. /**
  40783. * The position of the vr experience helper.
  40784. */
  40785. /**
  40786. * Sets the position of the vr experience helper.
  40787. */
  40788. position: Vector3;
  40789. /**
  40790. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40791. */
  40792. enableInteractions(): void;
  40793. private readonly _noControllerIsActive;
  40794. private beforeRender;
  40795. private _isTeleportationFloor;
  40796. /**
  40797. * Adds a floor mesh to be used for teleportation.
  40798. * @param floorMesh the mesh to be used for teleportation.
  40799. */
  40800. addFloorMesh(floorMesh: Mesh): void;
  40801. /**
  40802. * Removes a floor mesh from being used for teleportation.
  40803. * @param floorMesh the mesh to be removed.
  40804. */
  40805. removeFloorMesh(floorMesh: Mesh): void;
  40806. /**
  40807. * Enables interactions and teleportation using the VR controllers and gaze.
  40808. * @param vrTeleportationOptions options to modify teleportation behavior.
  40809. */
  40810. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40811. private _onNewGamepadConnected;
  40812. private _tryEnableInteractionOnController;
  40813. private _onNewGamepadDisconnected;
  40814. private _enableInteractionOnController;
  40815. private _checkTeleportWithRay;
  40816. private _checkRotate;
  40817. private _checkTeleportBackwards;
  40818. private _enableTeleportationOnController;
  40819. private _createTeleportationCircles;
  40820. private _displayTeleportationTarget;
  40821. private _hideTeleportationTarget;
  40822. private _rotateCamera;
  40823. private _moveTeleportationSelectorTo;
  40824. private _workingVector;
  40825. private _workingQuaternion;
  40826. private _workingMatrix;
  40827. /**
  40828. * Teleports the users feet to the desired location
  40829. * @param location The location where the user's feet should be placed
  40830. */
  40831. teleportCamera(location: Vector3): void;
  40832. private _convertNormalToDirectionOfRay;
  40833. private _castRayAndSelectObject;
  40834. private _notifySelectedMeshUnselected;
  40835. /**
  40836. * Sets the color of the laser ray from the vr controllers.
  40837. * @param color new color for the ray.
  40838. */
  40839. changeLaserColor(color: Color3): void;
  40840. /**
  40841. * Sets the color of the ray from the vr headsets gaze.
  40842. * @param color new color for the ray.
  40843. */
  40844. changeGazeColor(color: Color3): void;
  40845. /**
  40846. * Exits VR and disposes of the vr experience helper
  40847. */
  40848. dispose(): void;
  40849. /**
  40850. * Gets the name of the VRExperienceHelper class
  40851. * @returns "VRExperienceHelper"
  40852. */
  40853. getClassName(): string;
  40854. }
  40855. }
  40856. declare module "babylonjs/Cameras/VR/index" {
  40857. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40858. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40859. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40860. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40861. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40862. export * from "babylonjs/Cameras/VR/webVRCamera";
  40863. }
  40864. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40865. import { Observable } from "babylonjs/Misc/observable";
  40866. import { Nullable } from "babylonjs/types";
  40867. import { IDisposable, Scene } from "babylonjs/scene";
  40868. import { Vector3 } from "babylonjs/Maths/math";
  40869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40870. import { Ray } from "babylonjs/Culling/ray";
  40871. /**
  40872. * Manages an XRSession
  40873. * @see https://doc.babylonjs.com/how_to/webxr
  40874. */
  40875. export class WebXRSessionManager implements IDisposable {
  40876. private scene;
  40877. /**
  40878. * Fires every time a new xrFrame arrives which can be used to update the camera
  40879. */
  40880. onXRFrameObservable: Observable<any>;
  40881. /**
  40882. * Fires when the xr session is ended either by the device or manually done
  40883. */
  40884. onXRSessionEnded: Observable<any>;
  40885. /** @hidden */
  40886. _xrSession: XRSession;
  40887. /** @hidden */
  40888. _frameOfReference: XRFrameOfReference;
  40889. /** @hidden */
  40890. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40891. /** @hidden */
  40892. _currentXRFrame: Nullable<XRFrame>;
  40893. private _xrNavigator;
  40894. private _xrDevice;
  40895. private _tmpMatrix;
  40896. /**
  40897. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40898. * @param scene The scene which the session should be created for
  40899. */
  40900. constructor(scene: Scene);
  40901. /**
  40902. * Initializes the manager
  40903. * After initialization enterXR can be called to start an XR session
  40904. * @returns Promise which resolves after it is initialized
  40905. */
  40906. initializeAsync(): Promise<void>;
  40907. /**
  40908. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40909. * @param sessionCreationOptions xr options to create the session with
  40910. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40911. * @returns Promise which resolves after it enters XR
  40912. */
  40913. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40914. /**
  40915. * Stops the xrSession and restores the renderloop
  40916. * @returns Promise which resolves after it exits XR
  40917. */
  40918. exitXRAsync(): Promise<void>;
  40919. /**
  40920. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40921. * @param ray ray to cast into the environment
  40922. * @returns Promise which resolves with a collision point in the environment if it exists
  40923. */
  40924. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40925. /**
  40926. * Checks if a session would be supported for the creation options specified
  40927. * @param options creation options to check if they are supported
  40928. * @returns true if supported
  40929. */
  40930. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40931. /**
  40932. * @hidden
  40933. * Converts the render layer of xrSession to a render target
  40934. * @param session session to create render target for
  40935. * @param scene scene the new render target should be created for
  40936. */
  40937. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40938. /**
  40939. * Disposes of the session manager
  40940. */
  40941. dispose(): void;
  40942. }
  40943. }
  40944. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40945. import { Scene } from "babylonjs/scene";
  40946. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40947. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40948. /**
  40949. * WebXR Camera which holds the views for the xrSession
  40950. * @see https://doc.babylonjs.com/how_to/webxr
  40951. */
  40952. export class WebXRCamera extends FreeCamera {
  40953. private static _TmpMatrix;
  40954. /**
  40955. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40956. * @param name the name of the camera
  40957. * @param scene the scene to add the camera to
  40958. */
  40959. constructor(name: string, scene: Scene);
  40960. private _updateNumberOfRigCameras;
  40961. /** @hidden */
  40962. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40963. /**
  40964. * Updates the cameras position from the current pose information of the XR session
  40965. * @param xrSessionManager the session containing pose information
  40966. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40967. */
  40968. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40969. }
  40970. }
  40971. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40972. import { Nullable } from "babylonjs/types";
  40973. import { Observable } from "babylonjs/Misc/observable";
  40974. import { IDisposable, Scene } from "babylonjs/scene";
  40975. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40977. import { Ray } from "babylonjs/Culling/ray";
  40978. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40979. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40980. /**
  40981. * States of the webXR experience
  40982. */
  40983. export enum WebXRState {
  40984. /**
  40985. * Transitioning to being in XR mode
  40986. */
  40987. ENTERING_XR = 0,
  40988. /**
  40989. * Transitioning to non XR mode
  40990. */
  40991. EXITING_XR = 1,
  40992. /**
  40993. * In XR mode and presenting
  40994. */
  40995. IN_XR = 2,
  40996. /**
  40997. * Not entered XR mode
  40998. */
  40999. NOT_IN_XR = 3
  41000. }
  41001. /**
  41002. * Helper class used to enable XR
  41003. * @see https://doc.babylonjs.com/how_to/webxr
  41004. */
  41005. export class WebXRExperienceHelper implements IDisposable {
  41006. private scene;
  41007. /**
  41008. * 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
  41009. */
  41010. container: AbstractMesh;
  41011. /**
  41012. * Camera used to render xr content
  41013. */
  41014. camera: WebXRCamera;
  41015. /**
  41016. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41017. */
  41018. state: WebXRState;
  41019. private _setState;
  41020. private static _TmpVector;
  41021. /**
  41022. * Fires when the state of the experience helper has changed
  41023. */
  41024. onStateChangedObservable: Observable<WebXRState>;
  41025. /** @hidden */
  41026. _sessionManager: WebXRSessionManager;
  41027. private _nonVRCamera;
  41028. private _originalSceneAutoClear;
  41029. private _supported;
  41030. /**
  41031. * Creates the experience helper
  41032. * @param scene the scene to attach the experience helper to
  41033. * @returns a promise for the experience helper
  41034. */
  41035. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41036. /**
  41037. * Creates a WebXRExperienceHelper
  41038. * @param scene The scene the helper should be created in
  41039. */
  41040. private constructor();
  41041. /**
  41042. * Exits XR mode and returns the scene to its original state
  41043. * @returns promise that resolves after xr mode has exited
  41044. */
  41045. exitXRAsync(): Promise<void>;
  41046. /**
  41047. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41048. * @param sessionCreationOptions options for the XR session
  41049. * @param frameOfReference frame of reference of the XR session
  41050. * @returns promise that resolves after xr mode has entered
  41051. */
  41052. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41053. /**
  41054. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41055. * @param ray ray to cast into the environment
  41056. * @returns Promise which resolves with a collision point in the environment if it exists
  41057. */
  41058. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41059. /**
  41060. * Updates the global position of the camera by moving the camera's container
  41061. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41062. * @param position The desired global position of the camera
  41063. */
  41064. setPositionOfCameraUsingContainer(position: Vector3): void;
  41065. /**
  41066. * Rotates the xr camera by rotating the camera's container around the camera's position
  41067. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41068. * @param rotation the desired quaternion rotation to apply to the camera
  41069. */
  41070. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41071. /**
  41072. * Checks if the creation options are supported by the xr session
  41073. * @param options creation options
  41074. * @returns true if supported
  41075. */
  41076. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41077. /**
  41078. * Disposes of the experience helper
  41079. */
  41080. dispose(): void;
  41081. }
  41082. }
  41083. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41084. import { Nullable } from "babylonjs/types";
  41085. import { Observable } from "babylonjs/Misc/observable";
  41086. import { IDisposable, Scene } from "babylonjs/scene";
  41087. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41088. /**
  41089. * Button which can be used to enter a different mode of XR
  41090. */
  41091. export class WebXREnterExitUIButton {
  41092. /** button element */
  41093. element: HTMLElement;
  41094. /** XR initialization options for the button */
  41095. initializationOptions: XRSessionCreationOptions;
  41096. /**
  41097. * Creates a WebXREnterExitUIButton
  41098. * @param element button element
  41099. * @param initializationOptions XR initialization options for the button
  41100. */
  41101. constructor(
  41102. /** button element */
  41103. element: HTMLElement,
  41104. /** XR initialization options for the button */
  41105. initializationOptions: XRSessionCreationOptions);
  41106. /**
  41107. * Overwritable function which can be used to update the button's visuals when the state changes
  41108. * @param activeButton the current active button in the UI
  41109. */
  41110. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41111. }
  41112. /**
  41113. * Options to create the webXR UI
  41114. */
  41115. export class WebXREnterExitUIOptions {
  41116. /**
  41117. * Context to enter xr with
  41118. */
  41119. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41120. /**
  41121. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41122. */
  41123. customButtons?: Array<WebXREnterExitUIButton>;
  41124. }
  41125. /**
  41126. * UI to allow the user to enter/exit XR mode
  41127. */
  41128. export class WebXREnterExitUI implements IDisposable {
  41129. private scene;
  41130. private _overlay;
  41131. private _buttons;
  41132. private _activeButton;
  41133. /**
  41134. * Fired every time the active button is changed.
  41135. *
  41136. * When xr is entered via a button that launches xr that button will be the callback parameter
  41137. *
  41138. * When exiting xr the callback parameter will be null)
  41139. */
  41140. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41141. /**
  41142. * Creates UI to allow the user to enter/exit XR mode
  41143. * @param scene the scene to add the ui to
  41144. * @param helper the xr experience helper to enter/exit xr with
  41145. * @param options options to configure the UI
  41146. * @returns the created ui
  41147. */
  41148. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41149. private constructor();
  41150. private _updateButtons;
  41151. /**
  41152. * Disposes of the object
  41153. */
  41154. dispose(): void;
  41155. }
  41156. }
  41157. declare module "babylonjs/Cameras/XR/webXRInput" {
  41158. import { IDisposable, Scene } from "babylonjs/scene";
  41159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41160. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41161. /**
  41162. * Represents an XR input
  41163. */
  41164. export class WebXRController {
  41165. /**
  41166. * 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
  41167. */
  41168. grip?: AbstractMesh;
  41169. /**
  41170. * Pointer which can be used to select objects or attach a visible laser to
  41171. */
  41172. pointer: AbstractMesh;
  41173. /**
  41174. * Creates the controller
  41175. * @see https://doc.babylonjs.com/how_to/webxr
  41176. * @param scene the scene which the controller should be associated to
  41177. */
  41178. constructor(scene: Scene);
  41179. /**
  41180. * Disposes of the object
  41181. */
  41182. dispose(): void;
  41183. }
  41184. /**
  41185. * XR input used to track XR inputs such as controllers/rays
  41186. */
  41187. export class WebXRInput implements IDisposable {
  41188. private helper;
  41189. /**
  41190. * XR controllers being tracked
  41191. */
  41192. controllers: Array<WebXRController>;
  41193. private _tmpMatrix;
  41194. private _frameObserver;
  41195. /**
  41196. * Initializes the WebXRInput
  41197. * @param helper experience helper which the input should be created for
  41198. */
  41199. constructor(helper: WebXRExperienceHelper);
  41200. /**
  41201. * Disposes of the object
  41202. */
  41203. dispose(): void;
  41204. }
  41205. }
  41206. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41207. import { Nullable } from "babylonjs/types";
  41208. import { IDisposable } from "babylonjs/scene";
  41209. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41210. /**
  41211. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41212. */
  41213. export class WebXRManagedOutputCanvas implements IDisposable {
  41214. private _canvas;
  41215. /**
  41216. * xrpresent context of the canvas which can be used to display/mirror xr content
  41217. */
  41218. canvasContext: Nullable<WebGLRenderingContext>;
  41219. /**
  41220. * Initializes the canvas to be added/removed upon entering/exiting xr
  41221. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41222. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41223. */
  41224. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41225. /**
  41226. * Disposes of the object
  41227. */
  41228. dispose(): void;
  41229. private _setManagedOutputCanvas;
  41230. private _addCanvas;
  41231. private _removeCanvas;
  41232. }
  41233. }
  41234. declare module "babylonjs/Cameras/XR/index" {
  41235. export * from "babylonjs/Cameras/XR/webXRCamera";
  41236. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41237. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41238. export * from "babylonjs/Cameras/XR/webXRInput";
  41239. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41240. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41241. }
  41242. declare module "babylonjs/Cameras/RigModes/index" {
  41243. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41244. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41245. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41246. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41247. }
  41248. declare module "babylonjs/Cameras/index" {
  41249. export * from "babylonjs/Cameras/Inputs/index";
  41250. export * from "babylonjs/Cameras/cameraInputsManager";
  41251. export * from "babylonjs/Cameras/camera";
  41252. export * from "babylonjs/Cameras/targetCamera";
  41253. export * from "babylonjs/Cameras/freeCamera";
  41254. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41255. export * from "babylonjs/Cameras/touchCamera";
  41256. export * from "babylonjs/Cameras/arcRotateCamera";
  41257. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41258. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41259. export * from "babylonjs/Cameras/flyCamera";
  41260. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41261. export * from "babylonjs/Cameras/followCamera";
  41262. export * from "babylonjs/Cameras/gamepadCamera";
  41263. export * from "babylonjs/Cameras/Stereoscopic/index";
  41264. export * from "babylonjs/Cameras/universalCamera";
  41265. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41266. export * from "babylonjs/Cameras/VR/index";
  41267. export * from "babylonjs/Cameras/XR/index";
  41268. export * from "babylonjs/Cameras/RigModes/index";
  41269. }
  41270. declare module "babylonjs/Collisions/index" {
  41271. export * from "babylonjs/Collisions/collider";
  41272. export * from "babylonjs/Collisions/collisionCoordinator";
  41273. export * from "babylonjs/Collisions/pickingInfo";
  41274. export * from "babylonjs/Collisions/intersectionInfo";
  41275. }
  41276. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41277. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41278. import { Vector3, Plane } from "babylonjs/Maths/math";
  41279. import { Ray } from "babylonjs/Culling/ray";
  41280. /**
  41281. * Contains an array of blocks representing the octree
  41282. */
  41283. export interface IOctreeContainer<T> {
  41284. /**
  41285. * Blocks within the octree
  41286. */
  41287. blocks: Array<OctreeBlock<T>>;
  41288. }
  41289. /**
  41290. * Class used to store a cell in an octree
  41291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41292. */
  41293. export class OctreeBlock<T> {
  41294. /**
  41295. * Gets the content of the current block
  41296. */
  41297. entries: T[];
  41298. /**
  41299. * Gets the list of block children
  41300. */
  41301. blocks: Array<OctreeBlock<T>>;
  41302. private _depth;
  41303. private _maxDepth;
  41304. private _capacity;
  41305. private _minPoint;
  41306. private _maxPoint;
  41307. private _boundingVectors;
  41308. private _creationFunc;
  41309. /**
  41310. * Creates a new block
  41311. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41312. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41313. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41314. * @param depth defines the current depth of this block in the octree
  41315. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41316. * @param creationFunc defines a callback to call when an element is added to the block
  41317. */
  41318. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41319. /**
  41320. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41321. */
  41322. readonly capacity: number;
  41323. /**
  41324. * Gets the minimum vector (in world space) of the block's bounding box
  41325. */
  41326. readonly minPoint: Vector3;
  41327. /**
  41328. * Gets the maximum vector (in world space) of the block's bounding box
  41329. */
  41330. readonly maxPoint: Vector3;
  41331. /**
  41332. * Add a new element to this block
  41333. * @param entry defines the element to add
  41334. */
  41335. addEntry(entry: T): void;
  41336. /**
  41337. * Remove an element from this block
  41338. * @param entry defines the element to remove
  41339. */
  41340. removeEntry(entry: T): void;
  41341. /**
  41342. * Add an array of elements to this block
  41343. * @param entries defines the array of elements to add
  41344. */
  41345. addEntries(entries: T[]): void;
  41346. /**
  41347. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41348. * @param frustumPlanes defines the frustum planes to test
  41349. * @param selection defines the array to store current content if selection is positive
  41350. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41351. */
  41352. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41353. /**
  41354. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41355. * @param sphereCenter defines the bounding sphere center
  41356. * @param sphereRadius defines the bounding sphere radius
  41357. * @param selection defines the array to store current content if selection is positive
  41358. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41359. */
  41360. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41361. /**
  41362. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41363. * @param ray defines the ray to test with
  41364. * @param selection defines the array to store current content if selection is positive
  41365. */
  41366. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41367. /**
  41368. * Subdivide the content into child blocks (this block will then be empty)
  41369. */
  41370. createInnerBlocks(): void;
  41371. /**
  41372. * @hidden
  41373. */
  41374. 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;
  41375. }
  41376. }
  41377. declare module "babylonjs/Culling/Octrees/octree" {
  41378. import { SmartArray } from "babylonjs/Misc/smartArray";
  41379. import { Vector3, Plane } from "babylonjs/Maths/math";
  41380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41382. import { Ray } from "babylonjs/Culling/ray";
  41383. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41384. /**
  41385. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41386. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41387. */
  41388. export class Octree<T> {
  41389. /** 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.) */
  41390. maxDepth: number;
  41391. /**
  41392. * Blocks within the octree containing objects
  41393. */
  41394. blocks: Array<OctreeBlock<T>>;
  41395. /**
  41396. * Content stored in the octree
  41397. */
  41398. dynamicContent: T[];
  41399. private _maxBlockCapacity;
  41400. private _selectionContent;
  41401. private _creationFunc;
  41402. /**
  41403. * Creates a octree
  41404. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41405. * @param creationFunc function to be used to instatiate the octree
  41406. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41407. * @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.)
  41408. */
  41409. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41410. /** 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.) */
  41411. maxDepth?: number);
  41412. /**
  41413. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41414. * @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);
  41415. * @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);
  41416. * @param entries meshes to be added to the octree blocks
  41417. */
  41418. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41419. /**
  41420. * Adds a mesh to the octree
  41421. * @param entry Mesh to add to the octree
  41422. */
  41423. addMesh(entry: T): void;
  41424. /**
  41425. * Remove an element from the octree
  41426. * @param entry defines the element to remove
  41427. */
  41428. removeMesh(entry: T): void;
  41429. /**
  41430. * Selects an array of meshes within the frustum
  41431. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41432. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41433. * @returns array of meshes within the frustum
  41434. */
  41435. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41436. /**
  41437. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41438. * @param sphereCenter defines the bounding sphere center
  41439. * @param sphereRadius defines the bounding sphere radius
  41440. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41441. * @returns an array of objects that intersect the sphere
  41442. */
  41443. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41444. /**
  41445. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41446. * @param ray defines the ray to test with
  41447. * @returns array of intersected objects
  41448. */
  41449. intersectsRay(ray: Ray): SmartArray<T>;
  41450. /**
  41451. * Adds a mesh into the octree block if it intersects the block
  41452. */
  41453. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41454. /**
  41455. * Adds a submesh into the octree block if it intersects the block
  41456. */
  41457. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41458. }
  41459. }
  41460. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41461. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41462. import { Scene } from "babylonjs/scene";
  41463. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41465. import { Ray } from "babylonjs/Culling/ray";
  41466. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41467. import { Collider } from "babylonjs/Collisions/collider";
  41468. module "babylonjs/scene" {
  41469. interface Scene {
  41470. /**
  41471. * @hidden
  41472. * Backing Filed
  41473. */
  41474. _selectionOctree: Octree<AbstractMesh>;
  41475. /**
  41476. * Gets the octree used to boost mesh selection (picking)
  41477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41478. */
  41479. selectionOctree: Octree<AbstractMesh>;
  41480. /**
  41481. * Creates or updates the octree used to boost selection (picking)
  41482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41483. * @param maxCapacity defines the maximum capacity per leaf
  41484. * @param maxDepth defines the maximum depth of the octree
  41485. * @returns an octree of AbstractMesh
  41486. */
  41487. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41488. }
  41489. }
  41490. module "babylonjs/Meshes/abstractMesh" {
  41491. interface AbstractMesh {
  41492. /**
  41493. * @hidden
  41494. * Backing Field
  41495. */
  41496. _submeshesOctree: Octree<SubMesh>;
  41497. /**
  41498. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41499. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41500. * @param maxCapacity defines the maximum size of each block (64 by default)
  41501. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41502. * @returns the new octree
  41503. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41504. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41505. */
  41506. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41507. }
  41508. }
  41509. /**
  41510. * Defines the octree scene component responsible to manage any octrees
  41511. * in a given scene.
  41512. */
  41513. export class OctreeSceneComponent {
  41514. /**
  41515. * The component name helpfull to identify the component in the list of scene components.
  41516. */
  41517. readonly name: string;
  41518. /**
  41519. * The scene the component belongs to.
  41520. */
  41521. scene: Scene;
  41522. /**
  41523. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41524. */
  41525. readonly checksIsEnabled: boolean;
  41526. /**
  41527. * Creates a new instance of the component for the given scene
  41528. * @param scene Defines the scene to register the component in
  41529. */
  41530. constructor(scene: Scene);
  41531. /**
  41532. * Registers the component in a given scene
  41533. */
  41534. register(): void;
  41535. /**
  41536. * Return the list of active meshes
  41537. * @returns the list of active meshes
  41538. */
  41539. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41540. /**
  41541. * Return the list of active sub meshes
  41542. * @param mesh The mesh to get the candidates sub meshes from
  41543. * @returns the list of active sub meshes
  41544. */
  41545. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41546. private _tempRay;
  41547. /**
  41548. * Return the list of sub meshes intersecting with a given local ray
  41549. * @param mesh defines the mesh to find the submesh for
  41550. * @param localRay defines the ray in local space
  41551. * @returns the list of intersecting sub meshes
  41552. */
  41553. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41554. /**
  41555. * Return the list of sub meshes colliding with a collider
  41556. * @param mesh defines the mesh to find the submesh for
  41557. * @param collider defines the collider to evaluate the collision against
  41558. * @returns the list of colliding sub meshes
  41559. */
  41560. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41561. /**
  41562. * Rebuilds the elements related to this component in case of
  41563. * context lost for instance.
  41564. */
  41565. rebuild(): void;
  41566. /**
  41567. * Disposes the component and the associated ressources.
  41568. */
  41569. dispose(): void;
  41570. }
  41571. }
  41572. declare module "babylonjs/Culling/Octrees/index" {
  41573. export * from "babylonjs/Culling/Octrees/octree";
  41574. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41575. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41576. }
  41577. declare module "babylonjs/Culling/index" {
  41578. export * from "babylonjs/Culling/boundingBox";
  41579. export * from "babylonjs/Culling/boundingInfo";
  41580. export * from "babylonjs/Culling/boundingSphere";
  41581. export * from "babylonjs/Culling/Octrees/index";
  41582. export * from "babylonjs/Culling/ray";
  41583. }
  41584. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41585. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41586. import { Nullable } from "babylonjs/types";
  41587. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41588. import { Scene } from "babylonjs/scene";
  41589. /**
  41590. * Class containing static functions to help procedurally build meshes
  41591. */
  41592. export class LinesBuilder {
  41593. /**
  41594. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41595. * * 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
  41596. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41597. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41598. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41599. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41600. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41601. * * 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
  41602. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41605. * @param name defines the name of the new line system
  41606. * @param options defines the options used to create the line system
  41607. * @param scene defines the hosting scene
  41608. * @returns a new line system mesh
  41609. */
  41610. static CreateLineSystem(name: string, options: {
  41611. lines: Vector3[][];
  41612. updatable?: boolean;
  41613. instance?: Nullable<LinesMesh>;
  41614. colors?: Nullable<Color4[][]>;
  41615. useVertexAlpha?: boolean;
  41616. }, scene: Nullable<Scene>): LinesMesh;
  41617. /**
  41618. * Creates a line mesh
  41619. * 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
  41620. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41621. * * The parameter `points` is an array successive Vector3
  41622. * * 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
  41623. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41624. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41625. * * When updating an instance, remember that only point positions can change, not the number of points
  41626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41627. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41628. * @param name defines the name of the new line system
  41629. * @param options defines the options used to create the line system
  41630. * @param scene defines the hosting scene
  41631. * @returns a new line mesh
  41632. */
  41633. static CreateLines(name: string, options: {
  41634. points: Vector3[];
  41635. updatable?: boolean;
  41636. instance?: Nullable<LinesMesh>;
  41637. colors?: Color4[];
  41638. useVertexAlpha?: boolean;
  41639. }, scene?: Nullable<Scene>): LinesMesh;
  41640. /**
  41641. * Creates a dashed line mesh
  41642. * * 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
  41643. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41644. * * The parameter `points` is an array successive Vector3
  41645. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41646. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41647. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41648. * * 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
  41649. * * When updating an instance, remember that only point positions can change, not the number of points
  41650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41651. * @param name defines the name of the mesh
  41652. * @param options defines the options used to create the mesh
  41653. * @param scene defines the hosting scene
  41654. * @returns the dashed line mesh
  41655. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41656. */
  41657. static CreateDashedLines(name: string, options: {
  41658. points: Vector3[];
  41659. dashSize?: number;
  41660. gapSize?: number;
  41661. dashNb?: number;
  41662. updatable?: boolean;
  41663. instance?: LinesMesh;
  41664. }, scene?: Nullable<Scene>): LinesMesh;
  41665. }
  41666. }
  41667. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41668. import { IDisposable, Scene } from "babylonjs/scene";
  41669. import { Nullable } from "babylonjs/types";
  41670. import { Observable } from "babylonjs/Misc/observable";
  41671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41672. /**
  41673. * Renders a layer on top of an existing scene
  41674. */
  41675. export class UtilityLayerRenderer implements IDisposable {
  41676. /** the original scene that will be rendered on top of */
  41677. originalScene: Scene;
  41678. private _pointerCaptures;
  41679. private _lastPointerEvents;
  41680. private static _DefaultUtilityLayer;
  41681. private static _DefaultKeepDepthUtilityLayer;
  41682. /**
  41683. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41684. */
  41685. pickUtilitySceneFirst: boolean;
  41686. /**
  41687. * 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)
  41688. */
  41689. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41690. /**
  41691. * 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)
  41692. */
  41693. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41694. /**
  41695. * The scene that is rendered on top of the original scene
  41696. */
  41697. utilityLayerScene: Scene;
  41698. /**
  41699. * If the utility layer should automatically be rendered on top of existing scene
  41700. */
  41701. shouldRender: boolean;
  41702. /**
  41703. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41704. */
  41705. onlyCheckPointerDownEvents: boolean;
  41706. /**
  41707. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41708. */
  41709. processAllEvents: boolean;
  41710. /**
  41711. * Observable raised when the pointer move from the utility layer scene to the main scene
  41712. */
  41713. onPointerOutObservable: Observable<number>;
  41714. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41715. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41716. private _afterRenderObserver;
  41717. private _sceneDisposeObserver;
  41718. private _originalPointerObserver;
  41719. /**
  41720. * Instantiates a UtilityLayerRenderer
  41721. * @param originalScene the original scene that will be rendered on top of
  41722. * @param handleEvents boolean indicating if the utility layer should handle events
  41723. */
  41724. constructor(
  41725. /** the original scene that will be rendered on top of */
  41726. originalScene: Scene, handleEvents?: boolean);
  41727. private _notifyObservers;
  41728. /**
  41729. * Renders the utility layers scene on top of the original scene
  41730. */
  41731. render(): void;
  41732. /**
  41733. * Disposes of the renderer
  41734. */
  41735. dispose(): void;
  41736. private _updateCamera;
  41737. }
  41738. }
  41739. declare module "babylonjs/Gizmos/gizmo" {
  41740. import { Nullable } from "babylonjs/types";
  41741. import { IDisposable } from "babylonjs/scene";
  41742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41743. import { Mesh } from "babylonjs/Meshes/mesh";
  41744. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41745. /**
  41746. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41747. */
  41748. export class Gizmo implements IDisposable {
  41749. /** The utility layer the gizmo will be added to */
  41750. gizmoLayer: UtilityLayerRenderer;
  41751. /**
  41752. * The root mesh of the gizmo
  41753. */
  41754. _rootMesh: Mesh;
  41755. private _attachedMesh;
  41756. /**
  41757. * Ratio for the scale of the gizmo (Default: 1)
  41758. */
  41759. scaleRatio: number;
  41760. private _tmpMatrix;
  41761. /**
  41762. * If a custom mesh has been set (Default: false)
  41763. */
  41764. protected _customMeshSet: boolean;
  41765. /**
  41766. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41767. * * When set, interactions will be enabled
  41768. */
  41769. attachedMesh: Nullable<AbstractMesh>;
  41770. /**
  41771. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41772. * @param mesh The mesh to replace the default mesh of the gizmo
  41773. */
  41774. setCustomMesh(mesh: Mesh): void;
  41775. /**
  41776. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41777. */
  41778. updateGizmoRotationToMatchAttachedMesh: boolean;
  41779. /**
  41780. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41781. */
  41782. updateGizmoPositionToMatchAttachedMesh: boolean;
  41783. /**
  41784. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41785. */
  41786. protected _updateScale: boolean;
  41787. protected _interactionsEnabled: boolean;
  41788. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41789. private _beforeRenderObserver;
  41790. /**
  41791. * Creates a gizmo
  41792. * @param gizmoLayer The utility layer the gizmo will be added to
  41793. */
  41794. constructor(
  41795. /** The utility layer the gizmo will be added to */
  41796. gizmoLayer?: UtilityLayerRenderer);
  41797. private _tempVector;
  41798. /**
  41799. * @hidden
  41800. * Updates the gizmo to match the attached mesh's position/rotation
  41801. */
  41802. protected _update(): void;
  41803. /**
  41804. * Disposes of the gizmo
  41805. */
  41806. dispose(): void;
  41807. }
  41808. }
  41809. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41810. import { Observable } from "babylonjs/Misc/observable";
  41811. import { Nullable } from "babylonjs/types";
  41812. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41813. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41815. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41816. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41817. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41818. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41819. import { Scene } from "babylonjs/scene";
  41820. /**
  41821. * Single axis drag gizmo
  41822. */
  41823. export class AxisDragGizmo extends Gizmo {
  41824. /**
  41825. * Drag behavior responsible for the gizmos dragging interactions
  41826. */
  41827. dragBehavior: PointerDragBehavior;
  41828. private _pointerObserver;
  41829. /**
  41830. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41831. */
  41832. snapDistance: number;
  41833. /**
  41834. * Event that fires each time the gizmo snaps to a new location.
  41835. * * snapDistance is the the change in distance
  41836. */
  41837. onSnapObservable: Observable<{
  41838. snapDistance: number;
  41839. }>;
  41840. /** @hidden */
  41841. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41842. /** @hidden */
  41843. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41844. /**
  41845. * Creates an AxisDragGizmo
  41846. * @param gizmoLayer The utility layer the gizmo will be added to
  41847. * @param dragAxis The axis which the gizmo will be able to drag on
  41848. * @param color The color of the gizmo
  41849. */
  41850. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41851. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41852. /**
  41853. * Disposes of the gizmo
  41854. */
  41855. dispose(): void;
  41856. }
  41857. }
  41858. declare module "babylonjs/Debug/axesViewer" {
  41859. import { Vector3 } from "babylonjs/Maths/math";
  41860. import { Nullable } from "babylonjs/types";
  41861. import { Scene } from "babylonjs/scene";
  41862. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41863. /**
  41864. * The Axes viewer will show 3 axes in a specific point in space
  41865. */
  41866. export class AxesViewer {
  41867. private _xAxis;
  41868. private _yAxis;
  41869. private _zAxis;
  41870. private _scaleLinesFactor;
  41871. private _instanced;
  41872. /**
  41873. * Gets the hosting scene
  41874. */
  41875. scene: Scene;
  41876. /**
  41877. * Gets or sets a number used to scale line length
  41878. */
  41879. scaleLines: number;
  41880. /** Gets the node hierarchy used to render x-axis */
  41881. readonly xAxis: TransformNode;
  41882. /** Gets the node hierarchy used to render y-axis */
  41883. readonly yAxis: TransformNode;
  41884. /** Gets the node hierarchy used to render z-axis */
  41885. readonly zAxis: TransformNode;
  41886. /**
  41887. * Creates a new AxesViewer
  41888. * @param scene defines the hosting scene
  41889. * @param scaleLines defines a number used to scale line length (1 by default)
  41890. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41891. * @param xAxis defines the node hierarchy used to render the x-axis
  41892. * @param yAxis defines the node hierarchy used to render the y-axis
  41893. * @param zAxis defines the node hierarchy used to render the z-axis
  41894. */
  41895. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41896. /**
  41897. * Force the viewer to update
  41898. * @param position defines the position of the viewer
  41899. * @param xaxis defines the x axis of the viewer
  41900. * @param yaxis defines the y axis of the viewer
  41901. * @param zaxis defines the z axis of the viewer
  41902. */
  41903. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41904. /**
  41905. * Creates an instance of this axes viewer.
  41906. * @returns a new axes viewer with instanced meshes
  41907. */
  41908. createInstance(): AxesViewer;
  41909. /** Releases resources */
  41910. dispose(): void;
  41911. private static _SetRenderingGroupId;
  41912. }
  41913. }
  41914. declare module "babylonjs/Debug/boneAxesViewer" {
  41915. import { Nullable } from "babylonjs/types";
  41916. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41917. import { Vector3 } from "babylonjs/Maths/math";
  41918. import { Mesh } from "babylonjs/Meshes/mesh";
  41919. import { Bone } from "babylonjs/Bones/bone";
  41920. import { Scene } from "babylonjs/scene";
  41921. /**
  41922. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41923. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41924. */
  41925. export class BoneAxesViewer extends AxesViewer {
  41926. /**
  41927. * Gets or sets the target mesh where to display the axes viewer
  41928. */
  41929. mesh: Nullable<Mesh>;
  41930. /**
  41931. * Gets or sets the target bone where to display the axes viewer
  41932. */
  41933. bone: Nullable<Bone>;
  41934. /** Gets current position */
  41935. pos: Vector3;
  41936. /** Gets direction of X axis */
  41937. xaxis: Vector3;
  41938. /** Gets direction of Y axis */
  41939. yaxis: Vector3;
  41940. /** Gets direction of Z axis */
  41941. zaxis: Vector3;
  41942. /**
  41943. * Creates a new BoneAxesViewer
  41944. * @param scene defines the hosting scene
  41945. * @param bone defines the target bone
  41946. * @param mesh defines the target mesh
  41947. * @param scaleLines defines a scaling factor for line length (1 by default)
  41948. */
  41949. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41950. /**
  41951. * Force the viewer to update
  41952. */
  41953. update(): void;
  41954. /** Releases resources */
  41955. dispose(): void;
  41956. }
  41957. }
  41958. declare module "babylonjs/Debug/debugLayer" {
  41959. import { Observable } from "babylonjs/Misc/observable";
  41960. import { Scene } from "babylonjs/scene";
  41961. /**
  41962. * Interface used to define scene explorer extensibility option
  41963. */
  41964. export interface IExplorerExtensibilityOption {
  41965. /**
  41966. * Define the option label
  41967. */
  41968. label: string;
  41969. /**
  41970. * Defines the action to execute on click
  41971. */
  41972. action: (entity: any) => void;
  41973. }
  41974. /**
  41975. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41976. */
  41977. export interface IExplorerExtensibilityGroup {
  41978. /**
  41979. * Defines a predicate to test if a given type mut be extended
  41980. */
  41981. predicate: (entity: any) => boolean;
  41982. /**
  41983. * Gets the list of options added to a type
  41984. */
  41985. entries: IExplorerExtensibilityOption[];
  41986. }
  41987. /**
  41988. * Interface used to define the options to use to create the Inspector
  41989. */
  41990. export interface IInspectorOptions {
  41991. /**
  41992. * Display in overlay mode (default: false)
  41993. */
  41994. overlay?: boolean;
  41995. /**
  41996. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41997. */
  41998. globalRoot?: HTMLElement;
  41999. /**
  42000. * Display the Scene explorer
  42001. */
  42002. showExplorer?: boolean;
  42003. /**
  42004. * Display the property inspector
  42005. */
  42006. showInspector?: boolean;
  42007. /**
  42008. * Display in embed mode (both panes on the right)
  42009. */
  42010. embedMode?: boolean;
  42011. /**
  42012. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42013. */
  42014. handleResize?: boolean;
  42015. /**
  42016. * Allow the panes to popup (default: true)
  42017. */
  42018. enablePopup?: boolean;
  42019. /**
  42020. * Allow the panes to be closed by users (default: true)
  42021. */
  42022. enableClose?: boolean;
  42023. /**
  42024. * Optional list of extensibility entries
  42025. */
  42026. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42027. /**
  42028. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42029. */
  42030. inspectorURL?: string;
  42031. }
  42032. module "babylonjs/scene" {
  42033. interface Scene {
  42034. /**
  42035. * @hidden
  42036. * Backing field
  42037. */
  42038. _debugLayer: DebugLayer;
  42039. /**
  42040. * Gets the debug layer (aka Inspector) associated with the scene
  42041. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42042. */
  42043. debugLayer: DebugLayer;
  42044. }
  42045. }
  42046. /**
  42047. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42048. * what is happening in your scene
  42049. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42050. */
  42051. export class DebugLayer {
  42052. /**
  42053. * Define the url to get the inspector script from.
  42054. * By default it uses the babylonjs CDN.
  42055. * @ignoreNaming
  42056. */
  42057. static InspectorURL: string;
  42058. private _scene;
  42059. private BJSINSPECTOR;
  42060. /**
  42061. * Observable triggered when a property is changed through the inspector.
  42062. */
  42063. onPropertyChangedObservable: Observable<{
  42064. object: any;
  42065. property: string;
  42066. value: any;
  42067. initialValue: any;
  42068. }>;
  42069. /**
  42070. * Instantiates a new debug layer.
  42071. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42072. * what is happening in your scene
  42073. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42074. * @param scene Defines the scene to inspect
  42075. */
  42076. constructor(scene: Scene);
  42077. /** Creates the inspector window. */
  42078. private _createInspector;
  42079. /**
  42080. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42081. * @param entity defines the entity to select
  42082. * @param lineContainerTitle defines the specific block to highlight
  42083. */
  42084. select(entity: any, lineContainerTitle?: string): void;
  42085. /** Get the inspector from bundle or global */
  42086. private _getGlobalInspector;
  42087. /**
  42088. * Get if the inspector is visible or not.
  42089. * @returns true if visible otherwise, false
  42090. */
  42091. isVisible(): boolean;
  42092. /**
  42093. * Hide the inspector and close its window.
  42094. */
  42095. hide(): void;
  42096. /**
  42097. * Launch the debugLayer.
  42098. * @param config Define the configuration of the inspector
  42099. * @return a promise fulfilled when the debug layer is visible
  42100. */
  42101. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42102. }
  42103. }
  42104. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42105. import { Nullable } from "babylonjs/types";
  42106. import { Scene } from "babylonjs/scene";
  42107. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42108. import { Mesh } from "babylonjs/Meshes/mesh";
  42109. /**
  42110. * Class containing static functions to help procedurally build meshes
  42111. */
  42112. export class BoxBuilder {
  42113. /**
  42114. * Creates a box mesh
  42115. * * The parameter `size` sets the size (float) of each box side (default 1)
  42116. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42117. * * 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)
  42118. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42122. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42123. * @param name defines the name of the mesh
  42124. * @param options defines the options used to create the mesh
  42125. * @param scene defines the hosting scene
  42126. * @returns the box mesh
  42127. */
  42128. static CreateBox(name: string, options: {
  42129. size?: number;
  42130. width?: number;
  42131. height?: number;
  42132. depth?: number;
  42133. faceUV?: Vector4[];
  42134. faceColors?: Color4[];
  42135. sideOrientation?: number;
  42136. frontUVs?: Vector4;
  42137. backUVs?: Vector4;
  42138. updatable?: boolean;
  42139. }, scene?: Nullable<Scene>): Mesh;
  42140. }
  42141. }
  42142. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42143. import { Vector4 } from "babylonjs/Maths/math";
  42144. import { Mesh } from "babylonjs/Meshes/mesh";
  42145. /**
  42146. * Class containing static functions to help procedurally build meshes
  42147. */
  42148. export class SphereBuilder {
  42149. /**
  42150. * Creates a sphere mesh
  42151. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42152. * * 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`)
  42153. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42154. * * 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
  42155. * * 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)
  42156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42159. * @param name defines the name of the mesh
  42160. * @param options defines the options used to create the mesh
  42161. * @param scene defines the hosting scene
  42162. * @returns the sphere mesh
  42163. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42164. */
  42165. static CreateSphere(name: string, options: {
  42166. segments?: number;
  42167. diameter?: number;
  42168. diameterX?: number;
  42169. diameterY?: number;
  42170. diameterZ?: number;
  42171. arc?: number;
  42172. slice?: number;
  42173. sideOrientation?: number;
  42174. frontUVs?: Vector4;
  42175. backUVs?: Vector4;
  42176. updatable?: boolean;
  42177. }, scene: any): Mesh;
  42178. }
  42179. }
  42180. declare module "babylonjs/Debug/physicsViewer" {
  42181. import { Nullable } from "babylonjs/types";
  42182. import { Scene } from "babylonjs/scene";
  42183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42184. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42185. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42186. /**
  42187. * Used to show the physics impostor around the specific mesh
  42188. */
  42189. export class PhysicsViewer {
  42190. /** @hidden */
  42191. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42192. /** @hidden */
  42193. protected _meshes: Array<Nullable<AbstractMesh>>;
  42194. /** @hidden */
  42195. protected _scene: Nullable<Scene>;
  42196. /** @hidden */
  42197. protected _numMeshes: number;
  42198. /** @hidden */
  42199. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42200. private _renderFunction;
  42201. private _utilityLayer;
  42202. private _debugBoxMesh;
  42203. private _debugSphereMesh;
  42204. private _debugMaterial;
  42205. /**
  42206. * Creates a new PhysicsViewer
  42207. * @param scene defines the hosting scene
  42208. */
  42209. constructor(scene: Scene);
  42210. /** @hidden */
  42211. protected _updateDebugMeshes(): void;
  42212. /**
  42213. * Renders a specified physic impostor
  42214. * @param impostor defines the impostor to render
  42215. * @returns the new debug mesh used to render the impostor
  42216. */
  42217. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  42218. /**
  42219. * Hides a specified physic impostor
  42220. * @param impostor defines the impostor to hide
  42221. */
  42222. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42223. private _getDebugMaterial;
  42224. private _getDebugBoxMesh;
  42225. private _getDebugSphereMesh;
  42226. private _getDebugMesh;
  42227. /** Releases all resources */
  42228. dispose(): void;
  42229. }
  42230. }
  42231. declare module "babylonjs/Debug/rayHelper" {
  42232. import { Nullable } from "babylonjs/types";
  42233. import { Ray } from "babylonjs/Culling/ray";
  42234. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42235. import { Scene } from "babylonjs/scene";
  42236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42237. import "babylonjs/Meshes/Builders/linesBuilder";
  42238. /**
  42239. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42240. * in order to better appreciate the issue one might have.
  42241. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42242. */
  42243. export class RayHelper {
  42244. /**
  42245. * Defines the ray we are currently tryin to visualize.
  42246. */
  42247. ray: Nullable<Ray>;
  42248. private _renderPoints;
  42249. private _renderLine;
  42250. private _renderFunction;
  42251. private _scene;
  42252. private _updateToMeshFunction;
  42253. private _attachedToMesh;
  42254. private _meshSpaceDirection;
  42255. private _meshSpaceOrigin;
  42256. /**
  42257. * Helper function to create a colored helper in a scene in one line.
  42258. * @param ray Defines the ray we are currently tryin to visualize
  42259. * @param scene Defines the scene the ray is used in
  42260. * @param color Defines the color we want to see the ray in
  42261. * @returns The newly created ray helper.
  42262. */
  42263. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42264. /**
  42265. * Instantiate a new ray helper.
  42266. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42267. * in order to better appreciate the issue one might have.
  42268. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42269. * @param ray Defines the ray we are currently tryin to visualize
  42270. */
  42271. constructor(ray: Ray);
  42272. /**
  42273. * Shows the ray we are willing to debug.
  42274. * @param scene Defines the scene the ray needs to be rendered in
  42275. * @param color Defines the color the ray needs to be rendered in
  42276. */
  42277. show(scene: Scene, color?: Color3): void;
  42278. /**
  42279. * Hides the ray we are debugging.
  42280. */
  42281. hide(): void;
  42282. private _render;
  42283. /**
  42284. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42285. * @param mesh Defines the mesh we want the helper attached to
  42286. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42287. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42288. * @param length Defines the length of the ray
  42289. */
  42290. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42291. /**
  42292. * Detach the ray helper from the mesh it has previously been attached to.
  42293. */
  42294. detachFromMesh(): void;
  42295. private _updateToMesh;
  42296. /**
  42297. * Dispose the helper and release its associated resources.
  42298. */
  42299. dispose(): void;
  42300. }
  42301. }
  42302. declare module "babylonjs/Debug/skeletonViewer" {
  42303. import { Color3 } from "babylonjs/Maths/math";
  42304. import { Scene } from "babylonjs/scene";
  42305. import { Nullable } from "babylonjs/types";
  42306. import { Skeleton } from "babylonjs/Bones/skeleton";
  42307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42308. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42309. /**
  42310. * Class used to render a debug view of a given skeleton
  42311. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42312. */
  42313. export class SkeletonViewer {
  42314. /** defines the skeleton to render */
  42315. skeleton: Skeleton;
  42316. /** defines the mesh attached to the skeleton */
  42317. mesh: AbstractMesh;
  42318. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42319. autoUpdateBonesMatrices: boolean;
  42320. /** defines the rendering group id to use with the viewer */
  42321. renderingGroupId: number;
  42322. /** Gets or sets the color used to render the skeleton */
  42323. color: Color3;
  42324. private _scene;
  42325. private _debugLines;
  42326. private _debugMesh;
  42327. private _isEnabled;
  42328. private _renderFunction;
  42329. private _utilityLayer;
  42330. /**
  42331. * Returns the mesh used to render the bones
  42332. */
  42333. readonly debugMesh: Nullable<LinesMesh>;
  42334. /**
  42335. * Creates a new SkeletonViewer
  42336. * @param skeleton defines the skeleton to render
  42337. * @param mesh defines the mesh attached to the skeleton
  42338. * @param scene defines the hosting scene
  42339. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42340. * @param renderingGroupId defines the rendering group id to use with the viewer
  42341. */
  42342. constructor(
  42343. /** defines the skeleton to render */
  42344. skeleton: Skeleton,
  42345. /** defines the mesh attached to the skeleton */
  42346. mesh: AbstractMesh, scene: Scene,
  42347. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42348. autoUpdateBonesMatrices?: boolean,
  42349. /** defines the rendering group id to use with the viewer */
  42350. renderingGroupId?: number);
  42351. /** Gets or sets a boolean indicating if the viewer is enabled */
  42352. isEnabled: boolean;
  42353. private _getBonePosition;
  42354. private _getLinesForBonesWithLength;
  42355. private _getLinesForBonesNoLength;
  42356. /** Update the viewer to sync with current skeleton state */
  42357. update(): void;
  42358. /** Release associated resources */
  42359. dispose(): void;
  42360. }
  42361. }
  42362. declare module "babylonjs/Debug/index" {
  42363. export * from "babylonjs/Debug/axesViewer";
  42364. export * from "babylonjs/Debug/boneAxesViewer";
  42365. export * from "babylonjs/Debug/debugLayer";
  42366. export * from "babylonjs/Debug/physicsViewer";
  42367. export * from "babylonjs/Debug/rayHelper";
  42368. export * from "babylonjs/Debug/skeletonViewer";
  42369. }
  42370. declare module "babylonjs/Engines/nullEngine" {
  42371. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42372. import { Scene } from "babylonjs/scene";
  42373. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42374. import { Engine } from "babylonjs/Engines/engine";
  42375. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42376. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42377. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42378. import { Effect } from "babylonjs/Materials/effect";
  42379. /**
  42380. * Options to create the null engine
  42381. */
  42382. export class NullEngineOptions {
  42383. /**
  42384. * Render width (Default: 512)
  42385. */
  42386. renderWidth: number;
  42387. /**
  42388. * Render height (Default: 256)
  42389. */
  42390. renderHeight: number;
  42391. /**
  42392. * Texture size (Default: 512)
  42393. */
  42394. textureSize: number;
  42395. /**
  42396. * If delta time between frames should be constant
  42397. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42398. */
  42399. deterministicLockstep: boolean;
  42400. /**
  42401. * Maximum about of steps between frames (Default: 4)
  42402. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42403. */
  42404. lockstepMaxSteps: number;
  42405. }
  42406. /**
  42407. * The null engine class provides support for headless version of babylon.js.
  42408. * This can be used in server side scenario or for testing purposes
  42409. */
  42410. export class NullEngine extends Engine {
  42411. private _options;
  42412. /**
  42413. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42414. */
  42415. isDeterministicLockStep(): boolean;
  42416. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42417. getLockstepMaxSteps(): number;
  42418. /**
  42419. * Sets hardware scaling, used to save performance if needed
  42420. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42421. */
  42422. getHardwareScalingLevel(): number;
  42423. constructor(options?: NullEngineOptions);
  42424. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42425. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42426. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42427. getRenderWidth(useScreen?: boolean): number;
  42428. getRenderHeight(useScreen?: boolean): number;
  42429. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42430. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42431. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42432. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42433. bindSamplers(effect: Effect): void;
  42434. enableEffect(effect: Effect): void;
  42435. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42436. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42437. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42438. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42439. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42440. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42441. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42442. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42443. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42444. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42445. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42446. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42447. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42448. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42449. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42450. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42451. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42452. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42453. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42454. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42455. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42456. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42457. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42458. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42459. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42460. bindBuffers(vertexBuffers: {
  42461. [key: string]: VertexBuffer;
  42462. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42463. wipeCaches(bruteForce?: boolean): void;
  42464. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42465. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42466. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42467. /** @hidden */
  42468. _createTexture(): WebGLTexture;
  42469. /** @hidden */
  42470. _releaseTexture(texture: InternalTexture): void;
  42471. 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;
  42472. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42473. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42474. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42475. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42476. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42477. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42478. areAllEffectsReady(): boolean;
  42479. /**
  42480. * @hidden
  42481. * Get the current error code of the webGL context
  42482. * @returns the error code
  42483. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42484. */
  42485. getError(): number;
  42486. /** @hidden */
  42487. _getUnpackAlignement(): number;
  42488. /** @hidden */
  42489. _unpackFlipY(value: boolean): void;
  42490. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42491. /**
  42492. * Updates a dynamic vertex buffer.
  42493. * @param vertexBuffer the vertex buffer to update
  42494. * @param data the data used to update the vertex buffer
  42495. * @param byteOffset the byte offset of the data (optional)
  42496. * @param byteLength the byte length of the data (optional)
  42497. */
  42498. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42499. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42500. /** @hidden */
  42501. _bindTexture(channel: number, texture: InternalTexture): void;
  42502. /** @hidden */
  42503. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42504. releaseEffects(): void;
  42505. displayLoadingUI(): void;
  42506. hideLoadingUI(): void;
  42507. /** @hidden */
  42508. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42509. /** @hidden */
  42510. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42511. /** @hidden */
  42512. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42513. /** @hidden */
  42514. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42515. }
  42516. }
  42517. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42518. import { Nullable, int } from "babylonjs/types";
  42519. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42520. /** @hidden */
  42521. export class _OcclusionDataStorage {
  42522. /** @hidden */
  42523. occlusionInternalRetryCounter: number;
  42524. /** @hidden */
  42525. isOcclusionQueryInProgress: boolean;
  42526. /** @hidden */
  42527. isOccluded: boolean;
  42528. /** @hidden */
  42529. occlusionRetryCount: number;
  42530. /** @hidden */
  42531. occlusionType: number;
  42532. /** @hidden */
  42533. occlusionQueryAlgorithmType: number;
  42534. }
  42535. module "babylonjs/Engines/engine" {
  42536. interface Engine {
  42537. /**
  42538. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42539. * @return the new query
  42540. */
  42541. createQuery(): WebGLQuery;
  42542. /**
  42543. * Delete and release a webGL query
  42544. * @param query defines the query to delete
  42545. * @return the current engine
  42546. */
  42547. deleteQuery(query: WebGLQuery): Engine;
  42548. /**
  42549. * Check if a given query has resolved and got its value
  42550. * @param query defines the query to check
  42551. * @returns true if the query got its value
  42552. */
  42553. isQueryResultAvailable(query: WebGLQuery): boolean;
  42554. /**
  42555. * Gets the value of a given query
  42556. * @param query defines the query to check
  42557. * @returns the value of the query
  42558. */
  42559. getQueryResult(query: WebGLQuery): number;
  42560. /**
  42561. * Initiates an occlusion query
  42562. * @param algorithmType defines the algorithm to use
  42563. * @param query defines the query to use
  42564. * @returns the current engine
  42565. * @see http://doc.babylonjs.com/features/occlusionquery
  42566. */
  42567. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42568. /**
  42569. * Ends an occlusion query
  42570. * @see http://doc.babylonjs.com/features/occlusionquery
  42571. * @param algorithmType defines the algorithm to use
  42572. * @returns the current engine
  42573. */
  42574. endOcclusionQuery(algorithmType: number): Engine;
  42575. /**
  42576. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42577. * Please note that only one query can be issued at a time
  42578. * @returns a time token used to track the time span
  42579. */
  42580. startTimeQuery(): Nullable<_TimeToken>;
  42581. /**
  42582. * Ends a time query
  42583. * @param token defines the token used to measure the time span
  42584. * @returns the time spent (in ns)
  42585. */
  42586. endTimeQuery(token: _TimeToken): int;
  42587. /** @hidden */
  42588. _currentNonTimestampToken: Nullable<_TimeToken>;
  42589. /** @hidden */
  42590. _createTimeQuery(): WebGLQuery;
  42591. /** @hidden */
  42592. _deleteTimeQuery(query: WebGLQuery): void;
  42593. /** @hidden */
  42594. _getGlAlgorithmType(algorithmType: number): number;
  42595. /** @hidden */
  42596. _getTimeQueryResult(query: WebGLQuery): any;
  42597. /** @hidden */
  42598. _getTimeQueryAvailability(query: WebGLQuery): any;
  42599. }
  42600. }
  42601. module "babylonjs/Meshes/abstractMesh" {
  42602. interface AbstractMesh {
  42603. /**
  42604. * Backing filed
  42605. * @hidden
  42606. */
  42607. __occlusionDataStorage: _OcclusionDataStorage;
  42608. /**
  42609. * Access property
  42610. * @hidden
  42611. */
  42612. _occlusionDataStorage: _OcclusionDataStorage;
  42613. /**
  42614. * 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.
  42615. * The default value is -1 which means don't break the query and wait till the result
  42616. * @see http://doc.babylonjs.com/features/occlusionquery
  42617. */
  42618. occlusionRetryCount: number;
  42619. /**
  42620. * 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:
  42621. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42622. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42623. * * 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.
  42624. * @see http://doc.babylonjs.com/features/occlusionquery
  42625. */
  42626. occlusionType: number;
  42627. /**
  42628. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42629. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42630. * * 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.
  42631. * @see http://doc.babylonjs.com/features/occlusionquery
  42632. */
  42633. occlusionQueryAlgorithmType: number;
  42634. /**
  42635. * 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
  42636. * @see http://doc.babylonjs.com/features/occlusionquery
  42637. */
  42638. isOccluded: boolean;
  42639. /**
  42640. * Flag to check the progress status of the query
  42641. * @see http://doc.babylonjs.com/features/occlusionquery
  42642. */
  42643. isOcclusionQueryInProgress: boolean;
  42644. }
  42645. }
  42646. }
  42647. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42648. import { Nullable } from "babylonjs/types";
  42649. /** @hidden */
  42650. export var _forceTransformFeedbackToBundle: boolean;
  42651. module "babylonjs/Engines/engine" {
  42652. interface Engine {
  42653. /**
  42654. * Creates a webGL transform feedback object
  42655. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42656. * @returns the webGL transform feedback object
  42657. */
  42658. createTransformFeedback(): WebGLTransformFeedback;
  42659. /**
  42660. * Delete a webGL transform feedback object
  42661. * @param value defines the webGL transform feedback object to delete
  42662. */
  42663. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42664. /**
  42665. * Bind a webGL transform feedback object to the webgl context
  42666. * @param value defines the webGL transform feedback object to bind
  42667. */
  42668. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42669. /**
  42670. * Begins a transform feedback operation
  42671. * @param usePoints defines if points or triangles must be used
  42672. */
  42673. beginTransformFeedback(usePoints: boolean): void;
  42674. /**
  42675. * Ends a transform feedback operation
  42676. */
  42677. endTransformFeedback(): void;
  42678. /**
  42679. * Specify the varyings to use with transform feedback
  42680. * @param program defines the associated webGL program
  42681. * @param value defines the list of strings representing the varying names
  42682. */
  42683. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42684. /**
  42685. * Bind a webGL buffer for a transform feedback operation
  42686. * @param value defines the webGL buffer to bind
  42687. */
  42688. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42689. }
  42690. }
  42691. }
  42692. declare module "babylonjs/Engines/Extensions/index" {
  42693. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42694. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42695. }
  42696. declare module "babylonjs/Engines/index" {
  42697. export * from "babylonjs/Engines/constants";
  42698. export * from "babylonjs/Engines/engine";
  42699. export * from "babylonjs/Engines/engineStore";
  42700. export * from "babylonjs/Engines/nullEngine";
  42701. export * from "babylonjs/Engines/Extensions/index";
  42702. }
  42703. declare module "babylonjs/Events/clipboardEvents" {
  42704. /**
  42705. * Gather the list of clipboard event types as constants.
  42706. */
  42707. export class ClipboardEventTypes {
  42708. /**
  42709. * The clipboard event is fired when a copy command is active (pressed).
  42710. */
  42711. static readonly COPY: number;
  42712. /**
  42713. * The clipboard event is fired when a cut command is active (pressed).
  42714. */
  42715. static readonly CUT: number;
  42716. /**
  42717. * The clipboard event is fired when a paste command is active (pressed).
  42718. */
  42719. static readonly PASTE: number;
  42720. }
  42721. /**
  42722. * This class is used to store clipboard related info for the onClipboardObservable event.
  42723. */
  42724. export class ClipboardInfo {
  42725. /**
  42726. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42727. */
  42728. type: number;
  42729. /**
  42730. * Defines the related dom event
  42731. */
  42732. event: ClipboardEvent;
  42733. /**
  42734. *Creates an instance of ClipboardInfo.
  42735. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42736. * @param event Defines the related dom event
  42737. */
  42738. constructor(
  42739. /**
  42740. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42741. */
  42742. type: number,
  42743. /**
  42744. * Defines the related dom event
  42745. */
  42746. event: ClipboardEvent);
  42747. /**
  42748. * Get the clipboard event's type from the keycode.
  42749. * @param keyCode Defines the keyCode for the current keyboard event.
  42750. * @return {number}
  42751. */
  42752. static GetTypeFromCharacter(keyCode: number): number;
  42753. }
  42754. }
  42755. declare module "babylonjs/Events/index" {
  42756. export * from "babylonjs/Events/keyboardEvents";
  42757. export * from "babylonjs/Events/pointerEvents";
  42758. export * from "babylonjs/Events/clipboardEvents";
  42759. }
  42760. declare module "babylonjs/Loading/sceneLoader" {
  42761. import { Observable } from "babylonjs/Misc/observable";
  42762. import { Nullable } from "babylonjs/types";
  42763. import { Scene } from "babylonjs/scene";
  42764. import { Engine } from "babylonjs/Engines/engine";
  42765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42766. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42767. import { AssetContainer } from "babylonjs/assetContainer";
  42768. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42769. import { Skeleton } from "babylonjs/Bones/skeleton";
  42770. /**
  42771. * Class used to represent data loading progression
  42772. */
  42773. export class SceneLoaderProgressEvent {
  42774. /** defines if data length to load can be evaluated */
  42775. readonly lengthComputable: boolean;
  42776. /** defines the loaded data length */
  42777. readonly loaded: number;
  42778. /** defines the data length to load */
  42779. readonly total: number;
  42780. /**
  42781. * Create a new progress event
  42782. * @param lengthComputable defines if data length to load can be evaluated
  42783. * @param loaded defines the loaded data length
  42784. * @param total defines the data length to load
  42785. */
  42786. constructor(
  42787. /** defines if data length to load can be evaluated */
  42788. lengthComputable: boolean,
  42789. /** defines the loaded data length */
  42790. loaded: number,
  42791. /** defines the data length to load */
  42792. total: number);
  42793. /**
  42794. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42795. * @param event defines the source event
  42796. * @returns a new SceneLoaderProgressEvent
  42797. */
  42798. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42799. }
  42800. /**
  42801. * Interface used by SceneLoader plugins to define supported file extensions
  42802. */
  42803. export interface ISceneLoaderPluginExtensions {
  42804. /**
  42805. * Defines the list of supported extensions
  42806. */
  42807. [extension: string]: {
  42808. isBinary: boolean;
  42809. };
  42810. }
  42811. /**
  42812. * Interface used by SceneLoader plugin factory
  42813. */
  42814. export interface ISceneLoaderPluginFactory {
  42815. /**
  42816. * Defines the name of the factory
  42817. */
  42818. name: string;
  42819. /**
  42820. * Function called to create a new plugin
  42821. * @return the new plugin
  42822. */
  42823. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42824. /**
  42825. * Boolean indicating if the plugin can direct load specific data
  42826. */
  42827. canDirectLoad?: (data: string) => boolean;
  42828. }
  42829. /**
  42830. * Interface used to define a SceneLoader plugin
  42831. */
  42832. export interface ISceneLoaderPlugin {
  42833. /**
  42834. * The friendly name of this plugin.
  42835. */
  42836. name: string;
  42837. /**
  42838. * The file extensions supported by this plugin.
  42839. */
  42840. extensions: string | ISceneLoaderPluginExtensions;
  42841. /**
  42842. * Import meshes into a scene.
  42843. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42844. * @param scene The scene to import into
  42845. * @param data The data to import
  42846. * @param rootUrl The root url for scene and resources
  42847. * @param meshes The meshes array to import into
  42848. * @param particleSystems The particle systems array to import into
  42849. * @param skeletons The skeletons array to import into
  42850. * @param onError The callback when import fails
  42851. * @returns True if successful or false otherwise
  42852. */
  42853. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42854. /**
  42855. * Load into a scene.
  42856. * @param scene The scene to load into
  42857. * @param data The data to import
  42858. * @param rootUrl The root url for scene and resources
  42859. * @param onError The callback when import fails
  42860. * @returns true if successful or false otherwise
  42861. */
  42862. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42863. /**
  42864. * The callback that returns true if the data can be directly loaded.
  42865. */
  42866. canDirectLoad?: (data: string) => boolean;
  42867. /**
  42868. * The callback that allows custom handling of the root url based on the response url.
  42869. */
  42870. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42871. /**
  42872. * Load into an asset container.
  42873. * @param scene The scene to load into
  42874. * @param data The data to import
  42875. * @param rootUrl The root url for scene and resources
  42876. * @param onError The callback when import fails
  42877. * @returns The loaded asset container
  42878. */
  42879. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42880. }
  42881. /**
  42882. * Interface used to define an async SceneLoader plugin
  42883. */
  42884. export interface ISceneLoaderPluginAsync {
  42885. /**
  42886. * The friendly name of this plugin.
  42887. */
  42888. name: string;
  42889. /**
  42890. * The file extensions supported by this plugin.
  42891. */
  42892. extensions: string | ISceneLoaderPluginExtensions;
  42893. /**
  42894. * Import meshes into a scene.
  42895. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42896. * @param scene The scene to import into
  42897. * @param data The data to import
  42898. * @param rootUrl The root url for scene and resources
  42899. * @param onProgress The callback when the load progresses
  42900. * @param fileName Defines the name of the file to load
  42901. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42902. */
  42903. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42904. meshes: AbstractMesh[];
  42905. particleSystems: IParticleSystem[];
  42906. skeletons: Skeleton[];
  42907. animationGroups: AnimationGroup[];
  42908. }>;
  42909. /**
  42910. * Load into a scene.
  42911. * @param scene The scene to load into
  42912. * @param data The data to import
  42913. * @param rootUrl The root url for scene and resources
  42914. * @param onProgress The callback when the load progresses
  42915. * @param fileName Defines the name of the file to load
  42916. * @returns Nothing
  42917. */
  42918. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42919. /**
  42920. * The callback that returns true if the data can be directly loaded.
  42921. */
  42922. canDirectLoad?: (data: string) => boolean;
  42923. /**
  42924. * The callback that allows custom handling of the root url based on the response url.
  42925. */
  42926. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42927. /**
  42928. * Load into an asset container.
  42929. * @param scene The scene to load into
  42930. * @param data The data to import
  42931. * @param rootUrl The root url for scene and resources
  42932. * @param onProgress The callback when the load progresses
  42933. * @param fileName Defines the name of the file to load
  42934. * @returns The loaded asset container
  42935. */
  42936. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42937. }
  42938. /**
  42939. * Class used to load scene from various file formats using registered plugins
  42940. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42941. */
  42942. export class SceneLoader {
  42943. /**
  42944. * No logging while loading
  42945. */
  42946. static readonly NO_LOGGING: number;
  42947. /**
  42948. * Minimal logging while loading
  42949. */
  42950. static readonly MINIMAL_LOGGING: number;
  42951. /**
  42952. * Summary logging while loading
  42953. */
  42954. static readonly SUMMARY_LOGGING: number;
  42955. /**
  42956. * Detailled logging while loading
  42957. */
  42958. static readonly DETAILED_LOGGING: number;
  42959. /**
  42960. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42961. */
  42962. static ForceFullSceneLoadingForIncremental: boolean;
  42963. /**
  42964. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42965. */
  42966. static ShowLoadingScreen: boolean;
  42967. /**
  42968. * Defines the current logging level (while loading the scene)
  42969. * @ignorenaming
  42970. */
  42971. static loggingLevel: number;
  42972. /**
  42973. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42974. */
  42975. static CleanBoneMatrixWeights: boolean;
  42976. /**
  42977. * Event raised when a plugin is used to load a scene
  42978. */
  42979. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42980. private static _registeredPlugins;
  42981. private static _getDefaultPlugin;
  42982. private static _getPluginForExtension;
  42983. private static _getPluginForDirectLoad;
  42984. private static _getPluginForFilename;
  42985. private static _getDirectLoad;
  42986. private static _loadData;
  42987. private static _getFileInfo;
  42988. /**
  42989. * Gets a plugin that can load the given extension
  42990. * @param extension defines the extension to load
  42991. * @returns a plugin or null if none works
  42992. */
  42993. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42994. /**
  42995. * Gets a boolean indicating that the given extension can be loaded
  42996. * @param extension defines the extension to load
  42997. * @returns true if the extension is supported
  42998. */
  42999. static IsPluginForExtensionAvailable(extension: string): boolean;
  43000. /**
  43001. * Adds a new plugin to the list of registered plugins
  43002. * @param plugin defines the plugin to add
  43003. */
  43004. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43005. /**
  43006. * Import meshes into a scene
  43007. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43008. * @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)
  43009. * @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)
  43010. * @param scene the instance of BABYLON.Scene to append to
  43011. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43012. * @param onProgress a callback with a progress event for each file being loaded
  43013. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43014. * @param pluginExtension the extension used to determine the plugin
  43015. * @returns The loaded plugin
  43016. */
  43017. 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>;
  43018. /**
  43019. * Import meshes into a scene
  43020. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43021. * @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)
  43022. * @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)
  43023. * @param scene the instance of BABYLON.Scene to append to
  43024. * @param onProgress a callback with a progress event for each file being loaded
  43025. * @param pluginExtension the extension used to determine the plugin
  43026. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43027. */
  43028. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43029. meshes: AbstractMesh[];
  43030. particleSystems: IParticleSystem[];
  43031. skeletons: Skeleton[];
  43032. animationGroups: AnimationGroup[];
  43033. }>;
  43034. /**
  43035. * Load a scene
  43036. * @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)
  43037. * @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)
  43038. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43039. * @param onSuccess a callback with the scene when import succeeds
  43040. * @param onProgress a callback with a progress event for each file being loaded
  43041. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43042. * @param pluginExtension the extension used to determine the plugin
  43043. * @returns The loaded plugin
  43044. */
  43045. 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>;
  43046. /**
  43047. * Load a scene
  43048. * @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)
  43049. * @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)
  43050. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43051. * @param onProgress a callback with a progress event for each file being loaded
  43052. * @param pluginExtension the extension used to determine the plugin
  43053. * @returns The loaded scene
  43054. */
  43055. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43056. /**
  43057. * Append a scene
  43058. * @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)
  43059. * @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)
  43060. * @param scene is the instance of BABYLON.Scene to append to
  43061. * @param onSuccess a callback with the scene when import succeeds
  43062. * @param onProgress a callback with a progress event for each file being loaded
  43063. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43064. * @param pluginExtension the extension used to determine the plugin
  43065. * @returns The loaded plugin
  43066. */
  43067. 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>;
  43068. /**
  43069. * Append a scene
  43070. * @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)
  43071. * @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)
  43072. * @param scene is the instance of BABYLON.Scene to append to
  43073. * @param onProgress a callback with a progress event for each file being loaded
  43074. * @param pluginExtension the extension used to determine the plugin
  43075. * @returns The given scene
  43076. */
  43077. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43078. /**
  43079. * Load a scene into an asset container
  43080. * @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)
  43081. * @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)
  43082. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43083. * @param onSuccess a callback with the scene when import succeeds
  43084. * @param onProgress a callback with a progress event for each file being loaded
  43085. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43086. * @param pluginExtension the extension used to determine the plugin
  43087. * @returns The loaded plugin
  43088. */
  43089. 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>;
  43090. /**
  43091. * Load a scene into an asset container
  43092. * @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)
  43093. * @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)
  43094. * @param scene is the instance of Scene to append to
  43095. * @param onProgress a callback with a progress event for each file being loaded
  43096. * @param pluginExtension the extension used to determine the plugin
  43097. * @returns The loaded asset container
  43098. */
  43099. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43100. }
  43101. }
  43102. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43103. import { Scene } from "babylonjs/scene";
  43104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43105. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43106. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43107. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43108. /**
  43109. * Google Daydream controller
  43110. */
  43111. export class DaydreamController extends WebVRController {
  43112. /**
  43113. * Base Url for the controller model.
  43114. */
  43115. static MODEL_BASE_URL: string;
  43116. /**
  43117. * File name for the controller model.
  43118. */
  43119. static MODEL_FILENAME: string;
  43120. /**
  43121. * Gamepad Id prefix used to identify Daydream Controller.
  43122. */
  43123. static readonly GAMEPAD_ID_PREFIX: string;
  43124. /**
  43125. * Creates a new DaydreamController from a gamepad
  43126. * @param vrGamepad the gamepad that the controller should be created from
  43127. */
  43128. constructor(vrGamepad: any);
  43129. /**
  43130. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43131. * @param scene scene in which to add meshes
  43132. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43133. */
  43134. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43135. /**
  43136. * Called once for each button that changed state since the last frame
  43137. * @param buttonIdx Which button index changed
  43138. * @param state New state of the button
  43139. * @param changes Which properties on the state changed since last frame
  43140. */
  43141. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43142. }
  43143. }
  43144. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43145. import { Scene } from "babylonjs/scene";
  43146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43147. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43148. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43149. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43150. /**
  43151. * Gear VR Controller
  43152. */
  43153. export class GearVRController extends WebVRController {
  43154. /**
  43155. * Base Url for the controller model.
  43156. */
  43157. static MODEL_BASE_URL: string;
  43158. /**
  43159. * File name for the controller model.
  43160. */
  43161. static MODEL_FILENAME: string;
  43162. /**
  43163. * Gamepad Id prefix used to identify this controller.
  43164. */
  43165. static readonly GAMEPAD_ID_PREFIX: string;
  43166. private readonly _buttonIndexToObservableNameMap;
  43167. /**
  43168. * Creates a new GearVRController from a gamepad
  43169. * @param vrGamepad the gamepad that the controller should be created from
  43170. */
  43171. constructor(vrGamepad: any);
  43172. /**
  43173. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43174. * @param scene scene in which to add meshes
  43175. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43176. */
  43177. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43178. /**
  43179. * Called once for each button that changed state since the last frame
  43180. * @param buttonIdx Which button index changed
  43181. * @param state New state of the button
  43182. * @param changes Which properties on the state changed since last frame
  43183. */
  43184. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43185. }
  43186. }
  43187. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43188. import { Scene } from "babylonjs/scene";
  43189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43190. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43191. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43192. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43193. /**
  43194. * Generic Controller
  43195. */
  43196. export class GenericController extends WebVRController {
  43197. /**
  43198. * Base Url for the controller model.
  43199. */
  43200. static readonly MODEL_BASE_URL: string;
  43201. /**
  43202. * File name for the controller model.
  43203. */
  43204. static readonly MODEL_FILENAME: string;
  43205. /**
  43206. * Creates a new GenericController from a gamepad
  43207. * @param vrGamepad the gamepad that the controller should be created from
  43208. */
  43209. constructor(vrGamepad: any);
  43210. /**
  43211. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43212. * @param scene scene in which to add meshes
  43213. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43214. */
  43215. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43216. /**
  43217. * Called once for each button that changed state since the last frame
  43218. * @param buttonIdx Which button index changed
  43219. * @param state New state of the button
  43220. * @param changes Which properties on the state changed since last frame
  43221. */
  43222. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43223. }
  43224. }
  43225. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43226. import { Observable } from "babylonjs/Misc/observable";
  43227. import { Scene } from "babylonjs/scene";
  43228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43229. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43230. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43231. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43232. /**
  43233. * Oculus Touch Controller
  43234. */
  43235. export class OculusTouchController extends WebVRController {
  43236. /**
  43237. * Base Url for the controller model.
  43238. */
  43239. static MODEL_BASE_URL: string;
  43240. /**
  43241. * File name for the left controller model.
  43242. */
  43243. static MODEL_LEFT_FILENAME: string;
  43244. /**
  43245. * File name for the right controller model.
  43246. */
  43247. static MODEL_RIGHT_FILENAME: string;
  43248. /**
  43249. * Fired when the secondary trigger on this controller is modified
  43250. */
  43251. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43252. /**
  43253. * Fired when the thumb rest on this controller is modified
  43254. */
  43255. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43256. /**
  43257. * Creates a new OculusTouchController from a gamepad
  43258. * @param vrGamepad the gamepad that the controller should be created from
  43259. */
  43260. constructor(vrGamepad: any);
  43261. /**
  43262. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43263. * @param scene scene in which to add meshes
  43264. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43265. */
  43266. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43267. /**
  43268. * Fired when the A button on this controller is modified
  43269. */
  43270. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43271. /**
  43272. * Fired when the B button on this controller is modified
  43273. */
  43274. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43275. /**
  43276. * Fired when the X button on this controller is modified
  43277. */
  43278. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43279. /**
  43280. * Fired when the Y button on this controller is modified
  43281. */
  43282. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43283. /**
  43284. * Called once for each button that changed state since the last frame
  43285. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43286. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43287. * 2) secondary trigger (same)
  43288. * 3) A (right) X (left), touch, pressed = value
  43289. * 4) B / Y
  43290. * 5) thumb rest
  43291. * @param buttonIdx Which button index changed
  43292. * @param state New state of the button
  43293. * @param changes Which properties on the state changed since last frame
  43294. */
  43295. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43296. }
  43297. }
  43298. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43299. import { Scene } from "babylonjs/scene";
  43300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43301. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43302. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43303. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43304. import { Observable } from "babylonjs/Misc/observable";
  43305. /**
  43306. * Vive Controller
  43307. */
  43308. export class ViveController extends WebVRController {
  43309. /**
  43310. * Base Url for the controller model.
  43311. */
  43312. static MODEL_BASE_URL: string;
  43313. /**
  43314. * File name for the controller model.
  43315. */
  43316. static MODEL_FILENAME: string;
  43317. /**
  43318. * Creates a new ViveController from a gamepad
  43319. * @param vrGamepad the gamepad that the controller should be created from
  43320. */
  43321. constructor(vrGamepad: any);
  43322. /**
  43323. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43324. * @param scene scene in which to add meshes
  43325. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43326. */
  43327. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43328. /**
  43329. * Fired when the left button on this controller is modified
  43330. */
  43331. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43332. /**
  43333. * Fired when the right button on this controller is modified
  43334. */
  43335. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43336. /**
  43337. * Fired when the menu button on this controller is modified
  43338. */
  43339. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43340. /**
  43341. * Called once for each button that changed state since the last frame
  43342. * Vive mapping:
  43343. * 0: touchpad
  43344. * 1: trigger
  43345. * 2: left AND right buttons
  43346. * 3: menu button
  43347. * @param buttonIdx Which button index changed
  43348. * @param state New state of the button
  43349. * @param changes Which properties on the state changed since last frame
  43350. */
  43351. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43352. }
  43353. }
  43354. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43355. import { Observable } from "babylonjs/Misc/observable";
  43356. import { Scene } from "babylonjs/scene";
  43357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43358. import { Ray } from "babylonjs/Culling/ray";
  43359. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43360. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43361. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43362. /**
  43363. * Defines the WindowsMotionController object that the state of the windows motion controller
  43364. */
  43365. export class WindowsMotionController extends WebVRController {
  43366. /**
  43367. * The base url used to load the left and right controller models
  43368. */
  43369. static MODEL_BASE_URL: string;
  43370. /**
  43371. * The name of the left controller model file
  43372. */
  43373. static MODEL_LEFT_FILENAME: string;
  43374. /**
  43375. * The name of the right controller model file
  43376. */
  43377. static MODEL_RIGHT_FILENAME: string;
  43378. /**
  43379. * The controller name prefix for this controller type
  43380. */
  43381. static readonly GAMEPAD_ID_PREFIX: string;
  43382. /**
  43383. * The controller id pattern for this controller type
  43384. */
  43385. private static readonly GAMEPAD_ID_PATTERN;
  43386. private _loadedMeshInfo;
  43387. private readonly _mapping;
  43388. /**
  43389. * Fired when the trackpad on this controller is clicked
  43390. */
  43391. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43392. /**
  43393. * Fired when the trackpad on this controller is modified
  43394. */
  43395. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43396. /**
  43397. * The current x and y values of this controller's trackpad
  43398. */
  43399. trackpad: StickValues;
  43400. /**
  43401. * Creates a new WindowsMotionController from a gamepad
  43402. * @param vrGamepad the gamepad that the controller should be created from
  43403. */
  43404. constructor(vrGamepad: any);
  43405. /**
  43406. * Fired when the trigger on this controller is modified
  43407. */
  43408. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43409. /**
  43410. * Fired when the menu button on this controller is modified
  43411. */
  43412. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43413. /**
  43414. * Fired when the grip button on this controller is modified
  43415. */
  43416. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43417. /**
  43418. * Fired when the thumbstick button on this controller is modified
  43419. */
  43420. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43421. /**
  43422. * Fired when the touchpad button on this controller is modified
  43423. */
  43424. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43425. /**
  43426. * Fired when the touchpad values on this controller are modified
  43427. */
  43428. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43429. private _updateTrackpad;
  43430. /**
  43431. * Called once per frame by the engine.
  43432. */
  43433. update(): void;
  43434. /**
  43435. * Called once for each button that changed state since the last frame
  43436. * @param buttonIdx Which button index changed
  43437. * @param state New state of the button
  43438. * @param changes Which properties on the state changed since last frame
  43439. */
  43440. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43441. /**
  43442. * Moves the buttons on the controller mesh based on their current state
  43443. * @param buttonName the name of the button to move
  43444. * @param buttonValue the value of the button which determines the buttons new position
  43445. */
  43446. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43447. /**
  43448. * Moves the axis on the controller mesh based on its current state
  43449. * @param axis the index of the axis
  43450. * @param axisValue the value of the axis which determines the meshes new position
  43451. * @hidden
  43452. */
  43453. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43454. /**
  43455. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43456. * @param scene scene in which to add meshes
  43457. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43458. */
  43459. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43460. /**
  43461. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43462. * can be transformed by button presses and axes values, based on this._mapping.
  43463. *
  43464. * @param scene scene in which the meshes exist
  43465. * @param meshes list of meshes that make up the controller model to process
  43466. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43467. */
  43468. private processModel;
  43469. private createMeshInfo;
  43470. /**
  43471. * Gets the ray of the controller in the direction the controller is pointing
  43472. * @param length the length the resulting ray should be
  43473. * @returns a ray in the direction the controller is pointing
  43474. */
  43475. getForwardRay(length?: number): Ray;
  43476. /**
  43477. * Disposes of the controller
  43478. */
  43479. dispose(): void;
  43480. }
  43481. }
  43482. declare module "babylonjs/Gamepads/Controllers/index" {
  43483. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43484. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43485. export * from "babylonjs/Gamepads/Controllers/genericController";
  43486. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43487. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43488. export * from "babylonjs/Gamepads/Controllers/viveController";
  43489. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43490. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43491. }
  43492. declare module "babylonjs/Gamepads/index" {
  43493. export * from "babylonjs/Gamepads/Controllers/index";
  43494. export * from "babylonjs/Gamepads/gamepad";
  43495. export * from "babylonjs/Gamepads/gamepadManager";
  43496. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43497. export * from "babylonjs/Gamepads/xboxGamepad";
  43498. }
  43499. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43500. import { Observable } from "babylonjs/Misc/observable";
  43501. import { Nullable } from "babylonjs/types";
  43502. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43504. import { Mesh } from "babylonjs/Meshes/mesh";
  43505. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43506. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43507. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43508. /**
  43509. * Single axis scale gizmo
  43510. */
  43511. export class AxisScaleGizmo extends Gizmo {
  43512. private _coloredMaterial;
  43513. /**
  43514. * Drag behavior responsible for the gizmos dragging interactions
  43515. */
  43516. dragBehavior: PointerDragBehavior;
  43517. private _pointerObserver;
  43518. /**
  43519. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43520. */
  43521. snapDistance: number;
  43522. /**
  43523. * Event that fires each time the gizmo snaps to a new location.
  43524. * * snapDistance is the the change in distance
  43525. */
  43526. onSnapObservable: Observable<{
  43527. snapDistance: number;
  43528. }>;
  43529. /**
  43530. * If the scaling operation should be done on all axis (default: false)
  43531. */
  43532. uniformScaling: boolean;
  43533. /**
  43534. * Creates an AxisScaleGizmo
  43535. * @param gizmoLayer The utility layer the gizmo will be added to
  43536. * @param dragAxis The axis which the gizmo will be able to scale on
  43537. * @param color The color of the gizmo
  43538. */
  43539. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43540. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43541. /**
  43542. * Disposes of the gizmo
  43543. */
  43544. dispose(): void;
  43545. /**
  43546. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43547. * @param mesh The mesh to replace the default mesh of the gizmo
  43548. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43549. */
  43550. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43551. }
  43552. }
  43553. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43554. import { Observable } from "babylonjs/Misc/observable";
  43555. import { Nullable } from "babylonjs/types";
  43556. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43558. import { Mesh } from "babylonjs/Meshes/mesh";
  43559. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43560. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43561. import "babylonjs/Meshes/Builders/boxBuilder";
  43562. /**
  43563. * Bounding box gizmo
  43564. */
  43565. export class BoundingBoxGizmo extends Gizmo {
  43566. private _lineBoundingBox;
  43567. private _rotateSpheresParent;
  43568. private _scaleBoxesParent;
  43569. private _boundingDimensions;
  43570. private _renderObserver;
  43571. private _pointerObserver;
  43572. private _scaleDragSpeed;
  43573. private _tmpQuaternion;
  43574. private _tmpVector;
  43575. private _tmpRotationMatrix;
  43576. /**
  43577. * 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)
  43578. */
  43579. ignoreChildren: boolean;
  43580. /**
  43581. * 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)
  43582. */
  43583. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43584. /**
  43585. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43586. */
  43587. rotationSphereSize: number;
  43588. /**
  43589. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43590. */
  43591. scaleBoxSize: number;
  43592. /**
  43593. * 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)
  43594. */
  43595. fixedDragMeshScreenSize: boolean;
  43596. /**
  43597. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43598. */
  43599. fixedDragMeshScreenSizeDistanceFactor: number;
  43600. /**
  43601. * Fired when a rotation sphere or scale box is dragged
  43602. */
  43603. onDragStartObservable: Observable<{}>;
  43604. /**
  43605. * Fired when a scale box is dragged
  43606. */
  43607. onScaleBoxDragObservable: Observable<{}>;
  43608. /**
  43609. * Fired when a scale box drag is ended
  43610. */
  43611. onScaleBoxDragEndObservable: Observable<{}>;
  43612. /**
  43613. * Fired when a rotation sphere is dragged
  43614. */
  43615. onRotationSphereDragObservable: Observable<{}>;
  43616. /**
  43617. * Fired when a rotation sphere drag is ended
  43618. */
  43619. onRotationSphereDragEndObservable: Observable<{}>;
  43620. /**
  43621. * 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)
  43622. */
  43623. scalePivot: Nullable<Vector3>;
  43624. private _anchorMesh;
  43625. private _existingMeshScale;
  43626. private _dragMesh;
  43627. private pointerDragBehavior;
  43628. private coloredMaterial;
  43629. private hoverColoredMaterial;
  43630. /**
  43631. * Sets the color of the bounding box gizmo
  43632. * @param color the color to set
  43633. */
  43634. setColor(color: Color3): void;
  43635. /**
  43636. * Creates an BoundingBoxGizmo
  43637. * @param gizmoLayer The utility layer the gizmo will be added to
  43638. * @param color The color of the gizmo
  43639. */
  43640. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43641. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43642. private _selectNode;
  43643. /**
  43644. * Updates the bounding box information for the Gizmo
  43645. */
  43646. updateBoundingBox(): void;
  43647. private _updateRotationSpheres;
  43648. private _updateScaleBoxes;
  43649. /**
  43650. * Enables rotation on the specified axis and disables rotation on the others
  43651. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43652. */
  43653. setEnabledRotationAxis(axis: string): void;
  43654. /**
  43655. * Enables/disables scaling
  43656. * @param enable if scaling should be enabled
  43657. */
  43658. setEnabledScaling(enable: boolean): void;
  43659. private _updateDummy;
  43660. /**
  43661. * Enables a pointer drag behavior on the bounding box of the gizmo
  43662. */
  43663. enableDragBehavior(): void;
  43664. /**
  43665. * Disposes of the gizmo
  43666. */
  43667. dispose(): void;
  43668. /**
  43669. * 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)
  43670. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43671. * @returns the bounding box mesh with the passed in mesh as a child
  43672. */
  43673. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43674. /**
  43675. * CustomMeshes are not supported by this gizmo
  43676. * @param mesh The mesh to replace the default mesh of the gizmo
  43677. */
  43678. setCustomMesh(mesh: Mesh): void;
  43679. }
  43680. }
  43681. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43682. import { Observable } from "babylonjs/Misc/observable";
  43683. import { Nullable } from "babylonjs/types";
  43684. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43686. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43687. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43688. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43689. import "babylonjs/Meshes/Builders/linesBuilder";
  43690. /**
  43691. * Single plane rotation gizmo
  43692. */
  43693. export class PlaneRotationGizmo extends Gizmo {
  43694. /**
  43695. * Drag behavior responsible for the gizmos dragging interactions
  43696. */
  43697. dragBehavior: PointerDragBehavior;
  43698. private _pointerObserver;
  43699. /**
  43700. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43701. */
  43702. snapDistance: number;
  43703. /**
  43704. * Event that fires each time the gizmo snaps to a new location.
  43705. * * snapDistance is the the change in distance
  43706. */
  43707. onSnapObservable: Observable<{
  43708. snapDistance: number;
  43709. }>;
  43710. /**
  43711. * Creates a PlaneRotationGizmo
  43712. * @param gizmoLayer The utility layer the gizmo will be added to
  43713. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43714. * @param color The color of the gizmo
  43715. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43716. */
  43717. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43718. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43719. /**
  43720. * Disposes of the gizmo
  43721. */
  43722. dispose(): void;
  43723. }
  43724. }
  43725. declare module "babylonjs/Gizmos/rotationGizmo" {
  43726. import { Observable } from "babylonjs/Misc/observable";
  43727. import { Nullable } from "babylonjs/types";
  43728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43729. import { Mesh } from "babylonjs/Meshes/mesh";
  43730. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43731. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43732. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43733. /**
  43734. * Gizmo that enables rotating a mesh along 3 axis
  43735. */
  43736. export class RotationGizmo extends Gizmo {
  43737. /**
  43738. * Internal gizmo used for interactions on the x axis
  43739. */
  43740. xGizmo: PlaneRotationGizmo;
  43741. /**
  43742. * Internal gizmo used for interactions on the y axis
  43743. */
  43744. yGizmo: PlaneRotationGizmo;
  43745. /**
  43746. * Internal gizmo used for interactions on the z axis
  43747. */
  43748. zGizmo: PlaneRotationGizmo;
  43749. /** Fires an event when any of it's sub gizmos are dragged */
  43750. onDragStartObservable: Observable<{}>;
  43751. /** Fires an event when any of it's sub gizmos are released from dragging */
  43752. onDragEndObservable: Observable<{}>;
  43753. attachedMesh: Nullable<AbstractMesh>;
  43754. /**
  43755. * Creates a RotationGizmo
  43756. * @param gizmoLayer The utility layer the gizmo will be added to
  43757. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43758. */
  43759. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43760. updateGizmoRotationToMatchAttachedMesh: boolean;
  43761. /**
  43762. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43763. */
  43764. snapDistance: number;
  43765. /**
  43766. * Ratio for the scale of the gizmo (Default: 1)
  43767. */
  43768. scaleRatio: number;
  43769. /**
  43770. * Disposes of the gizmo
  43771. */
  43772. dispose(): void;
  43773. /**
  43774. * CustomMeshes are not supported by this gizmo
  43775. * @param mesh The mesh to replace the default mesh of the gizmo
  43776. */
  43777. setCustomMesh(mesh: Mesh): void;
  43778. }
  43779. }
  43780. declare module "babylonjs/Gizmos/positionGizmo" {
  43781. import { Observable } from "babylonjs/Misc/observable";
  43782. import { Nullable } from "babylonjs/types";
  43783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43784. import { Mesh } from "babylonjs/Meshes/mesh";
  43785. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43786. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43787. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43788. /**
  43789. * Gizmo that enables dragging a mesh along 3 axis
  43790. */
  43791. export class PositionGizmo extends Gizmo {
  43792. /**
  43793. * Internal gizmo used for interactions on the x axis
  43794. */
  43795. xGizmo: AxisDragGizmo;
  43796. /**
  43797. * Internal gizmo used for interactions on the y axis
  43798. */
  43799. yGizmo: AxisDragGizmo;
  43800. /**
  43801. * Internal gizmo used for interactions on the z axis
  43802. */
  43803. zGizmo: AxisDragGizmo;
  43804. /** Fires an event when any of it's sub gizmos are dragged */
  43805. onDragStartObservable: Observable<{}>;
  43806. /** Fires an event when any of it's sub gizmos are released from dragging */
  43807. onDragEndObservable: Observable<{}>;
  43808. attachedMesh: Nullable<AbstractMesh>;
  43809. /**
  43810. * Creates a PositionGizmo
  43811. * @param gizmoLayer The utility layer the gizmo will be added to
  43812. */
  43813. constructor(gizmoLayer?: UtilityLayerRenderer);
  43814. updateGizmoRotationToMatchAttachedMesh: boolean;
  43815. /**
  43816. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43817. */
  43818. snapDistance: number;
  43819. /**
  43820. * Ratio for the scale of the gizmo (Default: 1)
  43821. */
  43822. scaleRatio: number;
  43823. /**
  43824. * Disposes of the gizmo
  43825. */
  43826. dispose(): void;
  43827. /**
  43828. * CustomMeshes are not supported by this gizmo
  43829. * @param mesh The mesh to replace the default mesh of the gizmo
  43830. */
  43831. setCustomMesh(mesh: Mesh): void;
  43832. }
  43833. }
  43834. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43835. import { Scene } from "babylonjs/scene";
  43836. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43837. import { Mesh } from "babylonjs/Meshes/mesh";
  43838. /**
  43839. * Class containing static functions to help procedurally build meshes
  43840. */
  43841. export class PolyhedronBuilder {
  43842. /**
  43843. * Creates a polyhedron mesh
  43844. * * 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
  43845. * * The parameter `size` (positive float, default 1) sets the polygon size
  43846. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43847. * * 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`
  43848. * * 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
  43849. * * 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)`)
  43850. * * 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
  43851. * * 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
  43852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43855. * @param name defines the name of the mesh
  43856. * @param options defines the options used to create the mesh
  43857. * @param scene defines the hosting scene
  43858. * @returns the polyhedron mesh
  43859. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43860. */
  43861. static CreatePolyhedron(name: string, options: {
  43862. type?: number;
  43863. size?: number;
  43864. sizeX?: number;
  43865. sizeY?: number;
  43866. sizeZ?: number;
  43867. custom?: any;
  43868. faceUV?: Vector4[];
  43869. faceColors?: Color4[];
  43870. flat?: boolean;
  43871. updatable?: boolean;
  43872. sideOrientation?: number;
  43873. frontUVs?: Vector4;
  43874. backUVs?: Vector4;
  43875. }, scene: Scene): Mesh;
  43876. }
  43877. }
  43878. declare module "babylonjs/Gizmos/scaleGizmo" {
  43879. import { Observable } from "babylonjs/Misc/observable";
  43880. import { Nullable } from "babylonjs/types";
  43881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43882. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43883. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43884. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43885. /**
  43886. * Gizmo that enables scaling a mesh along 3 axis
  43887. */
  43888. export class ScaleGizmo extends Gizmo {
  43889. /**
  43890. * Internal gizmo used for interactions on the x axis
  43891. */
  43892. xGizmo: AxisScaleGizmo;
  43893. /**
  43894. * Internal gizmo used for interactions on the y axis
  43895. */
  43896. yGizmo: AxisScaleGizmo;
  43897. /**
  43898. * Internal gizmo used for interactions on the z axis
  43899. */
  43900. zGizmo: AxisScaleGizmo;
  43901. /**
  43902. * Internal gizmo used to scale all axis equally
  43903. */
  43904. uniformScaleGizmo: AxisScaleGizmo;
  43905. /** Fires an event when any of it's sub gizmos are dragged */
  43906. onDragStartObservable: Observable<{}>;
  43907. /** Fires an event when any of it's sub gizmos are released from dragging */
  43908. onDragEndObservable: Observable<{}>;
  43909. attachedMesh: Nullable<AbstractMesh>;
  43910. /**
  43911. * Creates a ScaleGizmo
  43912. * @param gizmoLayer The utility layer the gizmo will be added to
  43913. */
  43914. constructor(gizmoLayer?: UtilityLayerRenderer);
  43915. updateGizmoRotationToMatchAttachedMesh: boolean;
  43916. /**
  43917. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43918. */
  43919. snapDistance: number;
  43920. /**
  43921. * Ratio for the scale of the gizmo (Default: 1)
  43922. */
  43923. scaleRatio: number;
  43924. /**
  43925. * Disposes of the gizmo
  43926. */
  43927. dispose(): void;
  43928. }
  43929. }
  43930. declare module "babylonjs/Gizmos/gizmoManager" {
  43931. import { Observable } from "babylonjs/Misc/observable";
  43932. import { Nullable } from "babylonjs/types";
  43933. import { Scene, IDisposable } from "babylonjs/scene";
  43934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43935. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43936. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43937. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43938. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43939. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43940. /**
  43941. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43942. */
  43943. export class GizmoManager implements IDisposable {
  43944. private scene;
  43945. /**
  43946. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43947. */
  43948. gizmos: {
  43949. positionGizmo: Nullable<PositionGizmo>;
  43950. rotationGizmo: Nullable<RotationGizmo>;
  43951. scaleGizmo: Nullable<ScaleGizmo>;
  43952. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43953. };
  43954. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43955. clearGizmoOnEmptyPointerEvent: boolean;
  43956. /** Fires an event when the manager is attached to a mesh */
  43957. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43958. private _gizmosEnabled;
  43959. private _pointerObserver;
  43960. private _attachedMesh;
  43961. private _boundingBoxColor;
  43962. private _defaultUtilityLayer;
  43963. private _defaultKeepDepthUtilityLayer;
  43964. /**
  43965. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43966. */
  43967. boundingBoxDragBehavior: SixDofDragBehavior;
  43968. /**
  43969. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43970. */
  43971. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43972. /**
  43973. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43974. */
  43975. usePointerToAttachGizmos: boolean;
  43976. /**
  43977. * Instatiates a gizmo manager
  43978. * @param scene the scene to overlay the gizmos on top of
  43979. */
  43980. constructor(scene: Scene);
  43981. /**
  43982. * Attaches a set of gizmos to the specified mesh
  43983. * @param mesh The mesh the gizmo's should be attached to
  43984. */
  43985. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43986. /**
  43987. * If the position gizmo is enabled
  43988. */
  43989. positionGizmoEnabled: boolean;
  43990. /**
  43991. * If the rotation gizmo is enabled
  43992. */
  43993. rotationGizmoEnabled: boolean;
  43994. /**
  43995. * If the scale gizmo is enabled
  43996. */
  43997. scaleGizmoEnabled: boolean;
  43998. /**
  43999. * If the boundingBox gizmo is enabled
  44000. */
  44001. boundingBoxGizmoEnabled: boolean;
  44002. /**
  44003. * Disposes of the gizmo manager
  44004. */
  44005. dispose(): void;
  44006. }
  44007. }
  44008. declare module "babylonjs/Gizmos/lightGizmo" {
  44009. import { Nullable } from "babylonjs/types";
  44010. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44011. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44012. import { Light } from "babylonjs/Lights/light";
  44013. /**
  44014. * Gizmo that enables viewing a light
  44015. */
  44016. export class LightGizmo extends Gizmo {
  44017. private _box;
  44018. /**
  44019. * Creates a LightGizmo
  44020. * @param gizmoLayer The utility layer the gizmo will be added to
  44021. */
  44022. constructor(gizmoLayer?: UtilityLayerRenderer);
  44023. private _light;
  44024. /**
  44025. * The light that the gizmo is attached to
  44026. */
  44027. light: Nullable<Light>;
  44028. /**
  44029. * @hidden
  44030. * Updates the gizmo to match the attached mesh's position/rotation
  44031. */
  44032. protected _update(): void;
  44033. }
  44034. }
  44035. declare module "babylonjs/Gizmos/index" {
  44036. export * from "babylonjs/Gizmos/axisDragGizmo";
  44037. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44038. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44039. export * from "babylonjs/Gizmos/gizmo";
  44040. export * from "babylonjs/Gizmos/gizmoManager";
  44041. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44042. export * from "babylonjs/Gizmos/positionGizmo";
  44043. export * from "babylonjs/Gizmos/rotationGizmo";
  44044. export * from "babylonjs/Gizmos/scaleGizmo";
  44045. export * from "babylonjs/Gizmos/lightGizmo";
  44046. }
  44047. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44048. /** @hidden */
  44049. export var backgroundFragmentDeclaration: {
  44050. name: string;
  44051. shader: string;
  44052. };
  44053. }
  44054. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44055. /** @hidden */
  44056. export var backgroundUboDeclaration: {
  44057. name: string;
  44058. shader: string;
  44059. };
  44060. }
  44061. declare module "babylonjs/Shaders/background.fragment" {
  44062. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44063. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44064. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44065. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44066. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44067. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44068. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44069. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44070. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44071. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44072. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44073. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44074. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44075. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44076. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44077. /** @hidden */
  44078. export var backgroundPixelShader: {
  44079. name: string;
  44080. shader: string;
  44081. };
  44082. }
  44083. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44084. /** @hidden */
  44085. export var backgroundVertexDeclaration: {
  44086. name: string;
  44087. shader: string;
  44088. };
  44089. }
  44090. declare module "babylonjs/Shaders/background.vertex" {
  44091. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44092. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44093. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44094. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44095. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44096. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44097. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44098. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44099. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44100. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44102. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44103. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44104. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44105. /** @hidden */
  44106. export var backgroundVertexShader: {
  44107. name: string;
  44108. shader: string;
  44109. };
  44110. }
  44111. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44112. import { Nullable, int, float } from "babylonjs/types";
  44113. import { Scene } from "babylonjs/scene";
  44114. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44115. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44117. import { Mesh } from "babylonjs/Meshes/mesh";
  44118. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44119. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44120. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44122. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44123. import "babylonjs/Shaders/background.fragment";
  44124. import "babylonjs/Shaders/background.vertex";
  44125. /**
  44126. * Background material used to create an efficient environement around your scene.
  44127. */
  44128. export class BackgroundMaterial extends PushMaterial {
  44129. /**
  44130. * Standard reflectance value at parallel view angle.
  44131. */
  44132. static StandardReflectance0: number;
  44133. /**
  44134. * Standard reflectance value at grazing angle.
  44135. */
  44136. static StandardReflectance90: number;
  44137. protected _primaryColor: Color3;
  44138. /**
  44139. * Key light Color (multiply against the environement texture)
  44140. */
  44141. primaryColor: Color3;
  44142. protected __perceptualColor: Nullable<Color3>;
  44143. /**
  44144. * Experimental Internal Use Only.
  44145. *
  44146. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44147. * This acts as a helper to set the primary color to a more "human friendly" value.
  44148. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44149. * output color as close as possible from the chosen value.
  44150. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44151. * part of lighting setup.)
  44152. */
  44153. _perceptualColor: Nullable<Color3>;
  44154. protected _primaryColorShadowLevel: float;
  44155. /**
  44156. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44157. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44158. */
  44159. primaryColorShadowLevel: float;
  44160. protected _primaryColorHighlightLevel: float;
  44161. /**
  44162. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44163. * The primary color is used at the level chosen to define what the white area would look.
  44164. */
  44165. primaryColorHighlightLevel: float;
  44166. protected _reflectionTexture: Nullable<BaseTexture>;
  44167. /**
  44168. * Reflection Texture used in the material.
  44169. * Should be author in a specific way for the best result (refer to the documentation).
  44170. */
  44171. reflectionTexture: Nullable<BaseTexture>;
  44172. protected _reflectionBlur: float;
  44173. /**
  44174. * Reflection Texture level of blur.
  44175. *
  44176. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44177. * texture twice.
  44178. */
  44179. reflectionBlur: float;
  44180. protected _diffuseTexture: Nullable<BaseTexture>;
  44181. /**
  44182. * Diffuse Texture used in the material.
  44183. * Should be author in a specific way for the best result (refer to the documentation).
  44184. */
  44185. diffuseTexture: Nullable<BaseTexture>;
  44186. protected _shadowLights: Nullable<IShadowLight[]>;
  44187. /**
  44188. * Specify the list of lights casting shadow on the material.
  44189. * All scene shadow lights will be included if null.
  44190. */
  44191. shadowLights: Nullable<IShadowLight[]>;
  44192. protected _shadowLevel: float;
  44193. /**
  44194. * Helps adjusting the shadow to a softer level if required.
  44195. * 0 means black shadows and 1 means no shadows.
  44196. */
  44197. shadowLevel: float;
  44198. protected _sceneCenter: Vector3;
  44199. /**
  44200. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44201. * It is usually zero but might be interesting to modify according to your setup.
  44202. */
  44203. sceneCenter: Vector3;
  44204. protected _opacityFresnel: boolean;
  44205. /**
  44206. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44207. * This helps ensuring a nice transition when the camera goes under the ground.
  44208. */
  44209. opacityFresnel: boolean;
  44210. protected _reflectionFresnel: boolean;
  44211. /**
  44212. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44213. * This helps adding a mirror texture on the ground.
  44214. */
  44215. reflectionFresnel: boolean;
  44216. protected _reflectionFalloffDistance: number;
  44217. /**
  44218. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44219. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44220. */
  44221. reflectionFalloffDistance: number;
  44222. protected _reflectionAmount: number;
  44223. /**
  44224. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44225. */
  44226. reflectionAmount: number;
  44227. protected _reflectionReflectance0: number;
  44228. /**
  44229. * This specifies the weight of the reflection at grazing angle.
  44230. */
  44231. reflectionReflectance0: number;
  44232. protected _reflectionReflectance90: number;
  44233. /**
  44234. * This specifies the weight of the reflection at a perpendicular point of view.
  44235. */
  44236. reflectionReflectance90: number;
  44237. /**
  44238. * Sets the reflection reflectance fresnel values according to the default standard
  44239. * empirically know to work well :-)
  44240. */
  44241. reflectionStandardFresnelWeight: number;
  44242. protected _useRGBColor: boolean;
  44243. /**
  44244. * Helps to directly use the maps channels instead of their level.
  44245. */
  44246. useRGBColor: boolean;
  44247. protected _enableNoise: boolean;
  44248. /**
  44249. * This helps reducing the banding effect that could occur on the background.
  44250. */
  44251. enableNoise: boolean;
  44252. /**
  44253. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44254. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44255. * Recommended to be keep at 1.0 except for special cases.
  44256. */
  44257. fovMultiplier: number;
  44258. private _fovMultiplier;
  44259. /**
  44260. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44261. */
  44262. useEquirectangularFOV: boolean;
  44263. private _maxSimultaneousLights;
  44264. /**
  44265. * Number of Simultaneous lights allowed on the material.
  44266. */
  44267. maxSimultaneousLights: int;
  44268. /**
  44269. * Default configuration related to image processing available in the Background Material.
  44270. */
  44271. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44272. /**
  44273. * Keep track of the image processing observer to allow dispose and replace.
  44274. */
  44275. private _imageProcessingObserver;
  44276. /**
  44277. * Attaches a new image processing configuration to the PBR Material.
  44278. * @param configuration (if null the scene configuration will be use)
  44279. */
  44280. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44281. /**
  44282. * Gets the image processing configuration used either in this material.
  44283. */
  44284. /**
  44285. * Sets the Default image processing configuration used either in the this material.
  44286. *
  44287. * If sets to null, the scene one is in use.
  44288. */
  44289. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44290. /**
  44291. * Gets wether the color curves effect is enabled.
  44292. */
  44293. /**
  44294. * Sets wether the color curves effect is enabled.
  44295. */
  44296. cameraColorCurvesEnabled: boolean;
  44297. /**
  44298. * Gets wether the color grading effect is enabled.
  44299. */
  44300. /**
  44301. * Gets wether the color grading effect is enabled.
  44302. */
  44303. cameraColorGradingEnabled: boolean;
  44304. /**
  44305. * Gets wether tonemapping is enabled or not.
  44306. */
  44307. /**
  44308. * Sets wether tonemapping is enabled or not
  44309. */
  44310. cameraToneMappingEnabled: boolean;
  44311. /**
  44312. * The camera exposure used on this material.
  44313. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44314. * This corresponds to a photographic exposure.
  44315. */
  44316. /**
  44317. * The camera exposure used on this material.
  44318. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44319. * This corresponds to a photographic exposure.
  44320. */
  44321. cameraExposure: float;
  44322. /**
  44323. * Gets The camera contrast used on this material.
  44324. */
  44325. /**
  44326. * Sets The camera contrast used on this material.
  44327. */
  44328. cameraContrast: float;
  44329. /**
  44330. * Gets the Color Grading 2D Lookup Texture.
  44331. */
  44332. /**
  44333. * Sets the Color Grading 2D Lookup Texture.
  44334. */
  44335. cameraColorGradingTexture: Nullable<BaseTexture>;
  44336. /**
  44337. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44338. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44339. * 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;
  44340. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44341. */
  44342. /**
  44343. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44344. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44345. * 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;
  44346. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44347. */
  44348. cameraColorCurves: Nullable<ColorCurves>;
  44349. /**
  44350. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44351. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44352. */
  44353. switchToBGR: boolean;
  44354. private _renderTargets;
  44355. private _reflectionControls;
  44356. private _white;
  44357. private _primaryShadowColor;
  44358. private _primaryHighlightColor;
  44359. /**
  44360. * Instantiates a Background Material in the given scene
  44361. * @param name The friendly name of the material
  44362. * @param scene The scene to add the material to
  44363. */
  44364. constructor(name: string, scene: Scene);
  44365. /**
  44366. * Gets a boolean indicating that current material needs to register RTT
  44367. */
  44368. readonly hasRenderTargetTextures: boolean;
  44369. /**
  44370. * The entire material has been created in order to prevent overdraw.
  44371. * @returns false
  44372. */
  44373. needAlphaTesting(): boolean;
  44374. /**
  44375. * The entire material has been created in order to prevent overdraw.
  44376. * @returns true if blending is enable
  44377. */
  44378. needAlphaBlending(): boolean;
  44379. /**
  44380. * Checks wether the material is ready to be rendered for a given mesh.
  44381. * @param mesh The mesh to render
  44382. * @param subMesh The submesh to check against
  44383. * @param useInstances Specify wether or not the material is used with instances
  44384. * @returns true if all the dependencies are ready (Textures, Effects...)
  44385. */
  44386. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44387. /**
  44388. * Compute the primary color according to the chosen perceptual color.
  44389. */
  44390. private _computePrimaryColorFromPerceptualColor;
  44391. /**
  44392. * Compute the highlights and shadow colors according to their chosen levels.
  44393. */
  44394. private _computePrimaryColors;
  44395. /**
  44396. * Build the uniform buffer used in the material.
  44397. */
  44398. buildUniformLayout(): void;
  44399. /**
  44400. * Unbind the material.
  44401. */
  44402. unbind(): void;
  44403. /**
  44404. * Bind only the world matrix to the material.
  44405. * @param world The world matrix to bind.
  44406. */
  44407. bindOnlyWorldMatrix(world: Matrix): void;
  44408. /**
  44409. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44410. * @param world The world matrix to bind.
  44411. * @param subMesh The submesh to bind for.
  44412. */
  44413. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44414. /**
  44415. * Dispose the material.
  44416. * @param forceDisposeEffect Force disposal of the associated effect.
  44417. * @param forceDisposeTextures Force disposal of the associated textures.
  44418. */
  44419. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44420. /**
  44421. * Clones the material.
  44422. * @param name The cloned name.
  44423. * @returns The cloned material.
  44424. */
  44425. clone(name: string): BackgroundMaterial;
  44426. /**
  44427. * Serializes the current material to its JSON representation.
  44428. * @returns The JSON representation.
  44429. */
  44430. serialize(): any;
  44431. /**
  44432. * Gets the class name of the material
  44433. * @returns "BackgroundMaterial"
  44434. */
  44435. getClassName(): string;
  44436. /**
  44437. * Parse a JSON input to create back a background material.
  44438. * @param source The JSON data to parse
  44439. * @param scene The scene to create the parsed material in
  44440. * @param rootUrl The root url of the assets the material depends upon
  44441. * @returns the instantiated BackgroundMaterial.
  44442. */
  44443. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44444. }
  44445. }
  44446. declare module "babylonjs/Helpers/environmentHelper" {
  44447. import { Observable } from "babylonjs/Misc/observable";
  44448. import { Nullable } from "babylonjs/types";
  44449. import { Scene } from "babylonjs/scene";
  44450. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44452. import { Mesh } from "babylonjs/Meshes/mesh";
  44453. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44454. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44455. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44456. import "babylonjs/Meshes/Builders/planeBuilder";
  44457. import "babylonjs/Meshes/Builders/boxBuilder";
  44458. /**
  44459. * Represents the different options available during the creation of
  44460. * a Environment helper.
  44461. *
  44462. * This can control the default ground, skybox and image processing setup of your scene.
  44463. */
  44464. export interface IEnvironmentHelperOptions {
  44465. /**
  44466. * Specifies wether or not to create a ground.
  44467. * True by default.
  44468. */
  44469. createGround: boolean;
  44470. /**
  44471. * Specifies the ground size.
  44472. * 15 by default.
  44473. */
  44474. groundSize: number;
  44475. /**
  44476. * The texture used on the ground for the main color.
  44477. * Comes from the BabylonJS CDN by default.
  44478. *
  44479. * Remarks: Can be either a texture or a url.
  44480. */
  44481. groundTexture: string | BaseTexture;
  44482. /**
  44483. * The color mixed in the ground texture by default.
  44484. * BabylonJS clearColor by default.
  44485. */
  44486. groundColor: Color3;
  44487. /**
  44488. * Specifies the ground opacity.
  44489. * 1 by default.
  44490. */
  44491. groundOpacity: number;
  44492. /**
  44493. * Enables the ground to receive shadows.
  44494. * True by default.
  44495. */
  44496. enableGroundShadow: boolean;
  44497. /**
  44498. * Helps preventing the shadow to be fully black on the ground.
  44499. * 0.5 by default.
  44500. */
  44501. groundShadowLevel: number;
  44502. /**
  44503. * Creates a mirror texture attach to the ground.
  44504. * false by default.
  44505. */
  44506. enableGroundMirror: boolean;
  44507. /**
  44508. * Specifies the ground mirror size ratio.
  44509. * 0.3 by default as the default kernel is 64.
  44510. */
  44511. groundMirrorSizeRatio: number;
  44512. /**
  44513. * Specifies the ground mirror blur kernel size.
  44514. * 64 by default.
  44515. */
  44516. groundMirrorBlurKernel: number;
  44517. /**
  44518. * Specifies the ground mirror visibility amount.
  44519. * 1 by default
  44520. */
  44521. groundMirrorAmount: number;
  44522. /**
  44523. * Specifies the ground mirror reflectance weight.
  44524. * This uses the standard weight of the background material to setup the fresnel effect
  44525. * of the mirror.
  44526. * 1 by default.
  44527. */
  44528. groundMirrorFresnelWeight: number;
  44529. /**
  44530. * Specifies the ground mirror Falloff distance.
  44531. * This can helps reducing the size of the reflection.
  44532. * 0 by Default.
  44533. */
  44534. groundMirrorFallOffDistance: number;
  44535. /**
  44536. * Specifies the ground mirror texture type.
  44537. * Unsigned Int by Default.
  44538. */
  44539. groundMirrorTextureType: number;
  44540. /**
  44541. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44542. * the shown objects.
  44543. */
  44544. groundYBias: number;
  44545. /**
  44546. * Specifies wether or not to create a skybox.
  44547. * True by default.
  44548. */
  44549. createSkybox: boolean;
  44550. /**
  44551. * Specifies the skybox size.
  44552. * 20 by default.
  44553. */
  44554. skyboxSize: number;
  44555. /**
  44556. * The texture used on the skybox for the main color.
  44557. * Comes from the BabylonJS CDN by default.
  44558. *
  44559. * Remarks: Can be either a texture or a url.
  44560. */
  44561. skyboxTexture: string | BaseTexture;
  44562. /**
  44563. * The color mixed in the skybox texture by default.
  44564. * BabylonJS clearColor by default.
  44565. */
  44566. skyboxColor: Color3;
  44567. /**
  44568. * The background rotation around the Y axis of the scene.
  44569. * This helps aligning the key lights of your scene with the background.
  44570. * 0 by default.
  44571. */
  44572. backgroundYRotation: number;
  44573. /**
  44574. * Compute automatically the size of the elements to best fit with the scene.
  44575. */
  44576. sizeAuto: boolean;
  44577. /**
  44578. * Default position of the rootMesh if autoSize is not true.
  44579. */
  44580. rootPosition: Vector3;
  44581. /**
  44582. * Sets up the image processing in the scene.
  44583. * true by default.
  44584. */
  44585. setupImageProcessing: boolean;
  44586. /**
  44587. * The texture used as your environment texture in the scene.
  44588. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44589. *
  44590. * Remarks: Can be either a texture or a url.
  44591. */
  44592. environmentTexture: string | BaseTexture;
  44593. /**
  44594. * The value of the exposure to apply to the scene.
  44595. * 0.6 by default if setupImageProcessing is true.
  44596. */
  44597. cameraExposure: number;
  44598. /**
  44599. * The value of the contrast to apply to the scene.
  44600. * 1.6 by default if setupImageProcessing is true.
  44601. */
  44602. cameraContrast: number;
  44603. /**
  44604. * Specifies wether or not tonemapping should be enabled in the scene.
  44605. * true by default if setupImageProcessing is true.
  44606. */
  44607. toneMappingEnabled: boolean;
  44608. }
  44609. /**
  44610. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44611. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44612. * It also helps with the default setup of your imageProcessing configuration.
  44613. */
  44614. export class EnvironmentHelper {
  44615. /**
  44616. * Default ground texture URL.
  44617. */
  44618. private static _groundTextureCDNUrl;
  44619. /**
  44620. * Default skybox texture URL.
  44621. */
  44622. private static _skyboxTextureCDNUrl;
  44623. /**
  44624. * Default environment texture URL.
  44625. */
  44626. private static _environmentTextureCDNUrl;
  44627. /**
  44628. * Creates the default options for the helper.
  44629. */
  44630. private static _getDefaultOptions;
  44631. private _rootMesh;
  44632. /**
  44633. * Gets the root mesh created by the helper.
  44634. */
  44635. readonly rootMesh: Mesh;
  44636. private _skybox;
  44637. /**
  44638. * Gets the skybox created by the helper.
  44639. */
  44640. readonly skybox: Nullable<Mesh>;
  44641. private _skyboxTexture;
  44642. /**
  44643. * Gets the skybox texture created by the helper.
  44644. */
  44645. readonly skyboxTexture: Nullable<BaseTexture>;
  44646. private _skyboxMaterial;
  44647. /**
  44648. * Gets the skybox material created by the helper.
  44649. */
  44650. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44651. private _ground;
  44652. /**
  44653. * Gets the ground mesh created by the helper.
  44654. */
  44655. readonly ground: Nullable<Mesh>;
  44656. private _groundTexture;
  44657. /**
  44658. * Gets the ground texture created by the helper.
  44659. */
  44660. readonly groundTexture: Nullable<BaseTexture>;
  44661. private _groundMirror;
  44662. /**
  44663. * Gets the ground mirror created by the helper.
  44664. */
  44665. readonly groundMirror: Nullable<MirrorTexture>;
  44666. /**
  44667. * Gets the ground mirror render list to helps pushing the meshes
  44668. * you wish in the ground reflection.
  44669. */
  44670. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44671. private _groundMaterial;
  44672. /**
  44673. * Gets the ground material created by the helper.
  44674. */
  44675. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44676. /**
  44677. * Stores the creation options.
  44678. */
  44679. private readonly _scene;
  44680. private _options;
  44681. /**
  44682. * This observable will be notified with any error during the creation of the environment,
  44683. * mainly texture creation errors.
  44684. */
  44685. onErrorObservable: Observable<{
  44686. message?: string;
  44687. exception?: any;
  44688. }>;
  44689. /**
  44690. * constructor
  44691. * @param options Defines the options we want to customize the helper
  44692. * @param scene The scene to add the material to
  44693. */
  44694. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44695. /**
  44696. * Updates the background according to the new options
  44697. * @param options
  44698. */
  44699. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44700. /**
  44701. * Sets the primary color of all the available elements.
  44702. * @param color the main color to affect to the ground and the background
  44703. */
  44704. setMainColor(color: Color3): void;
  44705. /**
  44706. * Setup the image processing according to the specified options.
  44707. */
  44708. private _setupImageProcessing;
  44709. /**
  44710. * Setup the environment texture according to the specified options.
  44711. */
  44712. private _setupEnvironmentTexture;
  44713. /**
  44714. * Setup the background according to the specified options.
  44715. */
  44716. private _setupBackground;
  44717. /**
  44718. * Get the scene sizes according to the setup.
  44719. */
  44720. private _getSceneSize;
  44721. /**
  44722. * Setup the ground according to the specified options.
  44723. */
  44724. private _setupGround;
  44725. /**
  44726. * Setup the ground material according to the specified options.
  44727. */
  44728. private _setupGroundMaterial;
  44729. /**
  44730. * Setup the ground diffuse texture according to the specified options.
  44731. */
  44732. private _setupGroundDiffuseTexture;
  44733. /**
  44734. * Setup the ground mirror texture according to the specified options.
  44735. */
  44736. private _setupGroundMirrorTexture;
  44737. /**
  44738. * Setup the ground to receive the mirror texture.
  44739. */
  44740. private _setupMirrorInGroundMaterial;
  44741. /**
  44742. * Setup the skybox according to the specified options.
  44743. */
  44744. private _setupSkybox;
  44745. /**
  44746. * Setup the skybox material according to the specified options.
  44747. */
  44748. private _setupSkyboxMaterial;
  44749. /**
  44750. * Setup the skybox reflection texture according to the specified options.
  44751. */
  44752. private _setupSkyboxReflectionTexture;
  44753. private _errorHandler;
  44754. /**
  44755. * Dispose all the elements created by the Helper.
  44756. */
  44757. dispose(): void;
  44758. }
  44759. }
  44760. declare module "babylonjs/Helpers/photoDome" {
  44761. import { Observable } from "babylonjs/Misc/observable";
  44762. import { Nullable } from "babylonjs/types";
  44763. import { Scene } from "babylonjs/scene";
  44764. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44765. import { Mesh } from "babylonjs/Meshes/mesh";
  44766. import { Texture } from "babylonjs/Materials/Textures/texture";
  44767. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44768. import "babylonjs/Meshes/Builders/sphereBuilder";
  44769. /**
  44770. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44771. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44772. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44773. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44774. */
  44775. export class PhotoDome extends TransformNode {
  44776. private _useDirectMapping;
  44777. /**
  44778. * The texture being displayed on the sphere
  44779. */
  44780. protected _photoTexture: Texture;
  44781. /**
  44782. * Gets or sets the texture being displayed on the sphere
  44783. */
  44784. photoTexture: Texture;
  44785. /**
  44786. * Observable raised when an error occured while loading the 360 image
  44787. */
  44788. onLoadErrorObservable: Observable<string>;
  44789. /**
  44790. * The skybox material
  44791. */
  44792. protected _material: BackgroundMaterial;
  44793. /**
  44794. * The surface used for the skybox
  44795. */
  44796. protected _mesh: Mesh;
  44797. /**
  44798. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44799. * Also see the options.resolution property.
  44800. */
  44801. fovMultiplier: number;
  44802. /**
  44803. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44804. * @param name Element's name, child elements will append suffixes for their own names.
  44805. * @param urlsOfPhoto defines the url of the photo to display
  44806. * @param options defines an object containing optional or exposed sub element properties
  44807. * @param onError defines a callback called when an error occured while loading the texture
  44808. */
  44809. constructor(name: string, urlOfPhoto: string, options: {
  44810. resolution?: number;
  44811. size?: number;
  44812. useDirectMapping?: boolean;
  44813. faceForward?: boolean;
  44814. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44815. /**
  44816. * Releases resources associated with this node.
  44817. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44818. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44819. */
  44820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44821. }
  44822. }
  44823. declare module "babylonjs/Misc/brdfTextureTools" {
  44824. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44825. import { Scene } from "babylonjs/scene";
  44826. /**
  44827. * Class used to host texture specific utilities
  44828. */
  44829. export class BRDFTextureTools {
  44830. /**
  44831. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44832. * @param texture the texture to expand.
  44833. */
  44834. private static _ExpandDefaultBRDFTexture;
  44835. /**
  44836. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44837. * @param scene defines the hosting scene
  44838. * @returns the environment BRDF texture
  44839. */
  44840. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44841. private static _environmentBRDFBase64Texture;
  44842. }
  44843. }
  44844. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44845. import { Nullable } from "babylonjs/types";
  44846. import { IAnimatable } from "babylonjs/Misc/tools";
  44847. import { Color3 } from "babylonjs/Maths/math";
  44848. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44849. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44850. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44851. import { Engine } from "babylonjs/Engines/engine";
  44852. import { Scene } from "babylonjs/scene";
  44853. /**
  44854. * @hidden
  44855. */
  44856. export interface IMaterialClearCoatDefines {
  44857. CLEARCOAT: boolean;
  44858. CLEARCOAT_DEFAULTIOR: boolean;
  44859. CLEARCOAT_TEXTURE: boolean;
  44860. CLEARCOAT_TEXTUREDIRECTUV: number;
  44861. CLEARCOAT_BUMP: boolean;
  44862. CLEARCOAT_BUMPDIRECTUV: number;
  44863. CLEARCOAT_TINT: boolean;
  44864. CLEARCOAT_TINT_TEXTURE: boolean;
  44865. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44866. /** @hidden */
  44867. _areTexturesDirty: boolean;
  44868. }
  44869. /**
  44870. * Define the code related to the clear coat parameters of the pbr material.
  44871. */
  44872. export class PBRClearCoatConfiguration {
  44873. /**
  44874. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44875. * The default fits with a polyurethane material.
  44876. */
  44877. private static readonly _DefaultIndiceOfRefraction;
  44878. private _isEnabled;
  44879. /**
  44880. * Defines if the clear coat is enabled in the material.
  44881. */
  44882. isEnabled: boolean;
  44883. /**
  44884. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44885. */
  44886. intensity: number;
  44887. /**
  44888. * Defines the clear coat layer roughness.
  44889. */
  44890. roughness: number;
  44891. private _indiceOfRefraction;
  44892. /**
  44893. * Defines the indice of refraction of the clear coat.
  44894. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44895. * The default fits with a polyurethane material.
  44896. * Changing the default value is more performance intensive.
  44897. */
  44898. indiceOfRefraction: number;
  44899. private _texture;
  44900. /**
  44901. * Stores the clear coat values in a texture.
  44902. */
  44903. texture: Nullable<BaseTexture>;
  44904. private _bumpTexture;
  44905. /**
  44906. * Define the clear coat specific bump texture.
  44907. */
  44908. bumpTexture: Nullable<BaseTexture>;
  44909. private _isTintEnabled;
  44910. /**
  44911. * Defines if the clear coat tint is enabled in the material.
  44912. */
  44913. isTintEnabled: boolean;
  44914. /**
  44915. * Defines if the clear coat tint is enabled in the material.
  44916. * This is only use if tint is enabled
  44917. */
  44918. tintColor: Color3;
  44919. /**
  44920. * Defines if the distance at which the tint color should be found in the
  44921. * clear coat media.
  44922. * This is only use if tint is enabled
  44923. */
  44924. tintColorAtDistance: number;
  44925. /**
  44926. * Defines the clear coat layer thickness.
  44927. * This is only use if tint is enabled
  44928. */
  44929. tintThickness: number;
  44930. private _tintTexture;
  44931. /**
  44932. * Stores the clear tint values in a texture.
  44933. * rgb is tint
  44934. * a is a thickness factor
  44935. */
  44936. tintTexture: Nullable<BaseTexture>;
  44937. /** @hidden */
  44938. private _internalMarkAllSubMeshesAsTexturesDirty;
  44939. /** @hidden */
  44940. _markAllSubMeshesAsTexturesDirty(): void;
  44941. /**
  44942. * Instantiate a new istance of clear coat configuration.
  44943. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44944. */
  44945. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44946. /**
  44947. * Specifies that the submesh is ready to be used.
  44948. * @param defines the list of "defines" to update.
  44949. * @param scene defines the scene the material belongs to.
  44950. * @param engine defines the engine the material belongs to.
  44951. * @param disableBumpMap defines wether the material disables bump or not.
  44952. * @returns - boolean indicating that the submesh is ready or not.
  44953. */
  44954. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44955. /**
  44956. * Checks to see if a texture is used in the material.
  44957. * @param defines the list of "defines" to update.
  44958. * @param scene defines the scene to the material belongs to.
  44959. */
  44960. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44961. /**
  44962. * Binds the material data.
  44963. * @param uniformBuffer defines the Uniform buffer to fill in.
  44964. * @param scene defines the scene the material belongs to.
  44965. * @param engine defines the engine the material belongs to.
  44966. * @param disableBumpMap defines wether the material disables bump or not.
  44967. * @param isFrozen defines wether the material is frozen or not.
  44968. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44969. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44970. */
  44971. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44972. /**
  44973. * Checks to see if a texture is used in the material.
  44974. * @param texture - Base texture to use.
  44975. * @returns - Boolean specifying if a texture is used in the material.
  44976. */
  44977. hasTexture(texture: BaseTexture): boolean;
  44978. /**
  44979. * Returns an array of the actively used textures.
  44980. * @param activeTextures Array of BaseTextures
  44981. */
  44982. getActiveTextures(activeTextures: BaseTexture[]): void;
  44983. /**
  44984. * Returns the animatable textures.
  44985. * @param animatables Array of animatable textures.
  44986. */
  44987. getAnimatables(animatables: IAnimatable[]): void;
  44988. /**
  44989. * Disposes the resources of the material.
  44990. * @param forceDisposeTextures - Forces the disposal of all textures.
  44991. */
  44992. dispose(forceDisposeTextures?: boolean): void;
  44993. /**
  44994. * Get the current class name of the texture useful for serialization or dynamic coding.
  44995. * @returns "PBRClearCoatConfiguration"
  44996. */
  44997. getClassName(): string;
  44998. /**
  44999. * Add fallbacks to the effect fallbacks list.
  45000. * @param defines defines the Base texture to use.
  45001. * @param fallbacks defines the current fallback list.
  45002. * @param currentRank defines the current fallback rank.
  45003. * @returns the new fallback rank.
  45004. */
  45005. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45006. /**
  45007. * Add the required uniforms to the current list.
  45008. * @param uniforms defines the current uniform list.
  45009. */
  45010. static AddUniforms(uniforms: string[]): void;
  45011. /**
  45012. * Add the required samplers to the current list.
  45013. * @param samplers defines the current sampler list.
  45014. */
  45015. static AddSamplers(samplers: string[]): void;
  45016. /**
  45017. * Add the required uniforms to the current buffer.
  45018. * @param uniformBuffer defines the current uniform buffer.
  45019. */
  45020. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45021. /**
  45022. * Makes a duplicate of the current configuration into another one.
  45023. * @param clearCoatConfiguration define the config where to copy the info
  45024. */
  45025. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45026. /**
  45027. * Serializes this clear coat configuration.
  45028. * @returns - An object with the serialized config.
  45029. */
  45030. serialize(): any;
  45031. /**
  45032. * Parses a Clear Coat Configuration from a serialized object.
  45033. * @param source - Serialized object.
  45034. */
  45035. parse(source: any): void;
  45036. }
  45037. }
  45038. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45039. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45040. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45042. import { Vector2 } from "babylonjs/Maths/math";
  45043. import { Scene } from "babylonjs/scene";
  45044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45045. import { IAnimatable } from "babylonjs/Misc/tools";
  45046. import { Nullable } from "babylonjs/types";
  45047. /**
  45048. * @hidden
  45049. */
  45050. export interface IMaterialAnisotropicDefines {
  45051. ANISOTROPIC: boolean;
  45052. ANISOTROPIC_TEXTURE: boolean;
  45053. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45054. MAINUV1: boolean;
  45055. _areTexturesDirty: boolean;
  45056. _needUVs: boolean;
  45057. }
  45058. /**
  45059. * Define the code related to the anisotropic parameters of the pbr material.
  45060. */
  45061. export class PBRAnisotropicConfiguration {
  45062. private _isEnabled;
  45063. /**
  45064. * Defines if the anisotropy is enabled in the material.
  45065. */
  45066. isEnabled: boolean;
  45067. /**
  45068. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45069. */
  45070. intensity: number;
  45071. /**
  45072. * Defines if the effect is along the tangents, bitangents or in between.
  45073. * By default, the effect is "strectching" the highlights along the tangents.
  45074. */
  45075. direction: Vector2;
  45076. private _texture;
  45077. /**
  45078. * Stores the anisotropy values in a texture.
  45079. * rg is direction (like normal from -1 to 1)
  45080. * b is a intensity
  45081. */
  45082. texture: Nullable<BaseTexture>;
  45083. /** @hidden */
  45084. private _internalMarkAllSubMeshesAsTexturesDirty;
  45085. /** @hidden */
  45086. _markAllSubMeshesAsTexturesDirty(): void;
  45087. /**
  45088. * Instantiate a new istance of anisotropy configuration.
  45089. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45090. */
  45091. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45092. /**
  45093. * Specifies that the submesh is ready to be used.
  45094. * @param defines the list of "defines" to update.
  45095. * @param scene defines the scene the material belongs to.
  45096. * @returns - boolean indicating that the submesh is ready or not.
  45097. */
  45098. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45099. /**
  45100. * Checks to see if a texture is used in the material.
  45101. * @param defines the list of "defines" to update.
  45102. * @param mesh the mesh we are preparing the defines for.
  45103. * @param scene defines the scene the material belongs to.
  45104. */
  45105. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45106. /**
  45107. * Binds the material data.
  45108. * @param uniformBuffer defines the Uniform buffer to fill in.
  45109. * @param scene defines the scene the material belongs to.
  45110. * @param isFrozen defines wether the material is frozen or not.
  45111. */
  45112. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45113. /**
  45114. * Checks to see if a texture is used in the material.
  45115. * @param texture - Base texture to use.
  45116. * @returns - Boolean specifying if a texture is used in the material.
  45117. */
  45118. hasTexture(texture: BaseTexture): boolean;
  45119. /**
  45120. * Returns an array of the actively used textures.
  45121. * @param activeTextures Array of BaseTextures
  45122. */
  45123. getActiveTextures(activeTextures: BaseTexture[]): void;
  45124. /**
  45125. * Returns the animatable textures.
  45126. * @param animatables Array of animatable textures.
  45127. */
  45128. getAnimatables(animatables: IAnimatable[]): void;
  45129. /**
  45130. * Disposes the resources of the material.
  45131. * @param forceDisposeTextures - Forces the disposal of all textures.
  45132. */
  45133. dispose(forceDisposeTextures?: boolean): void;
  45134. /**
  45135. * Get the current class name of the texture useful for serialization or dynamic coding.
  45136. * @returns "PBRAnisotropicConfiguration"
  45137. */
  45138. getClassName(): string;
  45139. /**
  45140. * Add fallbacks to the effect fallbacks list.
  45141. * @param defines defines the Base texture to use.
  45142. * @param fallbacks defines the current fallback list.
  45143. * @param currentRank defines the current fallback rank.
  45144. * @returns the new fallback rank.
  45145. */
  45146. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45147. /**
  45148. * Add the required uniforms to the current list.
  45149. * @param uniforms defines the current uniform list.
  45150. */
  45151. static AddUniforms(uniforms: string[]): void;
  45152. /**
  45153. * Add the required uniforms to the current buffer.
  45154. * @param uniformBuffer defines the current uniform buffer.
  45155. */
  45156. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45157. /**
  45158. * Add the required samplers to the current list.
  45159. * @param samplers defines the current sampler list.
  45160. */
  45161. static AddSamplers(samplers: string[]): void;
  45162. /**
  45163. * Makes a duplicate of the current configuration into another one.
  45164. * @param anisotropicConfiguration define the config where to copy the info
  45165. */
  45166. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45167. /**
  45168. * Serializes this anisotropy configuration.
  45169. * @returns - An object with the serialized config.
  45170. */
  45171. serialize(): any;
  45172. /**
  45173. * Parses a anisotropy Configuration from a serialized object.
  45174. * @param source - Serialized object.
  45175. */
  45176. parse(source: any): void;
  45177. }
  45178. }
  45179. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45180. /**
  45181. * @hidden
  45182. */
  45183. export interface IMaterialBRDFDefines {
  45184. BRDF_V_HEIGHT_CORRELATED: boolean;
  45185. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45186. /** @hidden */
  45187. _areMiscDirty: boolean;
  45188. }
  45189. /**
  45190. * Define the code related to the BRDF parameters of the pbr material.
  45191. */
  45192. export class PBRBRDFConfiguration {
  45193. /**
  45194. * Default value used for the energy conservation.
  45195. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45196. */
  45197. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45198. /**
  45199. * Default value used for the Smith Visibility Height Correlated mode.
  45200. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45201. */
  45202. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45203. private _useEnergyConservation;
  45204. /**
  45205. * Defines if the material uses energy conservation.
  45206. */
  45207. useEnergyConservation: boolean;
  45208. private _useSmithVisibilityHeightCorrelated;
  45209. /**
  45210. * LEGACY Mode set to false
  45211. * Defines if the material uses height smith correlated visibility term.
  45212. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45213. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45214. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45215. * Not relying on height correlated will also disable energy conservation.
  45216. */
  45217. useSmithVisibilityHeightCorrelated: boolean;
  45218. /** @hidden */
  45219. private _internalMarkAllSubMeshesAsMiscDirty;
  45220. /** @hidden */
  45221. _markAllSubMeshesAsMiscDirty(): void;
  45222. /**
  45223. * Instantiate a new istance of clear coat configuration.
  45224. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45225. */
  45226. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45227. /**
  45228. * Checks to see if a texture is used in the material.
  45229. * @param defines the list of "defines" to update.
  45230. */
  45231. prepareDefines(defines: IMaterialBRDFDefines): void;
  45232. /**
  45233. * Get the current class name of the texture useful for serialization or dynamic coding.
  45234. * @returns "PBRClearCoatConfiguration"
  45235. */
  45236. getClassName(): string;
  45237. /**
  45238. * Makes a duplicate of the current configuration into another one.
  45239. * @param brdfConfiguration define the config where to copy the info
  45240. */
  45241. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45242. /**
  45243. * Serializes this BRDF configuration.
  45244. * @returns - An object with the serialized config.
  45245. */
  45246. serialize(): any;
  45247. /**
  45248. * Parses a BRDF Configuration from a serialized object.
  45249. * @param source - Serialized object.
  45250. */
  45251. parse(source: any): void;
  45252. }
  45253. }
  45254. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45255. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45256. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45257. import { Color3 } from "babylonjs/Maths/math";
  45258. import { Scene } from "babylonjs/scene";
  45259. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45260. import { IAnimatable } from "babylonjs/Misc/tools";
  45261. import { Nullable } from "babylonjs/types";
  45262. /**
  45263. * @hidden
  45264. */
  45265. export interface IMaterialSheenDefines {
  45266. SHEEN: boolean;
  45267. SHEEN_TEXTURE: boolean;
  45268. SHEEN_TEXTUREDIRECTUV: number;
  45269. SHEEN_LINKWITHALBEDO: boolean;
  45270. /** @hidden */
  45271. _areTexturesDirty: boolean;
  45272. }
  45273. /**
  45274. * Define the code related to the Sheen parameters of the pbr material.
  45275. */
  45276. export class PBRSheenConfiguration {
  45277. private _isEnabled;
  45278. /**
  45279. * Defines if the material uses sheen.
  45280. */
  45281. isEnabled: boolean;
  45282. private _linkSheenWithAlbedo;
  45283. /**
  45284. * Defines if the sheen is linked to the sheen color.
  45285. */
  45286. linkSheenWithAlbedo: boolean;
  45287. /**
  45288. * Defines the sheen intensity.
  45289. */
  45290. intensity: number;
  45291. /**
  45292. * Defines the sheen color.
  45293. */
  45294. color: Color3;
  45295. private _texture;
  45296. /**
  45297. * Stores the sheen tint values in a texture.
  45298. * rgb is tint
  45299. * a is a intensity
  45300. */
  45301. texture: Nullable<BaseTexture>;
  45302. /** @hidden */
  45303. private _internalMarkAllSubMeshesAsTexturesDirty;
  45304. /** @hidden */
  45305. _markAllSubMeshesAsTexturesDirty(): void;
  45306. /**
  45307. * Instantiate a new istance of clear coat configuration.
  45308. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45309. */
  45310. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45311. /**
  45312. * Specifies that the submesh is ready to be used.
  45313. * @param defines the list of "defines" to update.
  45314. * @param scene defines the scene the material belongs to.
  45315. * @returns - boolean indicating that the submesh is ready or not.
  45316. */
  45317. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45318. /**
  45319. * Checks to see if a texture is used in the material.
  45320. * @param defines the list of "defines" to update.
  45321. * @param scene defines the scene the material belongs to.
  45322. */
  45323. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45324. /**
  45325. * Binds the material data.
  45326. * @param uniformBuffer defines the Uniform buffer to fill in.
  45327. * @param scene defines the scene the material belongs to.
  45328. * @param isFrozen defines wether the material is frozen or not.
  45329. */
  45330. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45331. /**
  45332. * Checks to see if a texture is used in the material.
  45333. * @param texture - Base texture to use.
  45334. * @returns - Boolean specifying if a texture is used in the material.
  45335. */
  45336. hasTexture(texture: BaseTexture): boolean;
  45337. /**
  45338. * Returns an array of the actively used textures.
  45339. * @param activeTextures Array of BaseTextures
  45340. */
  45341. getActiveTextures(activeTextures: BaseTexture[]): void;
  45342. /**
  45343. * Returns the animatable textures.
  45344. * @param animatables Array of animatable textures.
  45345. */
  45346. getAnimatables(animatables: IAnimatable[]): void;
  45347. /**
  45348. * Disposes the resources of the material.
  45349. * @param forceDisposeTextures - Forces the disposal of all textures.
  45350. */
  45351. dispose(forceDisposeTextures?: boolean): void;
  45352. /**
  45353. * Get the current class name of the texture useful for serialization or dynamic coding.
  45354. * @returns "PBRSheenConfiguration"
  45355. */
  45356. getClassName(): string;
  45357. /**
  45358. * Add fallbacks to the effect fallbacks list.
  45359. * @param defines defines the Base texture to use.
  45360. * @param fallbacks defines the current fallback list.
  45361. * @param currentRank defines the current fallback rank.
  45362. * @returns the new fallback rank.
  45363. */
  45364. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45365. /**
  45366. * Add the required uniforms to the current list.
  45367. * @param uniforms defines the current uniform list.
  45368. */
  45369. static AddUniforms(uniforms: string[]): void;
  45370. /**
  45371. * Add the required uniforms to the current buffer.
  45372. * @param uniformBuffer defines the current uniform buffer.
  45373. */
  45374. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45375. /**
  45376. * Add the required samplers to the current list.
  45377. * @param samplers defines the current sampler list.
  45378. */
  45379. static AddSamplers(samplers: string[]): void;
  45380. /**
  45381. * Makes a duplicate of the current configuration into another one.
  45382. * @param sheenConfiguration define the config where to copy the info
  45383. */
  45384. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45385. /**
  45386. * Serializes this BRDF configuration.
  45387. * @returns - An object with the serialized config.
  45388. */
  45389. serialize(): any;
  45390. /**
  45391. * Parses a Sheen Configuration from a serialized object.
  45392. * @param source - Serialized object.
  45393. */
  45394. parse(source: any): void;
  45395. }
  45396. }
  45397. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  45398. /** @hidden */
  45399. export var pbrFragmentDeclaration: {
  45400. name: string;
  45401. shader: string;
  45402. };
  45403. }
  45404. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  45405. /** @hidden */
  45406. export var pbrUboDeclaration: {
  45407. name: string;
  45408. shader: string;
  45409. };
  45410. }
  45411. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  45412. /** @hidden */
  45413. export var pbrFragmentExtraDeclaration: {
  45414. name: string;
  45415. shader: string;
  45416. };
  45417. }
  45418. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  45419. /** @hidden */
  45420. export var pbrFragmentSamplersDeclaration: {
  45421. name: string;
  45422. shader: string;
  45423. };
  45424. }
  45425. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  45426. /** @hidden */
  45427. export var pbrHelperFunctions: {
  45428. name: string;
  45429. shader: string;
  45430. };
  45431. }
  45432. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  45433. /** @hidden */
  45434. export var harmonicsFunctions: {
  45435. name: string;
  45436. shader: string;
  45437. };
  45438. }
  45439. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  45440. /** @hidden */
  45441. export var pbrDirectLightingSetupFunctions: {
  45442. name: string;
  45443. shader: string;
  45444. };
  45445. }
  45446. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  45447. /** @hidden */
  45448. export var pbrDirectLightingFalloffFunctions: {
  45449. name: string;
  45450. shader: string;
  45451. };
  45452. }
  45453. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  45454. /** @hidden */
  45455. export var pbrBRDFFunctions: {
  45456. name: string;
  45457. shader: string;
  45458. };
  45459. }
  45460. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  45461. /** @hidden */
  45462. export var pbrDirectLightingFunctions: {
  45463. name: string;
  45464. shader: string;
  45465. };
  45466. }
  45467. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  45468. /** @hidden */
  45469. export var pbrIBLFunctions: {
  45470. name: string;
  45471. shader: string;
  45472. };
  45473. }
  45474. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  45475. /** @hidden */
  45476. export var pbrDebug: {
  45477. name: string;
  45478. shader: string;
  45479. };
  45480. }
  45481. declare module "babylonjs/Shaders/pbr.fragment" {
  45482. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  45483. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45484. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  45485. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45486. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45487. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  45488. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45489. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45490. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45491. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45492. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45493. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  45494. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45495. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45496. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45497. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  45498. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  45499. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  45500. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  45501. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  45502. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  45503. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45504. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45505. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45506. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45507. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45508. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45509. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45510. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45511. /** @hidden */
  45512. export var pbrPixelShader: {
  45513. name: string;
  45514. shader: string;
  45515. };
  45516. }
  45517. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45518. /** @hidden */
  45519. export var pbrVertexDeclaration: {
  45520. name: string;
  45521. shader: string;
  45522. };
  45523. }
  45524. declare module "babylonjs/Shaders/pbr.vertex" {
  45525. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45526. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45527. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45528. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45529. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45530. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45531. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45532. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45533. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45534. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45535. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45536. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45537. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45538. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45539. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45540. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45541. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45542. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45543. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45544. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45545. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45546. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45547. /** @hidden */
  45548. export var pbrVertexShader: {
  45549. name: string;
  45550. shader: string;
  45551. };
  45552. }
  45553. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45554. import { IAnimatable } from "babylonjs/Misc/tools";
  45555. import { Nullable } from "babylonjs/types";
  45556. import { Scene } from "babylonjs/scene";
  45557. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45558. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45560. import { Mesh } from "babylonjs/Meshes/mesh";
  45561. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45562. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45563. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45564. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45565. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45566. import { Material } from "babylonjs/Materials/material";
  45567. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45568. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45569. import "babylonjs/Shaders/pbr.fragment";
  45570. import "babylonjs/Shaders/pbr.vertex";
  45571. /**
  45572. * The Physically based material base class of BJS.
  45573. *
  45574. * This offers the main features of a standard PBR material.
  45575. * For more information, please refer to the documentation :
  45576. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45577. */
  45578. export abstract class PBRBaseMaterial extends PushMaterial {
  45579. /**
  45580. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45581. */
  45582. static readonly PBRMATERIAL_OPAQUE: number;
  45583. /**
  45584. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45585. */
  45586. static readonly PBRMATERIAL_ALPHATEST: number;
  45587. /**
  45588. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45589. */
  45590. static readonly PBRMATERIAL_ALPHABLEND: number;
  45591. /**
  45592. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45593. * They are also discarded below the alpha cutoff threshold to improve performances.
  45594. */
  45595. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45596. /**
  45597. * Defines the default value of how much AO map is occluding the analytical lights
  45598. * (point spot...).
  45599. */
  45600. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45601. /**
  45602. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45603. */
  45604. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45605. /**
  45606. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45607. * to enhance interoperability with other engines.
  45608. */
  45609. static readonly LIGHTFALLOFF_GLTF: number;
  45610. /**
  45611. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45612. * to enhance interoperability with other materials.
  45613. */
  45614. static readonly LIGHTFALLOFF_STANDARD: number;
  45615. /**
  45616. * Intensity of the direct lights e.g. the four lights available in your scene.
  45617. * This impacts both the direct diffuse and specular highlights.
  45618. */
  45619. protected _directIntensity: number;
  45620. /**
  45621. * Intensity of the emissive part of the material.
  45622. * This helps controlling the emissive effect without modifying the emissive color.
  45623. */
  45624. protected _emissiveIntensity: number;
  45625. /**
  45626. * Intensity of the environment e.g. how much the environment will light the object
  45627. * either through harmonics for rough material or through the refelction for shiny ones.
  45628. */
  45629. protected _environmentIntensity: number;
  45630. /**
  45631. * This is a special control allowing the reduction of the specular highlights coming from the
  45632. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45633. */
  45634. protected _specularIntensity: number;
  45635. /**
  45636. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45637. */
  45638. private _lightingInfos;
  45639. /**
  45640. * Debug Control allowing disabling the bump map on this material.
  45641. */
  45642. protected _disableBumpMap: boolean;
  45643. /**
  45644. * AKA Diffuse Texture in standard nomenclature.
  45645. */
  45646. protected _albedoTexture: BaseTexture;
  45647. /**
  45648. * AKA Occlusion Texture in other nomenclature.
  45649. */
  45650. protected _ambientTexture: BaseTexture;
  45651. /**
  45652. * AKA Occlusion Texture Intensity in other nomenclature.
  45653. */
  45654. protected _ambientTextureStrength: number;
  45655. /**
  45656. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45657. * 1 means it completely occludes it
  45658. * 0 mean it has no impact
  45659. */
  45660. protected _ambientTextureImpactOnAnalyticalLights: number;
  45661. /**
  45662. * Stores the alpha values in a texture.
  45663. */
  45664. protected _opacityTexture: BaseTexture;
  45665. /**
  45666. * Stores the reflection values in a texture.
  45667. */
  45668. protected _reflectionTexture: BaseTexture;
  45669. /**
  45670. * Stores the refraction values in a texture.
  45671. */
  45672. protected _refractionTexture: BaseTexture;
  45673. /**
  45674. * Stores the emissive values in a texture.
  45675. */
  45676. protected _emissiveTexture: BaseTexture;
  45677. /**
  45678. * AKA Specular texture in other nomenclature.
  45679. */
  45680. protected _reflectivityTexture: BaseTexture;
  45681. /**
  45682. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45683. */
  45684. protected _metallicTexture: BaseTexture;
  45685. /**
  45686. * Specifies the metallic scalar of the metallic/roughness workflow.
  45687. * Can also be used to scale the metalness values of the metallic texture.
  45688. */
  45689. protected _metallic: Nullable<number>;
  45690. /**
  45691. * Specifies the roughness scalar of the metallic/roughness workflow.
  45692. * Can also be used to scale the roughness values of the metallic texture.
  45693. */
  45694. protected _roughness: Nullable<number>;
  45695. /**
  45696. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45697. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45698. */
  45699. protected _microSurfaceTexture: BaseTexture;
  45700. /**
  45701. * Stores surface normal data used to displace a mesh in a texture.
  45702. */
  45703. protected _bumpTexture: BaseTexture;
  45704. /**
  45705. * Stores the pre-calculated light information of a mesh in a texture.
  45706. */
  45707. protected _lightmapTexture: BaseTexture;
  45708. /**
  45709. * The color of a material in ambient lighting.
  45710. */
  45711. protected _ambientColor: Color3;
  45712. /**
  45713. * AKA Diffuse Color in other nomenclature.
  45714. */
  45715. protected _albedoColor: Color3;
  45716. /**
  45717. * AKA Specular Color in other nomenclature.
  45718. */
  45719. protected _reflectivityColor: Color3;
  45720. /**
  45721. * The color applied when light is reflected from a material.
  45722. */
  45723. protected _reflectionColor: Color3;
  45724. /**
  45725. * The color applied when light is emitted from a material.
  45726. */
  45727. protected _emissiveColor: Color3;
  45728. /**
  45729. * AKA Glossiness in other nomenclature.
  45730. */
  45731. protected _microSurface: number;
  45732. /**
  45733. * source material index of refraction (IOR)' / 'destination material IOR.
  45734. */
  45735. protected _indexOfRefraction: number;
  45736. /**
  45737. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45738. */
  45739. protected _invertRefractionY: boolean;
  45740. /**
  45741. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45742. * Materials half opaque for instance using refraction could benefit from this control.
  45743. */
  45744. protected _linkRefractionWithTransparency: boolean;
  45745. /**
  45746. * Specifies that the material will use the light map as a show map.
  45747. */
  45748. protected _useLightmapAsShadowmap: boolean;
  45749. /**
  45750. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45751. * makes the reflect vector face the model (under horizon).
  45752. */
  45753. protected _useHorizonOcclusion: boolean;
  45754. /**
  45755. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45756. * too much the area relying on ambient texture to define their ambient occlusion.
  45757. */
  45758. protected _useRadianceOcclusion: boolean;
  45759. /**
  45760. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45761. */
  45762. protected _useAlphaFromAlbedoTexture: boolean;
  45763. /**
  45764. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45765. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45766. */
  45767. protected _useSpecularOverAlpha: boolean;
  45768. /**
  45769. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45770. */
  45771. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45772. /**
  45773. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45774. */
  45775. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45776. /**
  45777. * Specifies if the metallic texture contains the roughness information in its green channel.
  45778. */
  45779. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45780. /**
  45781. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45782. */
  45783. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45784. /**
  45785. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45786. */
  45787. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45788. /**
  45789. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45790. */
  45791. protected _useAmbientInGrayScale: boolean;
  45792. /**
  45793. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45794. * The material will try to infer what glossiness each pixel should be.
  45795. */
  45796. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45797. /**
  45798. * Defines the falloff type used in this material.
  45799. * It by default is Physical.
  45800. */
  45801. protected _lightFalloff: number;
  45802. /**
  45803. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45804. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45805. */
  45806. protected _useRadianceOverAlpha: boolean;
  45807. /**
  45808. * Allows using an object space normal map (instead of tangent space).
  45809. */
  45810. protected _useObjectSpaceNormalMap: boolean;
  45811. /**
  45812. * Allows using the bump map in parallax mode.
  45813. */
  45814. protected _useParallax: boolean;
  45815. /**
  45816. * Allows using the bump map in parallax occlusion mode.
  45817. */
  45818. protected _useParallaxOcclusion: boolean;
  45819. /**
  45820. * Controls the scale bias of the parallax mode.
  45821. */
  45822. protected _parallaxScaleBias: number;
  45823. /**
  45824. * If sets to true, disables all the lights affecting the material.
  45825. */
  45826. protected _disableLighting: boolean;
  45827. /**
  45828. * Number of Simultaneous lights allowed on the material.
  45829. */
  45830. protected _maxSimultaneousLights: number;
  45831. /**
  45832. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45833. */
  45834. protected _invertNormalMapX: boolean;
  45835. /**
  45836. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45837. */
  45838. protected _invertNormalMapY: boolean;
  45839. /**
  45840. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45841. */
  45842. protected _twoSidedLighting: boolean;
  45843. /**
  45844. * Defines the alpha limits in alpha test mode.
  45845. */
  45846. protected _alphaCutOff: number;
  45847. /**
  45848. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45849. */
  45850. protected _forceAlphaTest: boolean;
  45851. /**
  45852. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45853. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45854. */
  45855. protected _useAlphaFresnel: boolean;
  45856. /**
  45857. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45858. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45859. */
  45860. protected _useLinearAlphaFresnel: boolean;
  45861. /**
  45862. * The transparency mode of the material.
  45863. */
  45864. protected _transparencyMode: Nullable<number>;
  45865. /**
  45866. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45867. * from cos thetav and roughness:
  45868. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45869. */
  45870. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45871. /**
  45872. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45873. */
  45874. protected _forceIrradianceInFragment: boolean;
  45875. /**
  45876. * Force normal to face away from face.
  45877. */
  45878. protected _forceNormalForward: boolean;
  45879. /**
  45880. * Enables specular anti aliasing in the PBR shader.
  45881. * It will both interacts on the Geometry for analytical and IBL lighting.
  45882. * It also prefilter the roughness map based on the bump values.
  45883. */
  45884. protected _enableSpecularAntiAliasing: boolean;
  45885. /**
  45886. * Default configuration related to image processing available in the PBR Material.
  45887. */
  45888. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45889. /**
  45890. * Keep track of the image processing observer to allow dispose and replace.
  45891. */
  45892. private _imageProcessingObserver;
  45893. /**
  45894. * Attaches a new image processing configuration to the PBR Material.
  45895. * @param configuration
  45896. */
  45897. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45898. /**
  45899. * Stores the available render targets.
  45900. */
  45901. private _renderTargets;
  45902. /**
  45903. * Sets the global ambient color for the material used in lighting calculations.
  45904. */
  45905. private _globalAmbientColor;
  45906. /**
  45907. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45908. */
  45909. private _useLogarithmicDepth;
  45910. /**
  45911. * If set to true, no lighting calculations will be applied.
  45912. */
  45913. private _unlit;
  45914. private _debugMode;
  45915. /**
  45916. * @hidden
  45917. * This is reserved for the inspector.
  45918. * Defines the material debug mode.
  45919. * It helps seeing only some components of the material while troubleshooting.
  45920. */
  45921. debugMode: number;
  45922. /**
  45923. * @hidden
  45924. * This is reserved for the inspector.
  45925. * Specify from where on screen the debug mode should start.
  45926. * The value goes from -1 (full screen) to 1 (not visible)
  45927. * It helps with side by side comparison against the final render
  45928. * This defaults to -1
  45929. */
  45930. private debugLimit;
  45931. /**
  45932. * @hidden
  45933. * This is reserved for the inspector.
  45934. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45935. * You can use the factor to better multiply the final value.
  45936. */
  45937. private debugFactor;
  45938. /**
  45939. * Defines the clear coat layer parameters for the material.
  45940. */
  45941. readonly clearCoat: PBRClearCoatConfiguration;
  45942. /**
  45943. * Defines the anisotropic parameters for the material.
  45944. */
  45945. readonly anisotropy: PBRAnisotropicConfiguration;
  45946. /**
  45947. * Defines the BRDF parameters for the material.
  45948. */
  45949. readonly brdf: PBRBRDFConfiguration;
  45950. /**
  45951. * Defines the Sheen parameters for the material.
  45952. */
  45953. readonly sheen: PBRSheenConfiguration;
  45954. /**
  45955. * Instantiates a new PBRMaterial instance.
  45956. *
  45957. * @param name The material name
  45958. * @param scene The scene the material will be use in.
  45959. */
  45960. constructor(name: string, scene: Scene);
  45961. /**
  45962. * Gets a boolean indicating that current material needs to register RTT
  45963. */
  45964. readonly hasRenderTargetTextures: boolean;
  45965. /**
  45966. * Gets the name of the material class.
  45967. */
  45968. getClassName(): string;
  45969. /**
  45970. * Gets the name of the material shader.
  45971. * @returns - string that specifies the shader program of the material.
  45972. */
  45973. getShaderName(): string;
  45974. /**
  45975. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45976. */
  45977. /**
  45978. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45979. */
  45980. useLogarithmicDepth: boolean;
  45981. /**
  45982. * Gets the current transparency mode.
  45983. */
  45984. /**
  45985. * Sets the transparency mode of the material.
  45986. *
  45987. * | Value | Type | Description |
  45988. * | ----- | ----------------------------------- | ----------- |
  45989. * | 0 | OPAQUE | |
  45990. * | 1 | ALPHATEST | |
  45991. * | 2 | ALPHABLEND | |
  45992. * | 3 | ALPHATESTANDBLEND | |
  45993. *
  45994. */
  45995. transparencyMode: Nullable<number>;
  45996. /**
  45997. * Returns true if alpha blending should be disabled.
  45998. */
  45999. private readonly _disableAlphaBlending;
  46000. /**
  46001. * Specifies whether or not this material should be rendered in alpha blend mode.
  46002. */
  46003. needAlphaBlending(): boolean;
  46004. /**
  46005. * Specifies if the mesh will require alpha blending.
  46006. * @param mesh - BJS mesh.
  46007. */
  46008. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46009. /**
  46010. * Specifies whether or not this material should be rendered in alpha test mode.
  46011. */
  46012. needAlphaTesting(): boolean;
  46013. /**
  46014. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46015. */
  46016. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46017. /**
  46018. * Gets the texture used for the alpha test.
  46019. */
  46020. getAlphaTestTexture(): BaseTexture;
  46021. /**
  46022. * Specifies that the submesh is ready to be used.
  46023. * @param mesh - BJS mesh.
  46024. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46025. * @param useInstances - Specifies that instances should be used.
  46026. * @returns - boolean indicating that the submesh is ready or not.
  46027. */
  46028. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46029. /**
  46030. * Specifies if the material uses metallic roughness workflow.
  46031. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46032. */
  46033. isMetallicWorkflow(): boolean;
  46034. private _prepareEffect;
  46035. private _prepareDefines;
  46036. /**
  46037. * Force shader compilation
  46038. */
  46039. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46040. clipPlane: boolean;
  46041. }>): void;
  46042. /**
  46043. * Initializes the uniform buffer layout for the shader.
  46044. */
  46045. buildUniformLayout(): void;
  46046. /**
  46047. * Unbinds the textures.
  46048. */
  46049. unbind(): void;
  46050. /**
  46051. * Binds the submesh data.
  46052. * @param world - The world matrix.
  46053. * @param mesh - The BJS mesh.
  46054. * @param subMesh - A submesh of the BJS mesh.
  46055. */
  46056. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46057. /**
  46058. * Returns the animatable textures.
  46059. * @returns - Array of animatable textures.
  46060. */
  46061. getAnimatables(): IAnimatable[];
  46062. /**
  46063. * Returns the texture used for reflections.
  46064. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46065. */
  46066. private _getReflectionTexture;
  46067. /**
  46068. * Returns the texture used for refraction or null if none is used.
  46069. * @returns - Refection texture if present. If no refraction texture and refraction
  46070. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46071. */
  46072. private _getRefractionTexture;
  46073. /**
  46074. * Returns an array of the actively used textures.
  46075. * @returns - Array of BaseTextures
  46076. */
  46077. getActiveTextures(): BaseTexture[];
  46078. /**
  46079. * Checks to see if a texture is used in the material.
  46080. * @param texture - Base texture to use.
  46081. * @returns - Boolean specifying if a texture is used in the material.
  46082. */
  46083. hasTexture(texture: BaseTexture): boolean;
  46084. /**
  46085. * Disposes the resources of the material.
  46086. * @param forceDisposeEffect - Forces the disposal of effects.
  46087. * @param forceDisposeTextures - Forces the disposal of all textures.
  46088. */
  46089. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46090. }
  46091. }
  46092. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  46093. import { Nullable } from "babylonjs/types";
  46094. import { Scene } from "babylonjs/scene";
  46095. import { Color3 } from "babylonjs/Maths/math";
  46096. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46097. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46099. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  46100. /**
  46101. * The Physically based material of BJS.
  46102. *
  46103. * This offers the main features of a standard PBR material.
  46104. * For more information, please refer to the documentation :
  46105. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46106. */
  46107. export class PBRMaterial extends PBRBaseMaterial {
  46108. /**
  46109. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46110. */
  46111. static readonly PBRMATERIAL_OPAQUE: number;
  46112. /**
  46113. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46114. */
  46115. static readonly PBRMATERIAL_ALPHATEST: number;
  46116. /**
  46117. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46118. */
  46119. static readonly PBRMATERIAL_ALPHABLEND: number;
  46120. /**
  46121. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46122. * They are also discarded below the alpha cutoff threshold to improve performances.
  46123. */
  46124. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46125. /**
  46126. * Defines the default value of how much AO map is occluding the analytical lights
  46127. * (point spot...).
  46128. */
  46129. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46130. /**
  46131. * Intensity of the direct lights e.g. the four lights available in your scene.
  46132. * This impacts both the direct diffuse and specular highlights.
  46133. */
  46134. directIntensity: number;
  46135. /**
  46136. * Intensity of the emissive part of the material.
  46137. * This helps controlling the emissive effect without modifying the emissive color.
  46138. */
  46139. emissiveIntensity: number;
  46140. /**
  46141. * Intensity of the environment e.g. how much the environment will light the object
  46142. * either through harmonics for rough material or through the refelction for shiny ones.
  46143. */
  46144. environmentIntensity: number;
  46145. /**
  46146. * This is a special control allowing the reduction of the specular highlights coming from the
  46147. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46148. */
  46149. specularIntensity: number;
  46150. /**
  46151. * Debug Control allowing disabling the bump map on this material.
  46152. */
  46153. disableBumpMap: boolean;
  46154. /**
  46155. * AKA Diffuse Texture in standard nomenclature.
  46156. */
  46157. albedoTexture: BaseTexture;
  46158. /**
  46159. * AKA Occlusion Texture in other nomenclature.
  46160. */
  46161. ambientTexture: BaseTexture;
  46162. /**
  46163. * AKA Occlusion Texture Intensity in other nomenclature.
  46164. */
  46165. ambientTextureStrength: number;
  46166. /**
  46167. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46168. * 1 means it completely occludes it
  46169. * 0 mean it has no impact
  46170. */
  46171. ambientTextureImpactOnAnalyticalLights: number;
  46172. /**
  46173. * Stores the alpha values in a texture.
  46174. */
  46175. opacityTexture: BaseTexture;
  46176. /**
  46177. * Stores the reflection values in a texture.
  46178. */
  46179. reflectionTexture: Nullable<BaseTexture>;
  46180. /**
  46181. * Stores the emissive values in a texture.
  46182. */
  46183. emissiveTexture: BaseTexture;
  46184. /**
  46185. * AKA Specular texture in other nomenclature.
  46186. */
  46187. reflectivityTexture: BaseTexture;
  46188. /**
  46189. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46190. */
  46191. metallicTexture: BaseTexture;
  46192. /**
  46193. * Specifies the metallic scalar of the metallic/roughness workflow.
  46194. * Can also be used to scale the metalness values of the metallic texture.
  46195. */
  46196. metallic: Nullable<number>;
  46197. /**
  46198. * Specifies the roughness scalar of the metallic/roughness workflow.
  46199. * Can also be used to scale the roughness values of the metallic texture.
  46200. */
  46201. roughness: Nullable<number>;
  46202. /**
  46203. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46204. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46205. */
  46206. microSurfaceTexture: BaseTexture;
  46207. /**
  46208. * Stores surface normal data used to displace a mesh in a texture.
  46209. */
  46210. bumpTexture: BaseTexture;
  46211. /**
  46212. * Stores the pre-calculated light information of a mesh in a texture.
  46213. */
  46214. lightmapTexture: BaseTexture;
  46215. /**
  46216. * Stores the refracted light information in a texture.
  46217. */
  46218. refractionTexture: BaseTexture;
  46219. /**
  46220. * The color of a material in ambient lighting.
  46221. */
  46222. ambientColor: Color3;
  46223. /**
  46224. * AKA Diffuse Color in other nomenclature.
  46225. */
  46226. albedoColor: Color3;
  46227. /**
  46228. * AKA Specular Color in other nomenclature.
  46229. */
  46230. reflectivityColor: Color3;
  46231. /**
  46232. * The color reflected from the material.
  46233. */
  46234. reflectionColor: Color3;
  46235. /**
  46236. * The color emitted from the material.
  46237. */
  46238. emissiveColor: Color3;
  46239. /**
  46240. * AKA Glossiness in other nomenclature.
  46241. */
  46242. microSurface: number;
  46243. /**
  46244. * source material index of refraction (IOR)' / 'destination material IOR.
  46245. */
  46246. indexOfRefraction: number;
  46247. /**
  46248. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46249. */
  46250. invertRefractionY: boolean;
  46251. /**
  46252. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46253. * Materials half opaque for instance using refraction could benefit from this control.
  46254. */
  46255. linkRefractionWithTransparency: boolean;
  46256. /**
  46257. * If true, the light map contains occlusion information instead of lighting info.
  46258. */
  46259. useLightmapAsShadowmap: boolean;
  46260. /**
  46261. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46262. */
  46263. useAlphaFromAlbedoTexture: boolean;
  46264. /**
  46265. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46266. */
  46267. forceAlphaTest: boolean;
  46268. /**
  46269. * Defines the alpha limits in alpha test mode.
  46270. */
  46271. alphaCutOff: number;
  46272. /**
  46273. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46274. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46275. */
  46276. useSpecularOverAlpha: boolean;
  46277. /**
  46278. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46279. */
  46280. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46281. /**
  46282. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46283. */
  46284. useRoughnessFromMetallicTextureAlpha: boolean;
  46285. /**
  46286. * Specifies if the metallic texture contains the roughness information in its green channel.
  46287. */
  46288. useRoughnessFromMetallicTextureGreen: boolean;
  46289. /**
  46290. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46291. */
  46292. useMetallnessFromMetallicTextureBlue: boolean;
  46293. /**
  46294. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46295. */
  46296. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46297. /**
  46298. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46299. */
  46300. useAmbientInGrayScale: boolean;
  46301. /**
  46302. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46303. * The material will try to infer what glossiness each pixel should be.
  46304. */
  46305. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46306. /**
  46307. * BJS is using an harcoded light falloff based on a manually sets up range.
  46308. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46309. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46310. */
  46311. /**
  46312. * BJS is using an harcoded light falloff based on a manually sets up range.
  46313. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46314. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46315. */
  46316. usePhysicalLightFalloff: boolean;
  46317. /**
  46318. * In order to support the falloff compatibility with gltf, a special mode has been added
  46319. * to reproduce the gltf light falloff.
  46320. */
  46321. /**
  46322. * In order to support the falloff compatibility with gltf, a special mode has been added
  46323. * to reproduce the gltf light falloff.
  46324. */
  46325. useGLTFLightFalloff: boolean;
  46326. /**
  46327. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46328. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46329. */
  46330. useRadianceOverAlpha: boolean;
  46331. /**
  46332. * Allows using an object space normal map (instead of tangent space).
  46333. */
  46334. useObjectSpaceNormalMap: boolean;
  46335. /**
  46336. * Allows using the bump map in parallax mode.
  46337. */
  46338. useParallax: boolean;
  46339. /**
  46340. * Allows using the bump map in parallax occlusion mode.
  46341. */
  46342. useParallaxOcclusion: boolean;
  46343. /**
  46344. * Controls the scale bias of the parallax mode.
  46345. */
  46346. parallaxScaleBias: number;
  46347. /**
  46348. * If sets to true, disables all the lights affecting the material.
  46349. */
  46350. disableLighting: boolean;
  46351. /**
  46352. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46353. */
  46354. forceIrradianceInFragment: boolean;
  46355. /**
  46356. * Number of Simultaneous lights allowed on the material.
  46357. */
  46358. maxSimultaneousLights: number;
  46359. /**
  46360. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46361. */
  46362. invertNormalMapX: boolean;
  46363. /**
  46364. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46365. */
  46366. invertNormalMapY: boolean;
  46367. /**
  46368. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46369. */
  46370. twoSidedLighting: boolean;
  46371. /**
  46372. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46373. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46374. */
  46375. useAlphaFresnel: boolean;
  46376. /**
  46377. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46378. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46379. */
  46380. useLinearAlphaFresnel: boolean;
  46381. /**
  46382. * Let user defines the brdf lookup texture used for IBL.
  46383. * A default 8bit version is embedded but you could point at :
  46384. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46385. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46386. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46387. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46388. */
  46389. environmentBRDFTexture: Nullable<BaseTexture>;
  46390. /**
  46391. * Force normal to face away from face.
  46392. */
  46393. forceNormalForward: boolean;
  46394. /**
  46395. * Enables specular anti aliasing in the PBR shader.
  46396. * It will both interacts on the Geometry for analytical and IBL lighting.
  46397. * It also prefilter the roughness map based on the bump values.
  46398. */
  46399. enableSpecularAntiAliasing: boolean;
  46400. /**
  46401. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46402. * makes the reflect vector face the model (under horizon).
  46403. */
  46404. useHorizonOcclusion: boolean;
  46405. /**
  46406. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46407. * too much the area relying on ambient texture to define their ambient occlusion.
  46408. */
  46409. useRadianceOcclusion: boolean;
  46410. /**
  46411. * If set to true, no lighting calculations will be applied.
  46412. */
  46413. unlit: boolean;
  46414. /**
  46415. * Gets the image processing configuration used either in this material.
  46416. */
  46417. /**
  46418. * Sets the Default image processing configuration used either in the this material.
  46419. *
  46420. * If sets to null, the scene one is in use.
  46421. */
  46422. imageProcessingConfiguration: ImageProcessingConfiguration;
  46423. /**
  46424. * Gets wether the color curves effect is enabled.
  46425. */
  46426. /**
  46427. * Sets wether the color curves effect is enabled.
  46428. */
  46429. cameraColorCurvesEnabled: boolean;
  46430. /**
  46431. * Gets wether the color grading effect is enabled.
  46432. */
  46433. /**
  46434. * Gets wether the color grading effect is enabled.
  46435. */
  46436. cameraColorGradingEnabled: boolean;
  46437. /**
  46438. * Gets wether tonemapping is enabled or not.
  46439. */
  46440. /**
  46441. * Sets wether tonemapping is enabled or not
  46442. */
  46443. cameraToneMappingEnabled: boolean;
  46444. /**
  46445. * The camera exposure used on this material.
  46446. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46447. * This corresponds to a photographic exposure.
  46448. */
  46449. /**
  46450. * The camera exposure used on this material.
  46451. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46452. * This corresponds to a photographic exposure.
  46453. */
  46454. cameraExposure: number;
  46455. /**
  46456. * Gets The camera contrast used on this material.
  46457. */
  46458. /**
  46459. * Sets The camera contrast used on this material.
  46460. */
  46461. cameraContrast: number;
  46462. /**
  46463. * Gets the Color Grading 2D Lookup Texture.
  46464. */
  46465. /**
  46466. * Sets the Color Grading 2D Lookup Texture.
  46467. */
  46468. cameraColorGradingTexture: Nullable<BaseTexture>;
  46469. /**
  46470. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46471. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46472. * 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;
  46473. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46474. */
  46475. /**
  46476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46478. * 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;
  46479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46480. */
  46481. cameraColorCurves: Nullable<ColorCurves>;
  46482. /**
  46483. * Instantiates a new PBRMaterial instance.
  46484. *
  46485. * @param name The material name
  46486. * @param scene The scene the material will be use in.
  46487. */
  46488. constructor(name: string, scene: Scene);
  46489. /**
  46490. * Returns the name of this material class.
  46491. */
  46492. getClassName(): string;
  46493. /**
  46494. * Makes a duplicate of the current material.
  46495. * @param name - name to use for the new material.
  46496. */
  46497. clone(name: string): PBRMaterial;
  46498. /**
  46499. * Serializes this PBR Material.
  46500. * @returns - An object with the serialized material.
  46501. */
  46502. serialize(): any;
  46503. /**
  46504. * Parses a PBR Material from a serialized object.
  46505. * @param source - Serialized object.
  46506. * @param scene - BJS scene instance.
  46507. * @param rootUrl - url for the scene object
  46508. * @returns - PBRMaterial
  46509. */
  46510. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46511. }
  46512. }
  46513. declare module "babylonjs/Misc/dds" {
  46514. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46515. import { Engine } from "babylonjs/Engines/engine";
  46516. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46517. import { Nullable } from "babylonjs/types";
  46518. import { Scene } from "babylonjs/scene";
  46519. /**
  46520. * Direct draw surface info
  46521. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46522. */
  46523. export interface DDSInfo {
  46524. /**
  46525. * Width of the texture
  46526. */
  46527. width: number;
  46528. /**
  46529. * Width of the texture
  46530. */
  46531. height: number;
  46532. /**
  46533. * Number of Mipmaps for the texture
  46534. * @see https://en.wikipedia.org/wiki/Mipmap
  46535. */
  46536. mipmapCount: number;
  46537. /**
  46538. * If the textures format is a known fourCC format
  46539. * @see https://www.fourcc.org/
  46540. */
  46541. isFourCC: boolean;
  46542. /**
  46543. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46544. */
  46545. isRGB: boolean;
  46546. /**
  46547. * If the texture is a lumincance format
  46548. */
  46549. isLuminance: boolean;
  46550. /**
  46551. * If this is a cube texture
  46552. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46553. */
  46554. isCube: boolean;
  46555. /**
  46556. * If the texture is a compressed format eg. FOURCC_DXT1
  46557. */
  46558. isCompressed: boolean;
  46559. /**
  46560. * The dxgiFormat of the texture
  46561. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46562. */
  46563. dxgiFormat: number;
  46564. /**
  46565. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46566. */
  46567. textureType: number;
  46568. /**
  46569. * Sphericle polynomial created for the dds texture
  46570. */
  46571. sphericalPolynomial?: SphericalPolynomial;
  46572. }
  46573. /**
  46574. * Class used to provide DDS decompression tools
  46575. */
  46576. export class DDSTools {
  46577. /**
  46578. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46579. */
  46580. static StoreLODInAlphaChannel: boolean;
  46581. /**
  46582. * Gets DDS information from an array buffer
  46583. * @param arrayBuffer defines the array buffer to read data from
  46584. * @returns the DDS information
  46585. */
  46586. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46587. private static _FloatView;
  46588. private static _Int32View;
  46589. private static _ToHalfFloat;
  46590. private static _FromHalfFloat;
  46591. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46592. private static _GetHalfFloatRGBAArrayBuffer;
  46593. private static _GetFloatRGBAArrayBuffer;
  46594. private static _GetFloatAsUIntRGBAArrayBuffer;
  46595. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46596. private static _GetRGBAArrayBuffer;
  46597. private static _ExtractLongWordOrder;
  46598. private static _GetRGBArrayBuffer;
  46599. private static _GetLuminanceArrayBuffer;
  46600. /**
  46601. * Uploads DDS Levels to a Babylon Texture
  46602. * @hidden
  46603. */
  46604. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46605. }
  46606. module "babylonjs/Engines/engine" {
  46607. interface Engine {
  46608. /**
  46609. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46610. * @param rootUrl defines the url where the file to load is located
  46611. * @param scene defines the current scene
  46612. * @param lodScale defines scale to apply to the mip map selection
  46613. * @param lodOffset defines offset to apply to the mip map selection
  46614. * @param onLoad defines an optional callback raised when the texture is loaded
  46615. * @param onError defines an optional callback raised if there is an issue to load the texture
  46616. * @param format defines the format of the data
  46617. * @param forcedExtension defines the extension to use to pick the right loader
  46618. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46619. * @returns the cube texture as an InternalTexture
  46620. */
  46621. 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;
  46622. }
  46623. }
  46624. }
  46625. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46626. import { Nullable } from "babylonjs/types";
  46627. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46628. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46629. /**
  46630. * Implementation of the DDS Texture Loader.
  46631. * @hidden
  46632. */
  46633. export class _DDSTextureLoader implements IInternalTextureLoader {
  46634. /**
  46635. * Defines wether the loader supports cascade loading the different faces.
  46636. */
  46637. readonly supportCascades: boolean;
  46638. /**
  46639. * This returns if the loader support the current file information.
  46640. * @param extension defines the file extension of the file being loaded
  46641. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46642. * @param fallback defines the fallback internal texture if any
  46643. * @param isBase64 defines whether the texture is encoded as a base64
  46644. * @param isBuffer defines whether the texture data are stored as a buffer
  46645. * @returns true if the loader can load the specified file
  46646. */
  46647. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46648. /**
  46649. * Transform the url before loading if required.
  46650. * @param rootUrl the url of the texture
  46651. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46652. * @returns the transformed texture
  46653. */
  46654. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46655. /**
  46656. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46657. * @param rootUrl the url of the texture
  46658. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46659. * @returns the fallback texture
  46660. */
  46661. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46662. /**
  46663. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46664. * @param data contains the texture data
  46665. * @param texture defines the BabylonJS internal texture
  46666. * @param createPolynomials will be true if polynomials have been requested
  46667. * @param onLoad defines the callback to trigger once the texture is ready
  46668. * @param onError defines the callback to trigger in case of error
  46669. */
  46670. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46671. /**
  46672. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46673. * @param data contains the texture data
  46674. * @param texture defines the BabylonJS internal texture
  46675. * @param callback defines the method to call once ready to upload
  46676. */
  46677. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46678. }
  46679. }
  46680. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46681. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46682. /** @hidden */
  46683. export var rgbdEncodePixelShader: {
  46684. name: string;
  46685. shader: string;
  46686. };
  46687. }
  46688. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46689. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46690. /** @hidden */
  46691. export var rgbdDecodePixelShader: {
  46692. name: string;
  46693. shader: string;
  46694. };
  46695. }
  46696. declare module "babylonjs/Misc/environmentTextureTools" {
  46697. import { Nullable } from "babylonjs/types";
  46698. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46699. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46700. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46701. import "babylonjs/Shaders/rgbdEncode.fragment";
  46702. import "babylonjs/Shaders/rgbdDecode.fragment";
  46703. /**
  46704. * Raw texture data and descriptor sufficient for WebGL texture upload
  46705. */
  46706. export interface EnvironmentTextureInfo {
  46707. /**
  46708. * Version of the environment map
  46709. */
  46710. version: number;
  46711. /**
  46712. * Width of image
  46713. */
  46714. width: number;
  46715. /**
  46716. * Irradiance information stored in the file.
  46717. */
  46718. irradiance: any;
  46719. /**
  46720. * Specular information stored in the file.
  46721. */
  46722. specular: any;
  46723. }
  46724. /**
  46725. * Sets of helpers addressing the serialization and deserialization of environment texture
  46726. * stored in a BabylonJS env file.
  46727. * Those files are usually stored as .env files.
  46728. */
  46729. export class EnvironmentTextureTools {
  46730. /**
  46731. * Magic number identifying the env file.
  46732. */
  46733. private static _MagicBytes;
  46734. /**
  46735. * Gets the environment info from an env file.
  46736. * @param data The array buffer containing the .env bytes.
  46737. * @returns the environment file info (the json header) if successfully parsed.
  46738. */
  46739. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46740. /**
  46741. * Creates an environment texture from a loaded cube texture.
  46742. * @param texture defines the cube texture to convert in env file
  46743. * @return a promise containing the environment data if succesfull.
  46744. */
  46745. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46746. /**
  46747. * Creates a JSON representation of the spherical data.
  46748. * @param texture defines the texture containing the polynomials
  46749. * @return the JSON representation of the spherical info
  46750. */
  46751. private static _CreateEnvTextureIrradiance;
  46752. /**
  46753. * Uploads the texture info contained in the env file to the GPU.
  46754. * @param texture defines the internal texture to upload to
  46755. * @param arrayBuffer defines the buffer cotaining the data to load
  46756. * @param info defines the texture info retrieved through the GetEnvInfo method
  46757. * @returns a promise
  46758. */
  46759. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46760. /**
  46761. * Uploads the levels of image data to the GPU.
  46762. * @param texture defines the internal texture to upload to
  46763. * @param imageData defines the array buffer views of image data [mipmap][face]
  46764. * @returns a promise
  46765. */
  46766. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46767. /**
  46768. * Uploads spherical polynomials information to the texture.
  46769. * @param texture defines the texture we are trying to upload the information to
  46770. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46771. */
  46772. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46773. /** @hidden */
  46774. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46775. }
  46776. }
  46777. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46778. import { Nullable } from "babylonjs/types";
  46779. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46780. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46781. /**
  46782. * Implementation of the ENV Texture Loader.
  46783. * @hidden
  46784. */
  46785. export class _ENVTextureLoader implements IInternalTextureLoader {
  46786. /**
  46787. * Defines wether the loader supports cascade loading the different faces.
  46788. */
  46789. readonly supportCascades: boolean;
  46790. /**
  46791. * This returns if the loader support the current file information.
  46792. * @param extension defines the file extension of the file being loaded
  46793. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46794. * @param fallback defines the fallback internal texture if any
  46795. * @param isBase64 defines whether the texture is encoded as a base64
  46796. * @param isBuffer defines whether the texture data are stored as a buffer
  46797. * @returns true if the loader can load the specified file
  46798. */
  46799. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46800. /**
  46801. * Transform the url before loading if required.
  46802. * @param rootUrl the url of the texture
  46803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46804. * @returns the transformed texture
  46805. */
  46806. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46807. /**
  46808. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46809. * @param rootUrl the url of the texture
  46810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46811. * @returns the fallback texture
  46812. */
  46813. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46814. /**
  46815. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46816. * @param data contains the texture data
  46817. * @param texture defines the BabylonJS internal texture
  46818. * @param createPolynomials will be true if polynomials have been requested
  46819. * @param onLoad defines the callback to trigger once the texture is ready
  46820. * @param onError defines the callback to trigger in case of error
  46821. */
  46822. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46823. /**
  46824. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46825. * @param data contains the texture data
  46826. * @param texture defines the BabylonJS internal texture
  46827. * @param callback defines the method to call once ready to upload
  46828. */
  46829. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46830. }
  46831. }
  46832. declare module "babylonjs/Misc/khronosTextureContainer" {
  46833. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46834. /**
  46835. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46836. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46837. */
  46838. export class KhronosTextureContainer {
  46839. /** contents of the KTX container file */
  46840. arrayBuffer: any;
  46841. private static HEADER_LEN;
  46842. private static COMPRESSED_2D;
  46843. private static COMPRESSED_3D;
  46844. private static TEX_2D;
  46845. private static TEX_3D;
  46846. /**
  46847. * Gets the openGL type
  46848. */
  46849. glType: number;
  46850. /**
  46851. * Gets the openGL type size
  46852. */
  46853. glTypeSize: number;
  46854. /**
  46855. * Gets the openGL format
  46856. */
  46857. glFormat: number;
  46858. /**
  46859. * Gets the openGL internal format
  46860. */
  46861. glInternalFormat: number;
  46862. /**
  46863. * Gets the base internal format
  46864. */
  46865. glBaseInternalFormat: number;
  46866. /**
  46867. * Gets image width in pixel
  46868. */
  46869. pixelWidth: number;
  46870. /**
  46871. * Gets image height in pixel
  46872. */
  46873. pixelHeight: number;
  46874. /**
  46875. * Gets image depth in pixels
  46876. */
  46877. pixelDepth: number;
  46878. /**
  46879. * Gets the number of array elements
  46880. */
  46881. numberOfArrayElements: number;
  46882. /**
  46883. * Gets the number of faces
  46884. */
  46885. numberOfFaces: number;
  46886. /**
  46887. * Gets the number of mipmap levels
  46888. */
  46889. numberOfMipmapLevels: number;
  46890. /**
  46891. * Gets the bytes of key value data
  46892. */
  46893. bytesOfKeyValueData: number;
  46894. /**
  46895. * Gets the load type
  46896. */
  46897. loadType: number;
  46898. /**
  46899. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46900. */
  46901. isInvalid: boolean;
  46902. /**
  46903. * Creates a new KhronosTextureContainer
  46904. * @param arrayBuffer contents of the KTX container file
  46905. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46906. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46907. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46908. */
  46909. constructor(
  46910. /** contents of the KTX container file */
  46911. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46912. /**
  46913. * Uploads KTX content to a Babylon Texture.
  46914. * It is assumed that the texture has already been created & is currently bound
  46915. * @hidden
  46916. */
  46917. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46918. private _upload2DCompressedLevels;
  46919. }
  46920. }
  46921. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46922. import { Nullable } from "babylonjs/types";
  46923. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46924. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46925. /**
  46926. * Implementation of the KTX Texture Loader.
  46927. * @hidden
  46928. */
  46929. export class _KTXTextureLoader implements IInternalTextureLoader {
  46930. /**
  46931. * Defines wether the loader supports cascade loading the different faces.
  46932. */
  46933. readonly supportCascades: boolean;
  46934. /**
  46935. * This returns if the loader support the current file information.
  46936. * @param extension defines the file extension of the file being loaded
  46937. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46938. * @param fallback defines the fallback internal texture if any
  46939. * @param isBase64 defines whether the texture is encoded as a base64
  46940. * @param isBuffer defines whether the texture data are stored as a buffer
  46941. * @returns true if the loader can load the specified file
  46942. */
  46943. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46944. /**
  46945. * Transform the url before loading if required.
  46946. * @param rootUrl the url of the texture
  46947. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46948. * @returns the transformed texture
  46949. */
  46950. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46951. /**
  46952. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46953. * @param rootUrl the url of the texture
  46954. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46955. * @returns the fallback texture
  46956. */
  46957. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46958. /**
  46959. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46960. * @param data contains the texture data
  46961. * @param texture defines the BabylonJS internal texture
  46962. * @param createPolynomials will be true if polynomials have been requested
  46963. * @param onLoad defines the callback to trigger once the texture is ready
  46964. * @param onError defines the callback to trigger in case of error
  46965. */
  46966. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46967. /**
  46968. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46969. * @param data contains the texture data
  46970. * @param texture defines the BabylonJS internal texture
  46971. * @param callback defines the method to call once ready to upload
  46972. */
  46973. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46974. }
  46975. }
  46976. declare module "babylonjs/Helpers/sceneHelpers" {
  46977. import { Nullable } from "babylonjs/types";
  46978. import { Mesh } from "babylonjs/Meshes/mesh";
  46979. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46980. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46981. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46982. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46983. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46984. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46985. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46986. import "babylonjs/Meshes/Builders/boxBuilder";
  46987. /** @hidden */
  46988. export var _forceSceneHelpersToBundle: boolean;
  46989. module "babylonjs/scene" {
  46990. interface Scene {
  46991. /**
  46992. * Creates a default light for the scene.
  46993. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46994. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46995. */
  46996. createDefaultLight(replace?: boolean): void;
  46997. /**
  46998. * Creates a default camera for the scene.
  46999. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47000. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47001. * @param replace has default false, when true replaces the active camera in the scene
  47002. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47003. */
  47004. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47005. /**
  47006. * Creates a default camera and a default light.
  47007. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47008. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47009. * @param replace has the default false, when true replaces the active camera/light in the scene
  47010. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47011. */
  47012. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47013. /**
  47014. * Creates a new sky box
  47015. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47016. * @param environmentTexture defines the texture to use as environment texture
  47017. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47018. * @param scale defines the overall scale of the skybox
  47019. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47020. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47021. * @returns a new mesh holding the sky box
  47022. */
  47023. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47024. /**
  47025. * Creates a new environment
  47026. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47027. * @param options defines the options you can use to configure the environment
  47028. * @returns the new EnvironmentHelper
  47029. */
  47030. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47031. /**
  47032. * Creates a new VREXperienceHelper
  47033. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47034. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47035. * @returns a new VREXperienceHelper
  47036. */
  47037. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47038. /**
  47039. * Creates a new XREXperienceHelper
  47040. * @see http://doc.babylonjs.com/how_to/webxr
  47041. * @returns a promise for a new XREXperienceHelper
  47042. */
  47043. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47044. }
  47045. }
  47046. }
  47047. declare module "babylonjs/Helpers/videoDome" {
  47048. import { Scene } from "babylonjs/scene";
  47049. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47050. import { Mesh } from "babylonjs/Meshes/mesh";
  47051. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47052. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47053. import "babylonjs/Meshes/Builders/sphereBuilder";
  47054. /**
  47055. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47056. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47057. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47058. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47059. */
  47060. export class VideoDome extends TransformNode {
  47061. /**
  47062. * Define the video source as a Monoscopic panoramic 360 video.
  47063. */
  47064. static readonly MODE_MONOSCOPIC: number;
  47065. /**
  47066. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47067. */
  47068. static readonly MODE_TOPBOTTOM: number;
  47069. /**
  47070. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47071. */
  47072. static readonly MODE_SIDEBYSIDE: number;
  47073. private _useDirectMapping;
  47074. /**
  47075. * The video texture being displayed on the sphere
  47076. */
  47077. protected _videoTexture: VideoTexture;
  47078. /**
  47079. * Gets the video texture being displayed on the sphere
  47080. */
  47081. readonly videoTexture: VideoTexture;
  47082. /**
  47083. * The skybox material
  47084. */
  47085. protected _material: BackgroundMaterial;
  47086. /**
  47087. * The surface used for the skybox
  47088. */
  47089. protected _mesh: Mesh;
  47090. /**
  47091. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47092. * Also see the options.resolution property.
  47093. */
  47094. fovMultiplier: number;
  47095. private _videoMode;
  47096. /**
  47097. * Gets or set the current video mode for the video. It can be:
  47098. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47099. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47100. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47101. */
  47102. videoMode: number;
  47103. /**
  47104. * Oberserver used in Stereoscopic VR Mode.
  47105. */
  47106. private _onBeforeCameraRenderObserver;
  47107. /**
  47108. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47109. * @param name Element's name, child elements will append suffixes for their own names.
  47110. * @param urlsOrVideo defines the url(s) or the video element to use
  47111. * @param options An object containing optional or exposed sub element properties
  47112. */
  47113. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47114. resolution?: number;
  47115. clickToPlay?: boolean;
  47116. autoPlay?: boolean;
  47117. loop?: boolean;
  47118. size?: number;
  47119. poster?: string;
  47120. faceForward?: boolean;
  47121. useDirectMapping?: boolean;
  47122. }, scene: Scene);
  47123. private _changeVideoMode;
  47124. /**
  47125. * Releases resources associated with this node.
  47126. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47127. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47128. */
  47129. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47130. }
  47131. }
  47132. declare module "babylonjs/Helpers/index" {
  47133. export * from "babylonjs/Helpers/environmentHelper";
  47134. export * from "babylonjs/Helpers/photoDome";
  47135. export * from "babylonjs/Helpers/sceneHelpers";
  47136. export * from "babylonjs/Helpers/videoDome";
  47137. }
  47138. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  47139. import { PerfCounter } from "babylonjs/Misc/tools";
  47140. import { IDisposable } from "babylonjs/scene";
  47141. import { Engine } from "babylonjs/Engines/engine";
  47142. /**
  47143. * This class can be used to get instrumentation data from a Babylon engine
  47144. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47145. */
  47146. export class EngineInstrumentation implements IDisposable {
  47147. /**
  47148. * Define the instrumented engine.
  47149. */
  47150. engine: Engine;
  47151. private _captureGPUFrameTime;
  47152. private _gpuFrameTimeToken;
  47153. private _gpuFrameTime;
  47154. private _captureShaderCompilationTime;
  47155. private _shaderCompilationTime;
  47156. private _onBeginFrameObserver;
  47157. private _onEndFrameObserver;
  47158. private _onBeforeShaderCompilationObserver;
  47159. private _onAfterShaderCompilationObserver;
  47160. /**
  47161. * Gets the perf counter used for GPU frame time
  47162. */
  47163. readonly gpuFrameTimeCounter: PerfCounter;
  47164. /**
  47165. * Gets the GPU frame time capture status
  47166. */
  47167. /**
  47168. * Enable or disable the GPU frame time capture
  47169. */
  47170. captureGPUFrameTime: boolean;
  47171. /**
  47172. * Gets the perf counter used for shader compilation time
  47173. */
  47174. readonly shaderCompilationTimeCounter: PerfCounter;
  47175. /**
  47176. * Gets the shader compilation time capture status
  47177. */
  47178. /**
  47179. * Enable or disable the shader compilation time capture
  47180. */
  47181. captureShaderCompilationTime: boolean;
  47182. /**
  47183. * Instantiates a new engine instrumentation.
  47184. * This class can be used to get instrumentation data from a Babylon engine
  47185. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47186. * @param engine Defines the engine to instrument
  47187. */
  47188. constructor(
  47189. /**
  47190. * Define the instrumented engine.
  47191. */
  47192. engine: Engine);
  47193. /**
  47194. * Dispose and release associated resources.
  47195. */
  47196. dispose(): void;
  47197. }
  47198. }
  47199. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  47200. import { PerfCounter } from "babylonjs/Misc/tools";
  47201. import { Scene, IDisposable } from "babylonjs/scene";
  47202. /**
  47203. * This class can be used to get instrumentation data from a Babylon engine
  47204. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47205. */
  47206. export class SceneInstrumentation implements IDisposable {
  47207. /**
  47208. * Defines the scene to instrument
  47209. */
  47210. scene: Scene;
  47211. private _captureActiveMeshesEvaluationTime;
  47212. private _activeMeshesEvaluationTime;
  47213. private _captureRenderTargetsRenderTime;
  47214. private _renderTargetsRenderTime;
  47215. private _captureFrameTime;
  47216. private _frameTime;
  47217. private _captureRenderTime;
  47218. private _renderTime;
  47219. private _captureInterFrameTime;
  47220. private _interFrameTime;
  47221. private _captureParticlesRenderTime;
  47222. private _particlesRenderTime;
  47223. private _captureSpritesRenderTime;
  47224. private _spritesRenderTime;
  47225. private _capturePhysicsTime;
  47226. private _physicsTime;
  47227. private _captureAnimationsTime;
  47228. private _animationsTime;
  47229. private _captureCameraRenderTime;
  47230. private _cameraRenderTime;
  47231. private _onBeforeActiveMeshesEvaluationObserver;
  47232. private _onAfterActiveMeshesEvaluationObserver;
  47233. private _onBeforeRenderTargetsRenderObserver;
  47234. private _onAfterRenderTargetsRenderObserver;
  47235. private _onAfterRenderObserver;
  47236. private _onBeforeDrawPhaseObserver;
  47237. private _onAfterDrawPhaseObserver;
  47238. private _onBeforeAnimationsObserver;
  47239. private _onBeforeParticlesRenderingObserver;
  47240. private _onAfterParticlesRenderingObserver;
  47241. private _onBeforeSpritesRenderingObserver;
  47242. private _onAfterSpritesRenderingObserver;
  47243. private _onBeforePhysicsObserver;
  47244. private _onAfterPhysicsObserver;
  47245. private _onAfterAnimationsObserver;
  47246. private _onBeforeCameraRenderObserver;
  47247. private _onAfterCameraRenderObserver;
  47248. /**
  47249. * Gets the perf counter used for active meshes evaluation time
  47250. */
  47251. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47252. /**
  47253. * Gets the active meshes evaluation time capture status
  47254. */
  47255. /**
  47256. * Enable or disable the active meshes evaluation time capture
  47257. */
  47258. captureActiveMeshesEvaluationTime: boolean;
  47259. /**
  47260. * Gets the perf counter used for render targets render time
  47261. */
  47262. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47263. /**
  47264. * Gets the render targets render time capture status
  47265. */
  47266. /**
  47267. * Enable or disable the render targets render time capture
  47268. */
  47269. captureRenderTargetsRenderTime: boolean;
  47270. /**
  47271. * Gets the perf counter used for particles render time
  47272. */
  47273. readonly particlesRenderTimeCounter: PerfCounter;
  47274. /**
  47275. * Gets the particles render time capture status
  47276. */
  47277. /**
  47278. * Enable or disable the particles render time capture
  47279. */
  47280. captureParticlesRenderTime: boolean;
  47281. /**
  47282. * Gets the perf counter used for sprites render time
  47283. */
  47284. readonly spritesRenderTimeCounter: PerfCounter;
  47285. /**
  47286. * Gets the sprites render time capture status
  47287. */
  47288. /**
  47289. * Enable or disable the sprites render time capture
  47290. */
  47291. captureSpritesRenderTime: boolean;
  47292. /**
  47293. * Gets the perf counter used for physics time
  47294. */
  47295. readonly physicsTimeCounter: PerfCounter;
  47296. /**
  47297. * Gets the physics time capture status
  47298. */
  47299. /**
  47300. * Enable or disable the physics time capture
  47301. */
  47302. capturePhysicsTime: boolean;
  47303. /**
  47304. * Gets the perf counter used for animations time
  47305. */
  47306. readonly animationsTimeCounter: PerfCounter;
  47307. /**
  47308. * Gets the animations time capture status
  47309. */
  47310. /**
  47311. * Enable or disable the animations time capture
  47312. */
  47313. captureAnimationsTime: boolean;
  47314. /**
  47315. * Gets the perf counter used for frame time capture
  47316. */
  47317. readonly frameTimeCounter: PerfCounter;
  47318. /**
  47319. * Gets the frame time capture status
  47320. */
  47321. /**
  47322. * Enable or disable the frame time capture
  47323. */
  47324. captureFrameTime: boolean;
  47325. /**
  47326. * Gets the perf counter used for inter-frames time capture
  47327. */
  47328. readonly interFrameTimeCounter: PerfCounter;
  47329. /**
  47330. * Gets the inter-frames time capture status
  47331. */
  47332. /**
  47333. * Enable or disable the inter-frames time capture
  47334. */
  47335. captureInterFrameTime: boolean;
  47336. /**
  47337. * Gets the perf counter used for render time capture
  47338. */
  47339. readonly renderTimeCounter: PerfCounter;
  47340. /**
  47341. * Gets the render time capture status
  47342. */
  47343. /**
  47344. * Enable or disable the render time capture
  47345. */
  47346. captureRenderTime: boolean;
  47347. /**
  47348. * Gets the perf counter used for camera render time capture
  47349. */
  47350. readonly cameraRenderTimeCounter: PerfCounter;
  47351. /**
  47352. * Gets the camera render time capture status
  47353. */
  47354. /**
  47355. * Enable or disable the camera render time capture
  47356. */
  47357. captureCameraRenderTime: boolean;
  47358. /**
  47359. * Gets the perf counter used for draw calls
  47360. */
  47361. readonly drawCallsCounter: PerfCounter;
  47362. /**
  47363. * Gets the perf counter used for texture collisions
  47364. */
  47365. readonly textureCollisionsCounter: PerfCounter;
  47366. /**
  47367. * Instantiates a new scene instrumentation.
  47368. * This class can be used to get instrumentation data from a Babylon engine
  47369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47370. * @param scene Defines the scene to instrument
  47371. */
  47372. constructor(
  47373. /**
  47374. * Defines the scene to instrument
  47375. */
  47376. scene: Scene);
  47377. /**
  47378. * Dispose and release associated resources.
  47379. */
  47380. dispose(): void;
  47381. }
  47382. }
  47383. declare module "babylonjs/Instrumentation/index" {
  47384. export * from "babylonjs/Instrumentation/engineInstrumentation";
  47385. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  47386. export * from "babylonjs/Instrumentation/timeToken";
  47387. }
  47388. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  47389. /** @hidden */
  47390. export var glowMapGenerationPixelShader: {
  47391. name: string;
  47392. shader: string;
  47393. };
  47394. }
  47395. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  47396. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47397. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47399. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47400. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47401. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47402. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47403. /** @hidden */
  47404. export var glowMapGenerationVertexShader: {
  47405. name: string;
  47406. shader: string;
  47407. };
  47408. }
  47409. declare module "babylonjs/Layers/effectLayer" {
  47410. import { Observable } from "babylonjs/Misc/observable";
  47411. import { Nullable } from "babylonjs/types";
  47412. import { Camera } from "babylonjs/Cameras/camera";
  47413. import { Scene } from "babylonjs/scene";
  47414. import { Color4, ISize } from "babylonjs/Maths/math";
  47415. import { Engine } from "babylonjs/Engines/engine";
  47416. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47418. import { Mesh } from "babylonjs/Meshes/mesh";
  47419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47421. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47422. import { Effect } from "babylonjs/Materials/effect";
  47423. import { Material } from "babylonjs/Materials/material";
  47424. import "babylonjs/Shaders/glowMapGeneration.fragment";
  47425. import "babylonjs/Shaders/glowMapGeneration.vertex";
  47426. /**
  47427. * Effect layer options. This helps customizing the behaviour
  47428. * of the effect layer.
  47429. */
  47430. export interface IEffectLayerOptions {
  47431. /**
  47432. * Multiplication factor apply to the canvas size to compute the render target size
  47433. * used to generated the objects (the smaller the faster).
  47434. */
  47435. mainTextureRatio: number;
  47436. /**
  47437. * Enforces a fixed size texture to ensure effect stability across devices.
  47438. */
  47439. mainTextureFixedSize?: number;
  47440. /**
  47441. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47442. */
  47443. alphaBlendingMode: number;
  47444. /**
  47445. * The camera attached to the layer.
  47446. */
  47447. camera: Nullable<Camera>;
  47448. /**
  47449. * The rendering group to draw the layer in.
  47450. */
  47451. renderingGroupId: number;
  47452. }
  47453. /**
  47454. * The effect layer Helps adding post process effect blended with the main pass.
  47455. *
  47456. * This can be for instance use to generate glow or higlight effects on the scene.
  47457. *
  47458. * The effect layer class can not be used directly and is intented to inherited from to be
  47459. * customized per effects.
  47460. */
  47461. export abstract class EffectLayer {
  47462. private _vertexBuffers;
  47463. private _indexBuffer;
  47464. private _cachedDefines;
  47465. private _effectLayerMapGenerationEffect;
  47466. private _effectLayerOptions;
  47467. private _mergeEffect;
  47468. protected _scene: Scene;
  47469. protected _engine: Engine;
  47470. protected _maxSize: number;
  47471. protected _mainTextureDesiredSize: ISize;
  47472. protected _mainTexture: RenderTargetTexture;
  47473. protected _shouldRender: boolean;
  47474. protected _postProcesses: PostProcess[];
  47475. protected _textures: BaseTexture[];
  47476. protected _emissiveTextureAndColor: {
  47477. texture: Nullable<BaseTexture>;
  47478. color: Color4;
  47479. };
  47480. /**
  47481. * The name of the layer
  47482. */
  47483. name: string;
  47484. /**
  47485. * The clear color of the texture used to generate the glow map.
  47486. */
  47487. neutralColor: Color4;
  47488. /**
  47489. * Specifies wether the highlight layer is enabled or not.
  47490. */
  47491. isEnabled: boolean;
  47492. /**
  47493. * Gets the camera attached to the layer.
  47494. */
  47495. readonly camera: Nullable<Camera>;
  47496. /**
  47497. * Gets the rendering group id the layer should render in.
  47498. */
  47499. readonly renderingGroupId: number;
  47500. /**
  47501. * An event triggered when the effect layer has been disposed.
  47502. */
  47503. onDisposeObservable: Observable<EffectLayer>;
  47504. /**
  47505. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47506. */
  47507. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47508. /**
  47509. * An event triggered when the generated texture is being merged in the scene.
  47510. */
  47511. onBeforeComposeObservable: Observable<EffectLayer>;
  47512. /**
  47513. * An event triggered when the generated texture has been merged in the scene.
  47514. */
  47515. onAfterComposeObservable: Observable<EffectLayer>;
  47516. /**
  47517. * An event triggered when the efffect layer changes its size.
  47518. */
  47519. onSizeChangedObservable: Observable<EffectLayer>;
  47520. /** @hidden */
  47521. static _SceneComponentInitialization: (scene: Scene) => void;
  47522. /**
  47523. * Instantiates a new effect Layer and references it in the scene.
  47524. * @param name The name of the layer
  47525. * @param scene The scene to use the layer in
  47526. */
  47527. constructor(
  47528. /** The Friendly of the effect in the scene */
  47529. name: string, scene: Scene);
  47530. /**
  47531. * Get the effect name of the layer.
  47532. * @return The effect name
  47533. */
  47534. abstract getEffectName(): string;
  47535. /**
  47536. * Checks for the readiness of the element composing the layer.
  47537. * @param subMesh the mesh to check for
  47538. * @param useInstances specify wether or not to use instances to render the mesh
  47539. * @return true if ready otherwise, false
  47540. */
  47541. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47542. /**
  47543. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47544. * @returns true if the effect requires stencil during the main canvas render pass.
  47545. */
  47546. abstract needStencil(): boolean;
  47547. /**
  47548. * Create the merge effect. This is the shader use to blit the information back
  47549. * to the main canvas at the end of the scene rendering.
  47550. * @returns The effect containing the shader used to merge the effect on the main canvas
  47551. */
  47552. protected abstract _createMergeEffect(): Effect;
  47553. /**
  47554. * Creates the render target textures and post processes used in the effect layer.
  47555. */
  47556. protected abstract _createTextureAndPostProcesses(): void;
  47557. /**
  47558. * Implementation specific of rendering the generating effect on the main canvas.
  47559. * @param effect The effect used to render through
  47560. */
  47561. protected abstract _internalRender(effect: Effect): void;
  47562. /**
  47563. * Sets the required values for both the emissive texture and and the main color.
  47564. */
  47565. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47566. /**
  47567. * Free any resources and references associated to a mesh.
  47568. * Internal use
  47569. * @param mesh The mesh to free.
  47570. */
  47571. abstract _disposeMesh(mesh: Mesh): void;
  47572. /**
  47573. * Serializes this layer (Glow or Highlight for example)
  47574. * @returns a serialized layer object
  47575. */
  47576. abstract serialize?(): any;
  47577. /**
  47578. * Initializes the effect layer with the required options.
  47579. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47580. */
  47581. protected _init(options: Partial<IEffectLayerOptions>): void;
  47582. /**
  47583. * Generates the index buffer of the full screen quad blending to the main canvas.
  47584. */
  47585. private _generateIndexBuffer;
  47586. /**
  47587. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47588. */
  47589. private _genrateVertexBuffer;
  47590. /**
  47591. * Sets the main texture desired size which is the closest power of two
  47592. * of the engine canvas size.
  47593. */
  47594. private _setMainTextureSize;
  47595. /**
  47596. * Creates the main texture for the effect layer.
  47597. */
  47598. protected _createMainTexture(): void;
  47599. /**
  47600. * Adds specific effects defines.
  47601. * @param defines The defines to add specifics to.
  47602. */
  47603. protected _addCustomEffectDefines(defines: string[]): void;
  47604. /**
  47605. * Checks for the readiness of the element composing the layer.
  47606. * @param subMesh the mesh to check for
  47607. * @param useInstances specify wether or not to use instances to render the mesh
  47608. * @param emissiveTexture the associated emissive texture used to generate the glow
  47609. * @return true if ready otherwise, false
  47610. */
  47611. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47612. /**
  47613. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47614. */
  47615. render(): void;
  47616. /**
  47617. * Determine if a given mesh will be used in the current effect.
  47618. * @param mesh mesh to test
  47619. * @returns true if the mesh will be used
  47620. */
  47621. hasMesh(mesh: AbstractMesh): boolean;
  47622. /**
  47623. * Returns true if the layer contains information to display, otherwise false.
  47624. * @returns true if the glow layer should be rendered
  47625. */
  47626. shouldRender(): boolean;
  47627. /**
  47628. * Returns true if the mesh should render, otherwise false.
  47629. * @param mesh The mesh to render
  47630. * @returns true if it should render otherwise false
  47631. */
  47632. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47633. /**
  47634. * Returns true if the mesh can be rendered, otherwise false.
  47635. * @param mesh The mesh to render
  47636. * @param material The material used on the mesh
  47637. * @returns true if it can be rendered otherwise false
  47638. */
  47639. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47640. /**
  47641. * Returns true if the mesh should render, otherwise false.
  47642. * @param mesh The mesh to render
  47643. * @returns true if it should render otherwise false
  47644. */
  47645. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47646. /**
  47647. * Renders the submesh passed in parameter to the generation map.
  47648. */
  47649. protected _renderSubMesh(subMesh: SubMesh): void;
  47650. /**
  47651. * Rebuild the required buffers.
  47652. * @hidden Internal use only.
  47653. */
  47654. _rebuild(): void;
  47655. /**
  47656. * Dispose only the render target textures and post process.
  47657. */
  47658. private _disposeTextureAndPostProcesses;
  47659. /**
  47660. * Dispose the highlight layer and free resources.
  47661. */
  47662. dispose(): void;
  47663. /**
  47664. * Gets the class name of the effect layer
  47665. * @returns the string with the class name of the effect layer
  47666. */
  47667. getClassName(): string;
  47668. /**
  47669. * Creates an effect layer from parsed effect layer data
  47670. * @param parsedEffectLayer defines effect layer data
  47671. * @param scene defines the current scene
  47672. * @param rootUrl defines the root URL containing the effect layer information
  47673. * @returns a parsed effect Layer
  47674. */
  47675. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47676. }
  47677. }
  47678. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47679. import { Scene } from "babylonjs/scene";
  47680. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47681. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47682. import { AbstractScene } from "babylonjs/abstractScene";
  47683. module "babylonjs/abstractScene" {
  47684. interface AbstractScene {
  47685. /**
  47686. * The list of effect layers (highlights/glow) added to the scene
  47687. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47688. * @see http://doc.babylonjs.com/how_to/glow_layer
  47689. */
  47690. effectLayers: Array<EffectLayer>;
  47691. /**
  47692. * Removes the given effect layer from this scene.
  47693. * @param toRemove defines the effect layer to remove
  47694. * @returns the index of the removed effect layer
  47695. */
  47696. removeEffectLayer(toRemove: EffectLayer): number;
  47697. /**
  47698. * Adds the given effect layer to this scene
  47699. * @param newEffectLayer defines the effect layer to add
  47700. */
  47701. addEffectLayer(newEffectLayer: EffectLayer): void;
  47702. }
  47703. }
  47704. /**
  47705. * Defines the layer scene component responsible to manage any effect layers
  47706. * in a given scene.
  47707. */
  47708. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47709. /**
  47710. * The component name helpfull to identify the component in the list of scene components.
  47711. */
  47712. readonly name: string;
  47713. /**
  47714. * The scene the component belongs to.
  47715. */
  47716. scene: Scene;
  47717. private _engine;
  47718. private _renderEffects;
  47719. private _needStencil;
  47720. private _previousStencilState;
  47721. /**
  47722. * Creates a new instance of the component for the given scene
  47723. * @param scene Defines the scene to register the component in
  47724. */
  47725. constructor(scene: Scene);
  47726. /**
  47727. * Registers the component in a given scene
  47728. */
  47729. register(): void;
  47730. /**
  47731. * Rebuilds the elements related to this component in case of
  47732. * context lost for instance.
  47733. */
  47734. rebuild(): void;
  47735. /**
  47736. * Serializes the component data to the specified json object
  47737. * @param serializationObject The object to serialize to
  47738. */
  47739. serialize(serializationObject: any): void;
  47740. /**
  47741. * Adds all the element from the container to the scene
  47742. * @param container the container holding the elements
  47743. */
  47744. addFromContainer(container: AbstractScene): void;
  47745. /**
  47746. * Removes all the elements in the container from the scene
  47747. * @param container contains the elements to remove
  47748. * @param dispose if the removed element should be disposed (default: false)
  47749. */
  47750. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47751. /**
  47752. * Disposes the component and the associated ressources.
  47753. */
  47754. dispose(): void;
  47755. private _isReadyForMesh;
  47756. private _renderMainTexture;
  47757. private _setStencil;
  47758. private _setStencilBack;
  47759. private _draw;
  47760. private _drawCamera;
  47761. private _drawRenderingGroup;
  47762. }
  47763. }
  47764. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47765. /** @hidden */
  47766. export var glowMapMergePixelShader: {
  47767. name: string;
  47768. shader: string;
  47769. };
  47770. }
  47771. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47772. /** @hidden */
  47773. export var glowMapMergeVertexShader: {
  47774. name: string;
  47775. shader: string;
  47776. };
  47777. }
  47778. declare module "babylonjs/Layers/glowLayer" {
  47779. import { Nullable } from "babylonjs/types";
  47780. import { Camera } from "babylonjs/Cameras/camera";
  47781. import { Scene } from "babylonjs/scene";
  47782. import { Color4 } from "babylonjs/Maths/math";
  47783. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47785. import { Mesh } from "babylonjs/Meshes/mesh";
  47786. import { Texture } from "babylonjs/Materials/Textures/texture";
  47787. import { Effect } from "babylonjs/Materials/effect";
  47788. import { Material } from "babylonjs/Materials/material";
  47789. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47790. import "babylonjs/Shaders/glowMapMerge.fragment";
  47791. import "babylonjs/Shaders/glowMapMerge.vertex";
  47792. import "babylonjs/Layers/effectLayerSceneComponent";
  47793. module "babylonjs/abstractScene" {
  47794. interface AbstractScene {
  47795. /**
  47796. * Return a the first highlight layer of the scene with a given name.
  47797. * @param name The name of the highlight layer to look for.
  47798. * @return The highlight layer if found otherwise null.
  47799. */
  47800. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47801. }
  47802. }
  47803. /**
  47804. * Glow layer options. This helps customizing the behaviour
  47805. * of the glow layer.
  47806. */
  47807. export interface IGlowLayerOptions {
  47808. /**
  47809. * Multiplication factor apply to the canvas size to compute the render target size
  47810. * used to generated the glowing objects (the smaller the faster).
  47811. */
  47812. mainTextureRatio: number;
  47813. /**
  47814. * Enforces a fixed size texture to ensure resize independant blur.
  47815. */
  47816. mainTextureFixedSize?: number;
  47817. /**
  47818. * How big is the kernel of the blur texture.
  47819. */
  47820. blurKernelSize: number;
  47821. /**
  47822. * The camera attached to the layer.
  47823. */
  47824. camera: Nullable<Camera>;
  47825. /**
  47826. * Enable MSAA by chosing the number of samples.
  47827. */
  47828. mainTextureSamples?: number;
  47829. /**
  47830. * The rendering group to draw the layer in.
  47831. */
  47832. renderingGroupId: number;
  47833. }
  47834. /**
  47835. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47836. *
  47837. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47838. * glowy meshes to your scene.
  47839. *
  47840. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47841. */
  47842. export class GlowLayer extends EffectLayer {
  47843. /**
  47844. * Effect Name of the layer.
  47845. */
  47846. static readonly EffectName: string;
  47847. /**
  47848. * The default blur kernel size used for the glow.
  47849. */
  47850. static DefaultBlurKernelSize: number;
  47851. /**
  47852. * The default texture size ratio used for the glow.
  47853. */
  47854. static DefaultTextureRatio: number;
  47855. /**
  47856. * Sets the kernel size of the blur.
  47857. */
  47858. /**
  47859. * Gets the kernel size of the blur.
  47860. */
  47861. blurKernelSize: number;
  47862. /**
  47863. * Sets the glow intensity.
  47864. */
  47865. /**
  47866. * Gets the glow intensity.
  47867. */
  47868. intensity: number;
  47869. private _options;
  47870. private _intensity;
  47871. private _horizontalBlurPostprocess1;
  47872. private _verticalBlurPostprocess1;
  47873. private _horizontalBlurPostprocess2;
  47874. private _verticalBlurPostprocess2;
  47875. private _blurTexture1;
  47876. private _blurTexture2;
  47877. private _postProcesses1;
  47878. private _postProcesses2;
  47879. private _includedOnlyMeshes;
  47880. private _excludedMeshes;
  47881. /**
  47882. * Callback used to let the user override the color selection on a per mesh basis
  47883. */
  47884. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47885. /**
  47886. * Callback used to let the user override the texture selection on a per mesh basis
  47887. */
  47888. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47889. /**
  47890. * Instantiates a new glow Layer and references it to the scene.
  47891. * @param name The name of the layer
  47892. * @param scene The scene to use the layer in
  47893. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47894. */
  47895. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47896. /**
  47897. * Get the effect name of the layer.
  47898. * @return The effect name
  47899. */
  47900. getEffectName(): string;
  47901. /**
  47902. * Create the merge effect. This is the shader use to blit the information back
  47903. * to the main canvas at the end of the scene rendering.
  47904. */
  47905. protected _createMergeEffect(): Effect;
  47906. /**
  47907. * Creates the render target textures and post processes used in the glow layer.
  47908. */
  47909. protected _createTextureAndPostProcesses(): void;
  47910. /**
  47911. * Checks for the readiness of the element composing the layer.
  47912. * @param subMesh the mesh to check for
  47913. * @param useInstances specify wether or not to use instances to render the mesh
  47914. * @param emissiveTexture the associated emissive texture used to generate the glow
  47915. * @return true if ready otherwise, false
  47916. */
  47917. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47918. /**
  47919. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47920. */
  47921. needStencil(): boolean;
  47922. /**
  47923. * Returns true if the mesh can be rendered, otherwise false.
  47924. * @param mesh The mesh to render
  47925. * @param material The material used on the mesh
  47926. * @returns true if it can be rendered otherwise false
  47927. */
  47928. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47929. /**
  47930. * Implementation specific of rendering the generating effect on the main canvas.
  47931. * @param effect The effect used to render through
  47932. */
  47933. protected _internalRender(effect: Effect): void;
  47934. /**
  47935. * Sets the required values for both the emissive texture and and the main color.
  47936. */
  47937. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47938. /**
  47939. * Returns true if the mesh should render, otherwise false.
  47940. * @param mesh The mesh to render
  47941. * @returns true if it should render otherwise false
  47942. */
  47943. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47944. /**
  47945. * Adds specific effects defines.
  47946. * @param defines The defines to add specifics to.
  47947. */
  47948. protected _addCustomEffectDefines(defines: string[]): void;
  47949. /**
  47950. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47951. * @param mesh The mesh to exclude from the glow layer
  47952. */
  47953. addExcludedMesh(mesh: Mesh): void;
  47954. /**
  47955. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47956. * @param mesh The mesh to remove
  47957. */
  47958. removeExcludedMesh(mesh: Mesh): void;
  47959. /**
  47960. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47961. * @param mesh The mesh to include in the glow layer
  47962. */
  47963. addIncludedOnlyMesh(mesh: Mesh): void;
  47964. /**
  47965. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47966. * @param mesh The mesh to remove
  47967. */
  47968. removeIncludedOnlyMesh(mesh: Mesh): void;
  47969. /**
  47970. * Determine if a given mesh will be used in the glow layer
  47971. * @param mesh The mesh to test
  47972. * @returns true if the mesh will be highlighted by the current glow layer
  47973. */
  47974. hasMesh(mesh: AbstractMesh): boolean;
  47975. /**
  47976. * Free any resources and references associated to a mesh.
  47977. * Internal use
  47978. * @param mesh The mesh to free.
  47979. * @hidden
  47980. */
  47981. _disposeMesh(mesh: Mesh): void;
  47982. /**
  47983. * Gets the class name of the effect layer
  47984. * @returns the string with the class name of the effect layer
  47985. */
  47986. getClassName(): string;
  47987. /**
  47988. * Serializes this glow layer
  47989. * @returns a serialized glow layer object
  47990. */
  47991. serialize(): any;
  47992. /**
  47993. * Creates a Glow Layer from parsed glow layer data
  47994. * @param parsedGlowLayer defines glow layer data
  47995. * @param scene defines the current scene
  47996. * @param rootUrl defines the root URL containing the glow layer information
  47997. * @returns a parsed Glow Layer
  47998. */
  47999. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48000. }
  48001. }
  48002. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48003. /** @hidden */
  48004. export var glowBlurPostProcessPixelShader: {
  48005. name: string;
  48006. shader: string;
  48007. };
  48008. }
  48009. declare module "babylonjs/Layers/highlightLayer" {
  48010. import { Observable } from "babylonjs/Misc/observable";
  48011. import { Nullable } from "babylonjs/types";
  48012. import { Camera } from "babylonjs/Cameras/camera";
  48013. import { Scene } from "babylonjs/scene";
  48014. import { Color3, Color4 } from "babylonjs/Maths/math";
  48015. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48017. import { Mesh } from "babylonjs/Meshes/mesh";
  48018. import { Effect } from "babylonjs/Materials/effect";
  48019. import { Material } from "babylonjs/Materials/material";
  48020. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48021. import "babylonjs/Shaders/glowMapMerge.fragment";
  48022. import "babylonjs/Shaders/glowMapMerge.vertex";
  48023. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48024. module "babylonjs/abstractScene" {
  48025. interface AbstractScene {
  48026. /**
  48027. * Return a the first highlight layer of the scene with a given name.
  48028. * @param name The name of the highlight layer to look for.
  48029. * @return The highlight layer if found otherwise null.
  48030. */
  48031. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48032. }
  48033. }
  48034. /**
  48035. * Highlight layer options. This helps customizing the behaviour
  48036. * of the highlight layer.
  48037. */
  48038. export interface IHighlightLayerOptions {
  48039. /**
  48040. * Multiplication factor apply to the canvas size to compute the render target size
  48041. * used to generated the glowing objects (the smaller the faster).
  48042. */
  48043. mainTextureRatio: number;
  48044. /**
  48045. * Enforces a fixed size texture to ensure resize independant blur.
  48046. */
  48047. mainTextureFixedSize?: number;
  48048. /**
  48049. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48050. * of the picture to blur (the smaller the faster).
  48051. */
  48052. blurTextureSizeRatio: number;
  48053. /**
  48054. * How big in texel of the blur texture is the vertical blur.
  48055. */
  48056. blurVerticalSize: number;
  48057. /**
  48058. * How big in texel of the blur texture is the horizontal blur.
  48059. */
  48060. blurHorizontalSize: number;
  48061. /**
  48062. * Alpha blending mode used to apply the blur. Default is combine.
  48063. */
  48064. alphaBlendingMode: number;
  48065. /**
  48066. * The camera attached to the layer.
  48067. */
  48068. camera: Nullable<Camera>;
  48069. /**
  48070. * Should we display highlight as a solid stroke?
  48071. */
  48072. isStroke?: boolean;
  48073. /**
  48074. * The rendering group to draw the layer in.
  48075. */
  48076. renderingGroupId: number;
  48077. }
  48078. /**
  48079. * The highlight layer Helps adding a glow effect around a mesh.
  48080. *
  48081. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48082. * glowy meshes to your scene.
  48083. *
  48084. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48085. */
  48086. export class HighlightLayer extends EffectLayer {
  48087. name: string;
  48088. /**
  48089. * Effect Name of the highlight layer.
  48090. */
  48091. static readonly EffectName: string;
  48092. /**
  48093. * The neutral color used during the preparation of the glow effect.
  48094. * This is black by default as the blend operation is a blend operation.
  48095. */
  48096. static NeutralColor: Color4;
  48097. /**
  48098. * Stencil value used for glowing meshes.
  48099. */
  48100. static GlowingMeshStencilReference: number;
  48101. /**
  48102. * Stencil value used for the other meshes in the scene.
  48103. */
  48104. static NormalMeshStencilReference: number;
  48105. /**
  48106. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48107. */
  48108. innerGlow: boolean;
  48109. /**
  48110. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48111. */
  48112. outerGlow: boolean;
  48113. /**
  48114. * Specifies the horizontal size of the blur.
  48115. */
  48116. /**
  48117. * Gets the horizontal size of the blur.
  48118. */
  48119. blurHorizontalSize: number;
  48120. /**
  48121. * Specifies the vertical size of the blur.
  48122. */
  48123. /**
  48124. * Gets the vertical size of the blur.
  48125. */
  48126. blurVerticalSize: number;
  48127. /**
  48128. * An event triggered when the highlight layer is being blurred.
  48129. */
  48130. onBeforeBlurObservable: Observable<HighlightLayer>;
  48131. /**
  48132. * An event triggered when the highlight layer has been blurred.
  48133. */
  48134. onAfterBlurObservable: Observable<HighlightLayer>;
  48135. private _instanceGlowingMeshStencilReference;
  48136. private _options;
  48137. private _downSamplePostprocess;
  48138. private _horizontalBlurPostprocess;
  48139. private _verticalBlurPostprocess;
  48140. private _blurTexture;
  48141. private _meshes;
  48142. private _excludedMeshes;
  48143. /**
  48144. * Instantiates a new highlight Layer and references it to the scene..
  48145. * @param name The name of the layer
  48146. * @param scene The scene to use the layer in
  48147. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48148. */
  48149. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48150. /**
  48151. * Get the effect name of the layer.
  48152. * @return The effect name
  48153. */
  48154. getEffectName(): string;
  48155. /**
  48156. * Create the merge effect. This is the shader use to blit the information back
  48157. * to the main canvas at the end of the scene rendering.
  48158. */
  48159. protected _createMergeEffect(): Effect;
  48160. /**
  48161. * Creates the render target textures and post processes used in the highlight layer.
  48162. */
  48163. protected _createTextureAndPostProcesses(): void;
  48164. /**
  48165. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48166. */
  48167. needStencil(): boolean;
  48168. /**
  48169. * Checks for the readiness of the element composing the layer.
  48170. * @param subMesh the mesh to check for
  48171. * @param useInstances specify wether or not to use instances to render the mesh
  48172. * @param emissiveTexture the associated emissive texture used to generate the glow
  48173. * @return true if ready otherwise, false
  48174. */
  48175. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48176. /**
  48177. * Implementation specific of rendering the generating effect on the main canvas.
  48178. * @param effect The effect used to render through
  48179. */
  48180. protected _internalRender(effect: Effect): void;
  48181. /**
  48182. * Returns true if the layer contains information to display, otherwise false.
  48183. */
  48184. shouldRender(): boolean;
  48185. /**
  48186. * Returns true if the mesh should render, otherwise false.
  48187. * @param mesh The mesh to render
  48188. * @returns true if it should render otherwise false
  48189. */
  48190. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48191. /**
  48192. * Sets the required values for both the emissive texture and and the main color.
  48193. */
  48194. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48195. /**
  48196. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48197. * @param mesh The mesh to exclude from the highlight layer
  48198. */
  48199. addExcludedMesh(mesh: Mesh): void;
  48200. /**
  48201. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48202. * @param mesh The mesh to highlight
  48203. */
  48204. removeExcludedMesh(mesh: Mesh): void;
  48205. /**
  48206. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48207. * @param mesh mesh to test
  48208. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48209. */
  48210. hasMesh(mesh: AbstractMesh): boolean;
  48211. /**
  48212. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48213. * @param mesh The mesh to highlight
  48214. * @param color The color of the highlight
  48215. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48216. */
  48217. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48218. /**
  48219. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48220. * @param mesh The mesh to highlight
  48221. */
  48222. removeMesh(mesh: Mesh): void;
  48223. /**
  48224. * Force the stencil to the normal expected value for none glowing parts
  48225. */
  48226. private _defaultStencilReference;
  48227. /**
  48228. * Free any resources and references associated to a mesh.
  48229. * Internal use
  48230. * @param mesh The mesh to free.
  48231. * @hidden
  48232. */
  48233. _disposeMesh(mesh: Mesh): void;
  48234. /**
  48235. * Dispose the highlight layer and free resources.
  48236. */
  48237. dispose(): void;
  48238. /**
  48239. * Gets the class name of the effect layer
  48240. * @returns the string with the class name of the effect layer
  48241. */
  48242. getClassName(): string;
  48243. /**
  48244. * Serializes this Highlight layer
  48245. * @returns a serialized Highlight layer object
  48246. */
  48247. serialize(): any;
  48248. /**
  48249. * Creates a Highlight layer from parsed Highlight layer data
  48250. * @param parsedHightlightLayer defines the Highlight layer data
  48251. * @param scene defines the current scene
  48252. * @param rootUrl defines the root URL containing the Highlight layer information
  48253. * @returns a parsed Highlight layer
  48254. */
  48255. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48256. }
  48257. }
  48258. declare module "babylonjs/Layers/index" {
  48259. export * from "babylonjs/Layers/effectLayer";
  48260. export * from "babylonjs/Layers/effectLayerSceneComponent";
  48261. export * from "babylonjs/Layers/glowLayer";
  48262. export * from "babylonjs/Layers/highlightLayer";
  48263. export * from "babylonjs/Layers/layer";
  48264. export * from "babylonjs/Layers/layerSceneComponent";
  48265. }
  48266. declare module "babylonjs/Shaders/lensFlare.fragment" {
  48267. /** @hidden */
  48268. export var lensFlarePixelShader: {
  48269. name: string;
  48270. shader: string;
  48271. };
  48272. }
  48273. declare module "babylonjs/Shaders/lensFlare.vertex" {
  48274. /** @hidden */
  48275. export var lensFlareVertexShader: {
  48276. name: string;
  48277. shader: string;
  48278. };
  48279. }
  48280. declare module "babylonjs/LensFlares/lensFlareSystem" {
  48281. import { Scene } from "babylonjs/scene";
  48282. import { Vector3, Viewport } from "babylonjs/Maths/math";
  48283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48284. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  48285. import "babylonjs/Shaders/lensFlare.fragment";
  48286. import "babylonjs/Shaders/lensFlare.vertex";
  48287. /**
  48288. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48289. * It is usually composed of several `lensFlare`.
  48290. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48291. */
  48292. export class LensFlareSystem {
  48293. /**
  48294. * Define the name of the lens flare system
  48295. */
  48296. name: string;
  48297. /**
  48298. * List of lens flares used in this system.
  48299. */
  48300. lensFlares: LensFlare[];
  48301. /**
  48302. * Define a limit from the border the lens flare can be visible.
  48303. */
  48304. borderLimit: number;
  48305. /**
  48306. * Define a viewport border we do not want to see the lens flare in.
  48307. */
  48308. viewportBorder: number;
  48309. /**
  48310. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48311. */
  48312. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48313. /**
  48314. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48315. */
  48316. layerMask: number;
  48317. /**
  48318. * Define the id of the lens flare system in the scene.
  48319. * (equal to name by default)
  48320. */
  48321. id: string;
  48322. private _scene;
  48323. private _emitter;
  48324. private _vertexBuffers;
  48325. private _indexBuffer;
  48326. private _effect;
  48327. private _positionX;
  48328. private _positionY;
  48329. private _isEnabled;
  48330. /** @hidden */
  48331. static _SceneComponentInitialization: (scene: Scene) => void;
  48332. /**
  48333. * Instantiates a lens flare system.
  48334. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48335. * It is usually composed of several `lensFlare`.
  48336. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48337. * @param name Define the name of the lens flare system in the scene
  48338. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48339. * @param scene Define the scene the lens flare system belongs to
  48340. */
  48341. constructor(
  48342. /**
  48343. * Define the name of the lens flare system
  48344. */
  48345. name: string, emitter: any, scene: Scene);
  48346. /**
  48347. * Define if the lens flare system is enabled.
  48348. */
  48349. isEnabled: boolean;
  48350. /**
  48351. * Get the scene the effects belongs to.
  48352. * @returns the scene holding the lens flare system
  48353. */
  48354. getScene(): Scene;
  48355. /**
  48356. * Get the emitter of the lens flare system.
  48357. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48358. * @returns the emitter of the lens flare system
  48359. */
  48360. getEmitter(): any;
  48361. /**
  48362. * Set the emitter of the lens flare system.
  48363. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48364. * @param newEmitter Define the new emitter of the system
  48365. */
  48366. setEmitter(newEmitter: any): void;
  48367. /**
  48368. * Get the lens flare system emitter position.
  48369. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48370. * @returns the position
  48371. */
  48372. getEmitterPosition(): Vector3;
  48373. /**
  48374. * @hidden
  48375. */
  48376. computeEffectivePosition(globalViewport: Viewport): boolean;
  48377. /** @hidden */
  48378. _isVisible(): boolean;
  48379. /**
  48380. * @hidden
  48381. */
  48382. render(): boolean;
  48383. /**
  48384. * Dispose and release the lens flare with its associated resources.
  48385. */
  48386. dispose(): void;
  48387. /**
  48388. * Parse a lens flare system from a JSON repressentation
  48389. * @param parsedLensFlareSystem Define the JSON to parse
  48390. * @param scene Define the scene the parsed system should be instantiated in
  48391. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48392. * @returns the parsed system
  48393. */
  48394. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48395. /**
  48396. * Serialize the current Lens Flare System into a JSON representation.
  48397. * @returns the serialized JSON
  48398. */
  48399. serialize(): any;
  48400. }
  48401. }
  48402. declare module "babylonjs/LensFlares/lensFlare" {
  48403. import { Nullable } from "babylonjs/types";
  48404. import { Color3 } from "babylonjs/Maths/math";
  48405. import { Texture } from "babylonjs/Materials/Textures/texture";
  48406. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48407. /**
  48408. * This represents one of the lens effect in a `lensFlareSystem`.
  48409. * It controls one of the indiviual texture used in the effect.
  48410. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48411. */
  48412. export class LensFlare {
  48413. /**
  48414. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48415. */
  48416. size: number;
  48417. /**
  48418. * 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.
  48419. */
  48420. position: number;
  48421. /**
  48422. * Define the lens color.
  48423. */
  48424. color: Color3;
  48425. /**
  48426. * Define the lens texture.
  48427. */
  48428. texture: Nullable<Texture>;
  48429. /**
  48430. * Define the alpha mode to render this particular lens.
  48431. */
  48432. alphaMode: number;
  48433. private _system;
  48434. /**
  48435. * Creates a new Lens Flare.
  48436. * This represents one of the lens effect in a `lensFlareSystem`.
  48437. * It controls one of the indiviual texture used in the effect.
  48438. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48439. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48440. * @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.
  48441. * @param color Define the lens color
  48442. * @param imgUrl Define the lens texture url
  48443. * @param system Define the `lensFlareSystem` this flare is part of
  48444. * @returns The newly created Lens Flare
  48445. */
  48446. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48447. /**
  48448. * Instantiates a new Lens Flare.
  48449. * This represents one of the lens effect in a `lensFlareSystem`.
  48450. * It controls one of the indiviual texture used in the effect.
  48451. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48452. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48453. * @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.
  48454. * @param color Define the lens color
  48455. * @param imgUrl Define the lens texture url
  48456. * @param system Define the `lensFlareSystem` this flare is part of
  48457. */
  48458. constructor(
  48459. /**
  48460. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48461. */
  48462. size: number,
  48463. /**
  48464. * 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.
  48465. */
  48466. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48467. /**
  48468. * Dispose and release the lens flare with its associated resources.
  48469. */
  48470. dispose(): void;
  48471. }
  48472. }
  48473. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  48474. import { Nullable } from "babylonjs/types";
  48475. import { Scene } from "babylonjs/scene";
  48476. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48477. import { AbstractScene } from "babylonjs/abstractScene";
  48478. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48479. module "babylonjs/abstractScene" {
  48480. interface AbstractScene {
  48481. /**
  48482. * The list of lens flare system added to the scene
  48483. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48484. */
  48485. lensFlareSystems: Array<LensFlareSystem>;
  48486. /**
  48487. * Removes the given lens flare system from this scene.
  48488. * @param toRemove The lens flare system to remove
  48489. * @returns The index of the removed lens flare system
  48490. */
  48491. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48492. /**
  48493. * Adds the given lens flare system to this scene
  48494. * @param newLensFlareSystem The lens flare system to add
  48495. */
  48496. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48497. /**
  48498. * Gets a lens flare system using its name
  48499. * @param name defines the name to look for
  48500. * @returns the lens flare system or null if not found
  48501. */
  48502. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48503. /**
  48504. * Gets a lens flare system using its id
  48505. * @param id defines the id to look for
  48506. * @returns the lens flare system or null if not found
  48507. */
  48508. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48509. }
  48510. }
  48511. /**
  48512. * Defines the lens flare scene component responsible to manage any lens flares
  48513. * in a given scene.
  48514. */
  48515. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48516. /**
  48517. * The component name helpfull to identify the component in the list of scene components.
  48518. */
  48519. readonly name: string;
  48520. /**
  48521. * The scene the component belongs to.
  48522. */
  48523. scene: Scene;
  48524. /**
  48525. * Creates a new instance of the component for the given scene
  48526. * @param scene Defines the scene to register the component in
  48527. */
  48528. constructor(scene: Scene);
  48529. /**
  48530. * Registers the component in a given scene
  48531. */
  48532. register(): void;
  48533. /**
  48534. * Rebuilds the elements related to this component in case of
  48535. * context lost for instance.
  48536. */
  48537. rebuild(): void;
  48538. /**
  48539. * Adds all the element from the container to the scene
  48540. * @param container the container holding the elements
  48541. */
  48542. addFromContainer(container: AbstractScene): void;
  48543. /**
  48544. * Removes all the elements in the container from the scene
  48545. * @param container contains the elements to remove
  48546. * @param dispose if the removed element should be disposed (default: false)
  48547. */
  48548. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48549. /**
  48550. * Serializes the component data to the specified json object
  48551. * @param serializationObject The object to serialize to
  48552. */
  48553. serialize(serializationObject: any): void;
  48554. /**
  48555. * Disposes the component and the associated ressources.
  48556. */
  48557. dispose(): void;
  48558. private _draw;
  48559. }
  48560. }
  48561. declare module "babylonjs/LensFlares/index" {
  48562. export * from "babylonjs/LensFlares/lensFlare";
  48563. export * from "babylonjs/LensFlares/lensFlareSystem";
  48564. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48565. }
  48566. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48567. import { Scene } from "babylonjs/scene";
  48568. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48569. import { AbstractScene } from "babylonjs/abstractScene";
  48570. /**
  48571. * Defines the shadow generator component responsible to manage any shadow generators
  48572. * in a given scene.
  48573. */
  48574. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48575. /**
  48576. * The component name helpfull to identify the component in the list of scene components.
  48577. */
  48578. readonly name: string;
  48579. /**
  48580. * The scene the component belongs to.
  48581. */
  48582. scene: Scene;
  48583. /**
  48584. * Creates a new instance of the component for the given scene
  48585. * @param scene Defines the scene to register the component in
  48586. */
  48587. constructor(scene: Scene);
  48588. /**
  48589. * Registers the component in a given scene
  48590. */
  48591. register(): void;
  48592. /**
  48593. * Rebuilds the elements related to this component in case of
  48594. * context lost for instance.
  48595. */
  48596. rebuild(): void;
  48597. /**
  48598. * Serializes the component data to the specified json object
  48599. * @param serializationObject The object to serialize to
  48600. */
  48601. serialize(serializationObject: any): void;
  48602. /**
  48603. * Adds all the element from the container to the scene
  48604. * @param container the container holding the elements
  48605. */
  48606. addFromContainer(container: AbstractScene): void;
  48607. /**
  48608. * Removes all the elements in the container from the scene
  48609. * @param container contains the elements to remove
  48610. * @param dispose if the removed element should be disposed (default: false)
  48611. */
  48612. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48613. /**
  48614. * Rebuilds the elements related to this component in case of
  48615. * context lost for instance.
  48616. */
  48617. dispose(): void;
  48618. private _gatherRenderTargets;
  48619. }
  48620. }
  48621. declare module "babylonjs/Lights/Shadows/index" {
  48622. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48623. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48624. }
  48625. declare module "babylonjs/Lights/directionalLight" {
  48626. import { Camera } from "babylonjs/Cameras/camera";
  48627. import { Scene } from "babylonjs/scene";
  48628. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48630. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48631. import { Effect } from "babylonjs/Materials/effect";
  48632. /**
  48633. * A directional light is defined by a direction (what a surprise!).
  48634. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48635. * 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.
  48636. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48637. */
  48638. export class DirectionalLight extends ShadowLight {
  48639. private _shadowFrustumSize;
  48640. /**
  48641. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48642. */
  48643. /**
  48644. * Specifies a fix frustum size for the shadow generation.
  48645. */
  48646. shadowFrustumSize: number;
  48647. private _shadowOrthoScale;
  48648. /**
  48649. * Gets the shadow projection scale against the optimal computed one.
  48650. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48651. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48652. */
  48653. /**
  48654. * Sets the shadow projection scale against the optimal computed one.
  48655. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48656. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48657. */
  48658. shadowOrthoScale: number;
  48659. /**
  48660. * Automatically compute the projection matrix to best fit (including all the casters)
  48661. * on each frame.
  48662. */
  48663. autoUpdateExtends: boolean;
  48664. private _orthoLeft;
  48665. private _orthoRight;
  48666. private _orthoTop;
  48667. private _orthoBottom;
  48668. /**
  48669. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48670. * The directional light is emitted from everywhere in the given direction.
  48671. * It can cast shadows.
  48672. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48673. * @param name The friendly name of the light
  48674. * @param direction The direction of the light
  48675. * @param scene The scene the light belongs to
  48676. */
  48677. constructor(name: string, direction: Vector3, scene: Scene);
  48678. /**
  48679. * Returns the string "DirectionalLight".
  48680. * @return The class name
  48681. */
  48682. getClassName(): string;
  48683. /**
  48684. * Returns the integer 1.
  48685. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48686. */
  48687. getTypeID(): number;
  48688. /**
  48689. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48690. * Returns the DirectionalLight Shadow projection matrix.
  48691. */
  48692. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48693. /**
  48694. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48695. * Returns the DirectionalLight Shadow projection matrix.
  48696. */
  48697. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48698. /**
  48699. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48700. * Returns the DirectionalLight Shadow projection matrix.
  48701. */
  48702. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48703. protected _buildUniformLayout(): void;
  48704. /**
  48705. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48706. * @param effect The effect to update
  48707. * @param lightIndex The index of the light in the effect to update
  48708. * @returns The directional light
  48709. */
  48710. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48711. /**
  48712. * Gets the minZ used for shadow according to both the scene and the light.
  48713. *
  48714. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48715. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48716. * @param activeCamera The camera we are returning the min for
  48717. * @returns the depth min z
  48718. */
  48719. getDepthMinZ(activeCamera: Camera): number;
  48720. /**
  48721. * Gets the maxZ used for shadow according to both the scene and the light.
  48722. *
  48723. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48724. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48725. * @param activeCamera The camera we are returning the max for
  48726. * @returns the depth max z
  48727. */
  48728. getDepthMaxZ(activeCamera: Camera): number;
  48729. /**
  48730. * Prepares the list of defines specific to the light type.
  48731. * @param defines the list of defines
  48732. * @param lightIndex defines the index of the light for the effect
  48733. */
  48734. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48735. }
  48736. }
  48737. declare module "babylonjs/Lights/pointLight" {
  48738. import { Scene } from "babylonjs/scene";
  48739. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48741. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48742. import { Effect } from "babylonjs/Materials/effect";
  48743. /**
  48744. * A point light is a light defined by an unique point in world space.
  48745. * The light is emitted in every direction from this point.
  48746. * A good example of a point light is a standard light bulb.
  48747. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48748. */
  48749. export class PointLight extends ShadowLight {
  48750. private _shadowAngle;
  48751. /**
  48752. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48753. * This specifies what angle the shadow will use to be created.
  48754. *
  48755. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48756. */
  48757. /**
  48758. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48759. * This specifies what angle the shadow will use to be created.
  48760. *
  48761. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48762. */
  48763. shadowAngle: number;
  48764. /**
  48765. * Gets the direction if it has been set.
  48766. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48767. */
  48768. /**
  48769. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48770. */
  48771. direction: Vector3;
  48772. /**
  48773. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48774. * A PointLight emits the light in every direction.
  48775. * It can cast shadows.
  48776. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48777. * ```javascript
  48778. * var pointLight = new PointLight("pl", camera.position, scene);
  48779. * ```
  48780. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48781. * @param name The light friendly name
  48782. * @param position The position of the point light in the scene
  48783. * @param scene The scene the lights belongs to
  48784. */
  48785. constructor(name: string, position: Vector3, scene: Scene);
  48786. /**
  48787. * Returns the string "PointLight"
  48788. * @returns the class name
  48789. */
  48790. getClassName(): string;
  48791. /**
  48792. * Returns the integer 0.
  48793. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48794. */
  48795. getTypeID(): number;
  48796. /**
  48797. * Specifies wether or not the shadowmap should be a cube texture.
  48798. * @returns true if the shadowmap needs to be a cube texture.
  48799. */
  48800. needCube(): boolean;
  48801. /**
  48802. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48803. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48804. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48805. */
  48806. getShadowDirection(faceIndex?: number): Vector3;
  48807. /**
  48808. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48809. * - fov = PI / 2
  48810. * - aspect ratio : 1.0
  48811. * - z-near and far equal to the active camera minZ and maxZ.
  48812. * Returns the PointLight.
  48813. */
  48814. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48815. protected _buildUniformLayout(): void;
  48816. /**
  48817. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48818. * @param effect The effect to update
  48819. * @param lightIndex The index of the light in the effect to update
  48820. * @returns The point light
  48821. */
  48822. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48823. /**
  48824. * Prepares the list of defines specific to the light type.
  48825. * @param defines the list of defines
  48826. * @param lightIndex defines the index of the light for the effect
  48827. */
  48828. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48829. }
  48830. }
  48831. declare module "babylonjs/Lights/spotLight" {
  48832. import { Nullable } from "babylonjs/types";
  48833. import { Scene } from "babylonjs/scene";
  48834. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48836. import { Effect } from "babylonjs/Materials/effect";
  48837. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48838. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48839. /**
  48840. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48841. * These values define a cone of light starting from the position, emitting toward the direction.
  48842. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48843. * and the exponent defines the speed of the decay of the light with distance (reach).
  48844. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48845. */
  48846. export class SpotLight extends ShadowLight {
  48847. private _angle;
  48848. private _innerAngle;
  48849. private _cosHalfAngle;
  48850. private _lightAngleScale;
  48851. private _lightAngleOffset;
  48852. /**
  48853. * Gets the cone angle of the spot light in Radians.
  48854. */
  48855. /**
  48856. * Sets the cone angle of the spot light in Radians.
  48857. */
  48858. angle: number;
  48859. /**
  48860. * Only used in gltf falloff mode, this defines the angle where
  48861. * the directional falloff will start before cutting at angle which could be seen
  48862. * as outer angle.
  48863. */
  48864. /**
  48865. * Only used in gltf falloff mode, this defines the angle where
  48866. * the directional falloff will start before cutting at angle which could be seen
  48867. * as outer angle.
  48868. */
  48869. innerAngle: number;
  48870. private _shadowAngleScale;
  48871. /**
  48872. * Allows scaling the angle of the light for shadow generation only.
  48873. */
  48874. /**
  48875. * Allows scaling the angle of the light for shadow generation only.
  48876. */
  48877. shadowAngleScale: number;
  48878. /**
  48879. * The light decay speed with the distance from the emission spot.
  48880. */
  48881. exponent: number;
  48882. private _projectionTextureMatrix;
  48883. /**
  48884. * Allows reading the projecton texture
  48885. */
  48886. readonly projectionTextureMatrix: Matrix;
  48887. protected _projectionTextureLightNear: number;
  48888. /**
  48889. * Gets the near clip of the Spotlight for texture projection.
  48890. */
  48891. /**
  48892. * Sets the near clip of the Spotlight for texture projection.
  48893. */
  48894. projectionTextureLightNear: number;
  48895. protected _projectionTextureLightFar: number;
  48896. /**
  48897. * Gets the far clip of the Spotlight for texture projection.
  48898. */
  48899. /**
  48900. * Sets the far clip of the Spotlight for texture projection.
  48901. */
  48902. projectionTextureLightFar: number;
  48903. protected _projectionTextureUpDirection: Vector3;
  48904. /**
  48905. * Gets the Up vector of the Spotlight for texture projection.
  48906. */
  48907. /**
  48908. * Sets the Up vector of the Spotlight for texture projection.
  48909. */
  48910. projectionTextureUpDirection: Vector3;
  48911. private _projectionTexture;
  48912. /**
  48913. * Gets the projection texture of the light.
  48914. */
  48915. /**
  48916. * Sets the projection texture of the light.
  48917. */
  48918. projectionTexture: Nullable<BaseTexture>;
  48919. private _projectionTextureViewLightDirty;
  48920. private _projectionTextureProjectionLightDirty;
  48921. private _projectionTextureDirty;
  48922. private _projectionTextureViewTargetVector;
  48923. private _projectionTextureViewLightMatrix;
  48924. private _projectionTextureProjectionLightMatrix;
  48925. private _projectionTextureScalingMatrix;
  48926. /**
  48927. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48928. * It can cast shadows.
  48929. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48930. * @param name The light friendly name
  48931. * @param position The position of the spot light in the scene
  48932. * @param direction The direction of the light in the scene
  48933. * @param angle The cone angle of the light in Radians
  48934. * @param exponent The light decay speed with the distance from the emission spot
  48935. * @param scene The scene the lights belongs to
  48936. */
  48937. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48938. /**
  48939. * Returns the string "SpotLight".
  48940. * @returns the class name
  48941. */
  48942. getClassName(): string;
  48943. /**
  48944. * Returns the integer 2.
  48945. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48946. */
  48947. getTypeID(): number;
  48948. /**
  48949. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48950. */
  48951. protected _setDirection(value: Vector3): void;
  48952. /**
  48953. * Overrides the position setter to recompute the projection texture view light Matrix.
  48954. */
  48955. protected _setPosition(value: Vector3): void;
  48956. /**
  48957. * 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.
  48958. * Returns the SpotLight.
  48959. */
  48960. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48961. protected _computeProjectionTextureViewLightMatrix(): void;
  48962. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48963. /**
  48964. * Main function for light texture projection matrix computing.
  48965. */
  48966. protected _computeProjectionTextureMatrix(): void;
  48967. protected _buildUniformLayout(): void;
  48968. private _computeAngleValues;
  48969. /**
  48970. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48971. * @param effect The effect to update
  48972. * @param lightIndex The index of the light in the effect to update
  48973. * @returns The spot light
  48974. */
  48975. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48976. /**
  48977. * Disposes the light and the associated resources.
  48978. */
  48979. dispose(): void;
  48980. /**
  48981. * Prepares the list of defines specific to the light type.
  48982. * @param defines the list of defines
  48983. * @param lightIndex defines the index of the light for the effect
  48984. */
  48985. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48986. }
  48987. }
  48988. declare module "babylonjs/Lights/index" {
  48989. export * from "babylonjs/Lights/light";
  48990. export * from "babylonjs/Lights/shadowLight";
  48991. export * from "babylonjs/Lights/Shadows/index";
  48992. export * from "babylonjs/Lights/directionalLight";
  48993. export * from "babylonjs/Lights/hemisphericLight";
  48994. export * from "babylonjs/Lights/pointLight";
  48995. export * from "babylonjs/Lights/spotLight";
  48996. }
  48997. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48998. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48999. /**
  49000. * Header information of HDR texture files.
  49001. */
  49002. export interface HDRInfo {
  49003. /**
  49004. * The height of the texture in pixels.
  49005. */
  49006. height: number;
  49007. /**
  49008. * The width of the texture in pixels.
  49009. */
  49010. width: number;
  49011. /**
  49012. * The index of the beginning of the data in the binary file.
  49013. */
  49014. dataPosition: number;
  49015. }
  49016. /**
  49017. * This groups tools to convert HDR texture to native colors array.
  49018. */
  49019. export class HDRTools {
  49020. private static Ldexp;
  49021. private static Rgbe2float;
  49022. private static readStringLine;
  49023. /**
  49024. * Reads header information from an RGBE texture stored in a native array.
  49025. * More information on this format are available here:
  49026. * https://en.wikipedia.org/wiki/RGBE_image_format
  49027. *
  49028. * @param uint8array The binary file stored in native array.
  49029. * @return The header information.
  49030. */
  49031. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49032. /**
  49033. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49034. * This RGBE texture needs to store the information as a panorama.
  49035. *
  49036. * More information on this format are available here:
  49037. * https://en.wikipedia.org/wiki/RGBE_image_format
  49038. *
  49039. * @param buffer The binary file stored in an array buffer.
  49040. * @param size The expected size of the extracted cubemap.
  49041. * @return The Cube Map information.
  49042. */
  49043. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49044. /**
  49045. * Returns the pixels data extracted from an RGBE texture.
  49046. * This pixels will be stored left to right up to down in the R G B order in one array.
  49047. *
  49048. * More information on this format are available here:
  49049. * https://en.wikipedia.org/wiki/RGBE_image_format
  49050. *
  49051. * @param uint8array The binary file stored in an array buffer.
  49052. * @param hdrInfo The header information of the file.
  49053. * @return The pixels data in RGB right to left up to down order.
  49054. */
  49055. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49056. private static RGBE_ReadPixels_RLE;
  49057. }
  49058. }
  49059. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49060. import { Nullable } from "babylonjs/types";
  49061. import { Scene } from "babylonjs/scene";
  49062. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49063. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49064. /**
  49065. * This represents a texture coming from an HDR input.
  49066. *
  49067. * The only supported format is currently panorama picture stored in RGBE format.
  49068. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49069. */
  49070. export class HDRCubeTexture extends BaseTexture {
  49071. private static _facesMapping;
  49072. private _generateHarmonics;
  49073. private _noMipmap;
  49074. private _textureMatrix;
  49075. private _size;
  49076. private _onLoad;
  49077. private _onError;
  49078. /**
  49079. * The texture URL.
  49080. */
  49081. url: string;
  49082. /**
  49083. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49084. */
  49085. coordinatesMode: number;
  49086. protected _isBlocking: boolean;
  49087. /**
  49088. * Sets wether or not the texture is blocking during loading.
  49089. */
  49090. /**
  49091. * Gets wether or not the texture is blocking during loading.
  49092. */
  49093. isBlocking: boolean;
  49094. protected _rotationY: number;
  49095. /**
  49096. * Sets texture matrix rotation angle around Y axis in radians.
  49097. */
  49098. /**
  49099. * Gets texture matrix rotation angle around Y axis radians.
  49100. */
  49101. rotationY: number;
  49102. /**
  49103. * Gets or sets the center of the bounding box associated with the cube texture
  49104. * It must define where the camera used to render the texture was set
  49105. */
  49106. boundingBoxPosition: Vector3;
  49107. private _boundingBoxSize;
  49108. /**
  49109. * Gets or sets the size of the bounding box associated with the cube texture
  49110. * When defined, the cubemap will switch to local mode
  49111. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49112. * @example https://www.babylonjs-playground.com/#RNASML
  49113. */
  49114. boundingBoxSize: Vector3;
  49115. /**
  49116. * Instantiates an HDRTexture from the following parameters.
  49117. *
  49118. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49119. * @param scene The scene the texture will be used in
  49120. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49121. * @param noMipmap Forces to not generate the mipmap if true
  49122. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49123. * @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)
  49124. * @param reserved Reserved flag for internal use.
  49125. */
  49126. 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>);
  49127. /**
  49128. * Get the current class name of the texture useful for serialization or dynamic coding.
  49129. * @returns "HDRCubeTexture"
  49130. */
  49131. getClassName(): string;
  49132. /**
  49133. * Occurs when the file is raw .hdr file.
  49134. */
  49135. private loadTexture;
  49136. clone(): HDRCubeTexture;
  49137. delayLoad(): void;
  49138. /**
  49139. * Get the texture reflection matrix used to rotate/transform the reflection.
  49140. * @returns the reflection matrix
  49141. */
  49142. getReflectionTextureMatrix(): Matrix;
  49143. /**
  49144. * Set the texture reflection matrix used to rotate/transform the reflection.
  49145. * @param value Define the reflection matrix to set
  49146. */
  49147. setReflectionTextureMatrix(value: Matrix): void;
  49148. /**
  49149. * Parses a JSON representation of an HDR Texture in order to create the texture
  49150. * @param parsedTexture Define the JSON representation
  49151. * @param scene Define the scene the texture should be created in
  49152. * @param rootUrl Define the root url in case we need to load relative dependencies
  49153. * @returns the newly created texture after parsing
  49154. */
  49155. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49156. serialize(): any;
  49157. }
  49158. }
  49159. declare module "babylonjs/Physics/physicsEngine" {
  49160. import { Nullable } from "babylonjs/types";
  49161. import { Vector3 } from "babylonjs/Maths/math";
  49162. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49163. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49164. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49165. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49166. /**
  49167. * Class used to control physics engine
  49168. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49169. */
  49170. export class PhysicsEngine implements IPhysicsEngine {
  49171. private _physicsPlugin;
  49172. /**
  49173. * Global value used to control the smallest number supported by the simulation
  49174. */
  49175. static Epsilon: number;
  49176. private _impostors;
  49177. private _joints;
  49178. /**
  49179. * Gets the gravity vector used by the simulation
  49180. */
  49181. gravity: Vector3;
  49182. /**
  49183. * Factory used to create the default physics plugin.
  49184. * @returns The default physics plugin
  49185. */
  49186. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49187. /**
  49188. * Creates a new Physics Engine
  49189. * @param gravity defines the gravity vector used by the simulation
  49190. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49191. */
  49192. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49193. /**
  49194. * Sets the gravity vector used by the simulation
  49195. * @param gravity defines the gravity vector to use
  49196. */
  49197. setGravity(gravity: Vector3): void;
  49198. /**
  49199. * Set the time step of the physics engine.
  49200. * Default is 1/60.
  49201. * To slow it down, enter 1/600 for example.
  49202. * To speed it up, 1/30
  49203. * @param newTimeStep defines the new timestep to apply to this world.
  49204. */
  49205. setTimeStep(newTimeStep?: number): void;
  49206. /**
  49207. * Get the time step of the physics engine.
  49208. * @returns the current time step
  49209. */
  49210. getTimeStep(): number;
  49211. /**
  49212. * Release all resources
  49213. */
  49214. dispose(): void;
  49215. /**
  49216. * Gets the name of the current physics plugin
  49217. * @returns the name of the plugin
  49218. */
  49219. getPhysicsPluginName(): string;
  49220. /**
  49221. * Adding a new impostor for the impostor tracking.
  49222. * This will be done by the impostor itself.
  49223. * @param impostor the impostor to add
  49224. */
  49225. addImpostor(impostor: PhysicsImpostor): void;
  49226. /**
  49227. * Remove an impostor from the engine.
  49228. * This impostor and its mesh will not longer be updated by the physics engine.
  49229. * @param impostor the impostor to remove
  49230. */
  49231. removeImpostor(impostor: PhysicsImpostor): void;
  49232. /**
  49233. * Add a joint to the physics engine
  49234. * @param mainImpostor defines the main impostor to which the joint is added.
  49235. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49236. * @param joint defines the joint that will connect both impostors.
  49237. */
  49238. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49239. /**
  49240. * Removes a joint from the simulation
  49241. * @param mainImpostor defines the impostor used with the joint
  49242. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49243. * @param joint defines the joint to remove
  49244. */
  49245. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49246. /**
  49247. * Called by the scene. No need to call it.
  49248. * @param delta defines the timespam between frames
  49249. */
  49250. _step(delta: number): void;
  49251. /**
  49252. * Gets the current plugin used to run the simulation
  49253. * @returns current plugin
  49254. */
  49255. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49256. /**
  49257. * Gets the list of physic impostors
  49258. * @returns an array of PhysicsImpostor
  49259. */
  49260. getImpostors(): Array<PhysicsImpostor>;
  49261. /**
  49262. * Gets the impostor for a physics enabled object
  49263. * @param object defines the object impersonated by the impostor
  49264. * @returns the PhysicsImpostor or null if not found
  49265. */
  49266. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49267. /**
  49268. * Gets the impostor for a physics body object
  49269. * @param body defines physics body used by the impostor
  49270. * @returns the PhysicsImpostor or null if not found
  49271. */
  49272. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49273. /**
  49274. * Does a raycast in the physics world
  49275. * @param from when should the ray start?
  49276. * @param to when should the ray end?
  49277. * @returns PhysicsRaycastResult
  49278. */
  49279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49280. }
  49281. }
  49282. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49283. import { Nullable } from "babylonjs/types";
  49284. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49286. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49287. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49288. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49289. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49290. /** @hidden */
  49291. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49292. private _useDeltaForWorldStep;
  49293. world: any;
  49294. name: string;
  49295. private _physicsMaterials;
  49296. private _fixedTimeStep;
  49297. private _cannonRaycastResult;
  49298. private _raycastResult;
  49299. BJSCANNON: any;
  49300. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49301. setGravity(gravity: Vector3): void;
  49302. setTimeStep(timeStep: number): void;
  49303. getTimeStep(): number;
  49304. executeStep(delta: number): void;
  49305. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49306. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49307. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49308. private _processChildMeshes;
  49309. removePhysicsBody(impostor: PhysicsImpostor): void;
  49310. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49311. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49312. private _addMaterial;
  49313. private _checkWithEpsilon;
  49314. private _createShape;
  49315. private _createHeightmap;
  49316. private _minus90X;
  49317. private _plus90X;
  49318. private _tmpPosition;
  49319. private _tmpDeltaPosition;
  49320. private _tmpUnityRotation;
  49321. private _updatePhysicsBodyTransformation;
  49322. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49323. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49324. isSupported(): boolean;
  49325. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49326. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49327. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49328. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49329. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49330. getBodyMass(impostor: PhysicsImpostor): number;
  49331. getBodyFriction(impostor: PhysicsImpostor): number;
  49332. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49333. getBodyRestitution(impostor: PhysicsImpostor): number;
  49334. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49335. sleepBody(impostor: PhysicsImpostor): void;
  49336. wakeUpBody(impostor: PhysicsImpostor): void;
  49337. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49338. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49339. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49340. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49341. getRadius(impostor: PhysicsImpostor): number;
  49342. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49343. dispose(): void;
  49344. private _extendNamespace;
  49345. /**
  49346. * Does a raycast in the physics world
  49347. * @param from when should the ray start?
  49348. * @param to when should the ray end?
  49349. * @returns PhysicsRaycastResult
  49350. */
  49351. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49352. }
  49353. }
  49354. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49355. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49356. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49357. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49359. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49360. import { Nullable } from "babylonjs/types";
  49361. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49362. /** @hidden */
  49363. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49364. world: any;
  49365. name: string;
  49366. BJSOIMO: any;
  49367. private _raycastResult;
  49368. constructor(iterations?: number, oimoInjection?: any);
  49369. setGravity(gravity: Vector3): void;
  49370. setTimeStep(timeStep: number): void;
  49371. getTimeStep(): number;
  49372. private _tmpImpostorsArray;
  49373. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49374. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49375. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49376. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49377. private _tmpPositionVector;
  49378. removePhysicsBody(impostor: PhysicsImpostor): void;
  49379. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49380. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49381. isSupported(): boolean;
  49382. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49383. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49384. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49385. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49386. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49387. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49388. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49389. getBodyMass(impostor: PhysicsImpostor): number;
  49390. getBodyFriction(impostor: PhysicsImpostor): number;
  49391. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49392. getBodyRestitution(impostor: PhysicsImpostor): number;
  49393. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49394. sleepBody(impostor: PhysicsImpostor): void;
  49395. wakeUpBody(impostor: PhysicsImpostor): void;
  49396. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49397. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49398. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49399. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49400. getRadius(impostor: PhysicsImpostor): number;
  49401. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49402. dispose(): void;
  49403. /**
  49404. * Does a raycast in the physics world
  49405. * @param from when should the ray start?
  49406. * @param to when should the ray end?
  49407. * @returns PhysicsRaycastResult
  49408. */
  49409. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49410. }
  49411. }
  49412. declare module "babylonjs/Probes/reflectionProbe" {
  49413. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49414. import { Vector3 } from "babylonjs/Maths/math";
  49415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49416. import { Nullable } from "babylonjs/types";
  49417. import { Scene } from "babylonjs/scene";
  49418. module "babylonjs/abstractScene" {
  49419. interface AbstractScene {
  49420. /**
  49421. * The list of reflection probes added to the scene
  49422. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49423. */
  49424. reflectionProbes: Array<ReflectionProbe>;
  49425. /**
  49426. * Removes the given reflection probe from this scene.
  49427. * @param toRemove The reflection probe to remove
  49428. * @returns The index of the removed reflection probe
  49429. */
  49430. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49431. /**
  49432. * Adds the given reflection probe to this scene.
  49433. * @param newReflectionProbe The reflection probe to add
  49434. */
  49435. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49436. }
  49437. }
  49438. /**
  49439. * Class used to generate realtime reflection / refraction cube textures
  49440. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49441. */
  49442. export class ReflectionProbe {
  49443. /** defines the name of the probe */
  49444. name: string;
  49445. private _scene;
  49446. private _renderTargetTexture;
  49447. private _projectionMatrix;
  49448. private _viewMatrix;
  49449. private _target;
  49450. private _add;
  49451. private _attachedMesh;
  49452. private _invertYAxis;
  49453. /** Gets or sets probe position (center of the cube map) */
  49454. position: Vector3;
  49455. /**
  49456. * Creates a new reflection probe
  49457. * @param name defines the name of the probe
  49458. * @param size defines the texture resolution (for each face)
  49459. * @param scene defines the hosting scene
  49460. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49461. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49462. */
  49463. constructor(
  49464. /** defines the name of the probe */
  49465. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49466. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49467. samples: number;
  49468. /** Gets or sets the refresh rate to use (on every frame by default) */
  49469. refreshRate: number;
  49470. /**
  49471. * Gets the hosting scene
  49472. * @returns a Scene
  49473. */
  49474. getScene(): Scene;
  49475. /** Gets the internal CubeTexture used to render to */
  49476. readonly cubeTexture: RenderTargetTexture;
  49477. /** Gets the list of meshes to render */
  49478. readonly renderList: Nullable<AbstractMesh[]>;
  49479. /**
  49480. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49481. * @param mesh defines the mesh to attach to
  49482. */
  49483. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49484. /**
  49485. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49486. * @param renderingGroupId The rendering group id corresponding to its index
  49487. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49488. */
  49489. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49490. /**
  49491. * Clean all associated resources
  49492. */
  49493. dispose(): void;
  49494. /**
  49495. * Converts the reflection probe information to a readable string for debug purpose.
  49496. * @param fullDetails Supports for multiple levels of logging within scene loading
  49497. * @returns the human readable reflection probe info
  49498. */
  49499. toString(fullDetails?: boolean): string;
  49500. /**
  49501. * Get the class name of the relfection probe.
  49502. * @returns "ReflectionProbe"
  49503. */
  49504. getClassName(): string;
  49505. /**
  49506. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49507. * @returns The JSON representation of the texture
  49508. */
  49509. serialize(): any;
  49510. /**
  49511. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49512. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49513. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49514. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49515. * @returns The parsed reflection probe if successful
  49516. */
  49517. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49518. }
  49519. }
  49520. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  49521. /** @hidden */
  49522. export var _BabylonLoaderRegistered: boolean;
  49523. }
  49524. declare module "babylonjs/Loading/Plugins/index" {
  49525. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  49526. }
  49527. declare module "babylonjs/Loading/index" {
  49528. export * from "babylonjs/Loading/loadingScreen";
  49529. export * from "babylonjs/Loading/Plugins/index";
  49530. export * from "babylonjs/Loading/sceneLoader";
  49531. export * from "babylonjs/Loading/sceneLoaderFlags";
  49532. }
  49533. declare module "babylonjs/Materials/Background/index" {
  49534. export * from "babylonjs/Materials/Background/backgroundMaterial";
  49535. }
  49536. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  49537. import { Scene } from "babylonjs/scene";
  49538. import { Color3 } from "babylonjs/Maths/math";
  49539. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49540. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49541. /**
  49542. * The Physically based simple base material of BJS.
  49543. *
  49544. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49545. * It is used as the base class for both the specGloss and metalRough conventions.
  49546. */
  49547. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49548. /**
  49549. * Number of Simultaneous lights allowed on the material.
  49550. */
  49551. maxSimultaneousLights: number;
  49552. /**
  49553. * If sets to true, disables all the lights affecting the material.
  49554. */
  49555. disableLighting: boolean;
  49556. /**
  49557. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49558. */
  49559. environmentTexture: BaseTexture;
  49560. /**
  49561. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49562. */
  49563. invertNormalMapX: boolean;
  49564. /**
  49565. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49566. */
  49567. invertNormalMapY: boolean;
  49568. /**
  49569. * Normal map used in the model.
  49570. */
  49571. normalTexture: BaseTexture;
  49572. /**
  49573. * Emissivie color used to self-illuminate the model.
  49574. */
  49575. emissiveColor: Color3;
  49576. /**
  49577. * Emissivie texture used to self-illuminate the model.
  49578. */
  49579. emissiveTexture: BaseTexture;
  49580. /**
  49581. * Occlusion Channel Strenght.
  49582. */
  49583. occlusionStrength: number;
  49584. /**
  49585. * Occlusion Texture of the material (adding extra occlusion effects).
  49586. */
  49587. occlusionTexture: BaseTexture;
  49588. /**
  49589. * Defines the alpha limits in alpha test mode.
  49590. */
  49591. alphaCutOff: number;
  49592. /**
  49593. * Gets the current double sided mode.
  49594. */
  49595. /**
  49596. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49597. */
  49598. doubleSided: boolean;
  49599. /**
  49600. * Stores the pre-calculated light information of a mesh in a texture.
  49601. */
  49602. lightmapTexture: BaseTexture;
  49603. /**
  49604. * If true, the light map contains occlusion information instead of lighting info.
  49605. */
  49606. useLightmapAsShadowmap: boolean;
  49607. /**
  49608. * Instantiates a new PBRMaterial instance.
  49609. *
  49610. * @param name The material name
  49611. * @param scene The scene the material will be use in.
  49612. */
  49613. constructor(name: string, scene: Scene);
  49614. getClassName(): string;
  49615. }
  49616. }
  49617. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49618. import { Scene } from "babylonjs/scene";
  49619. import { Color3 } from "babylonjs/Maths/math";
  49620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49621. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49622. /**
  49623. * The PBR material of BJS following the metal roughness convention.
  49624. *
  49625. * This fits to the PBR convention in the GLTF definition:
  49626. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49627. */
  49628. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49629. /**
  49630. * The base color has two different interpretations depending on the value of metalness.
  49631. * When the material is a metal, the base color is the specific measured reflectance value
  49632. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49633. * of the material.
  49634. */
  49635. baseColor: Color3;
  49636. /**
  49637. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49638. * well as opacity information in the alpha channel.
  49639. */
  49640. baseTexture: BaseTexture;
  49641. /**
  49642. * Specifies the metallic scalar value of the material.
  49643. * Can also be used to scale the metalness values of the metallic texture.
  49644. */
  49645. metallic: number;
  49646. /**
  49647. * Specifies the roughness scalar value of the material.
  49648. * Can also be used to scale the roughness values of the metallic texture.
  49649. */
  49650. roughness: number;
  49651. /**
  49652. * Texture containing both the metallic value in the B channel and the
  49653. * roughness value in the G channel to keep better precision.
  49654. */
  49655. metallicRoughnessTexture: BaseTexture;
  49656. /**
  49657. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49658. *
  49659. * @param name The material name
  49660. * @param scene The scene the material will be use in.
  49661. */
  49662. constructor(name: string, scene: Scene);
  49663. /**
  49664. * Return the currrent class name of the material.
  49665. */
  49666. getClassName(): string;
  49667. /**
  49668. * Makes a duplicate of the current material.
  49669. * @param name - name to use for the new material.
  49670. */
  49671. clone(name: string): PBRMetallicRoughnessMaterial;
  49672. /**
  49673. * Serialize the material to a parsable JSON object.
  49674. */
  49675. serialize(): any;
  49676. /**
  49677. * Parses a JSON object correponding to the serialize function.
  49678. */
  49679. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49680. }
  49681. }
  49682. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49683. import { Scene } from "babylonjs/scene";
  49684. import { Color3 } from "babylonjs/Maths/math";
  49685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49686. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49687. /**
  49688. * The PBR material of BJS following the specular glossiness convention.
  49689. *
  49690. * This fits to the PBR convention in the GLTF definition:
  49691. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49692. */
  49693. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49694. /**
  49695. * Specifies the diffuse color of the material.
  49696. */
  49697. diffuseColor: Color3;
  49698. /**
  49699. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49700. * channel.
  49701. */
  49702. diffuseTexture: BaseTexture;
  49703. /**
  49704. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49705. */
  49706. specularColor: Color3;
  49707. /**
  49708. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49709. */
  49710. glossiness: number;
  49711. /**
  49712. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49713. */
  49714. specularGlossinessTexture: BaseTexture;
  49715. /**
  49716. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49717. *
  49718. * @param name The material name
  49719. * @param scene The scene the material will be use in.
  49720. */
  49721. constructor(name: string, scene: Scene);
  49722. /**
  49723. * Return the currrent class name of the material.
  49724. */
  49725. getClassName(): string;
  49726. /**
  49727. * Makes a duplicate of the current material.
  49728. * @param name - name to use for the new material.
  49729. */
  49730. clone(name: string): PBRSpecularGlossinessMaterial;
  49731. /**
  49732. * Serialize the material to a parsable JSON object.
  49733. */
  49734. serialize(): any;
  49735. /**
  49736. * Parses a JSON object correponding to the serialize function.
  49737. */
  49738. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49739. }
  49740. }
  49741. declare module "babylonjs/Materials/PBR/index" {
  49742. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49743. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49744. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49745. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49746. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49747. }
  49748. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49749. import { Nullable } from "babylonjs/types";
  49750. import { Scene } from "babylonjs/scene";
  49751. import { Matrix } from "babylonjs/Maths/math";
  49752. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49753. /**
  49754. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49755. * It can help converting any input color in a desired output one. This can then be used to create effects
  49756. * from sepia, black and white to sixties or futuristic rendering...
  49757. *
  49758. * The only supported format is currently 3dl.
  49759. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49760. */
  49761. export class ColorGradingTexture extends BaseTexture {
  49762. /**
  49763. * The current texture matrix. (will always be identity in color grading texture)
  49764. */
  49765. private _textureMatrix;
  49766. /**
  49767. * The texture URL.
  49768. */
  49769. url: string;
  49770. /**
  49771. * Empty line regex stored for GC.
  49772. */
  49773. private static _noneEmptyLineRegex;
  49774. private _engine;
  49775. /**
  49776. * Instantiates a ColorGradingTexture from the following parameters.
  49777. *
  49778. * @param url The location of the color gradind data (currently only supporting 3dl)
  49779. * @param scene The scene the texture will be used in
  49780. */
  49781. constructor(url: string, scene: Scene);
  49782. /**
  49783. * Returns the texture matrix used in most of the material.
  49784. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49785. */
  49786. getTextureMatrix(): Matrix;
  49787. /**
  49788. * Occurs when the file being loaded is a .3dl LUT file.
  49789. */
  49790. private load3dlTexture;
  49791. /**
  49792. * Starts the loading process of the texture.
  49793. */
  49794. private loadTexture;
  49795. /**
  49796. * Clones the color gradind texture.
  49797. */
  49798. clone(): ColorGradingTexture;
  49799. /**
  49800. * Called during delayed load for textures.
  49801. */
  49802. delayLoad(): void;
  49803. /**
  49804. * Parses a color grading texture serialized by Babylon.
  49805. * @param parsedTexture The texture information being parsedTexture
  49806. * @param scene The scene to load the texture in
  49807. * @param rootUrl The root url of the data assets to load
  49808. * @return A color gradind texture
  49809. */
  49810. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49811. /**
  49812. * Serializes the LUT texture to json format.
  49813. */
  49814. serialize(): any;
  49815. }
  49816. }
  49817. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  49818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49819. import { Scene } from "babylonjs/scene";
  49820. import { Nullable } from "babylonjs/types";
  49821. /**
  49822. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49823. */
  49824. export class EquiRectangularCubeTexture extends BaseTexture {
  49825. /** The six faces of the cube. */
  49826. private static _FacesMapping;
  49827. private _noMipmap;
  49828. private _onLoad;
  49829. private _onError;
  49830. /** The size of the cubemap. */
  49831. private _size;
  49832. /** The buffer of the image. */
  49833. private _buffer;
  49834. /** The width of the input image. */
  49835. private _width;
  49836. /** The height of the input image. */
  49837. private _height;
  49838. /** The URL to the image. */
  49839. url: string;
  49840. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49841. coordinatesMode: number;
  49842. /**
  49843. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49844. * @param url The location of the image
  49845. * @param scene The scene the texture will be used in
  49846. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49847. * @param noMipmap Forces to not generate the mipmap if true
  49848. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49849. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49850. * @param onLoad — defines a callback called when texture is loaded
  49851. * @param onError — defines a callback called if there is an error
  49852. */
  49853. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49854. /**
  49855. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49856. */
  49857. private loadImage;
  49858. /**
  49859. * Convert the image buffer into a cubemap and create a CubeTexture.
  49860. */
  49861. private loadTexture;
  49862. /**
  49863. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49864. * @param buffer The ArrayBuffer that should be converted.
  49865. * @returns The buffer as Float32Array.
  49866. */
  49867. private getFloat32ArrayFromArrayBuffer;
  49868. /**
  49869. * Get the current class name of the texture useful for serialization or dynamic coding.
  49870. * @returns "EquiRectangularCubeTexture"
  49871. */
  49872. getClassName(): string;
  49873. /**
  49874. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49875. * @returns A clone of the current EquiRectangularCubeTexture.
  49876. */
  49877. clone(): EquiRectangularCubeTexture;
  49878. }
  49879. }
  49880. declare module "babylonjs/Misc/tga" {
  49881. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49882. /**
  49883. * Based on jsTGALoader - Javascript loader for TGA file
  49884. * By Vincent Thibault
  49885. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49886. */
  49887. export class TGATools {
  49888. private static _TYPE_INDEXED;
  49889. private static _TYPE_RGB;
  49890. private static _TYPE_GREY;
  49891. private static _TYPE_RLE_INDEXED;
  49892. private static _TYPE_RLE_RGB;
  49893. private static _TYPE_RLE_GREY;
  49894. private static _ORIGIN_MASK;
  49895. private static _ORIGIN_SHIFT;
  49896. private static _ORIGIN_BL;
  49897. private static _ORIGIN_BR;
  49898. private static _ORIGIN_UL;
  49899. private static _ORIGIN_UR;
  49900. /**
  49901. * Gets the header of a TGA file
  49902. * @param data defines the TGA data
  49903. * @returns the header
  49904. */
  49905. static GetTGAHeader(data: Uint8Array): any;
  49906. /**
  49907. * Uploads TGA content to a Babylon Texture
  49908. * @hidden
  49909. */
  49910. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49911. /** @hidden */
  49912. 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;
  49913. /** @hidden */
  49914. 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;
  49915. /** @hidden */
  49916. 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;
  49917. /** @hidden */
  49918. 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;
  49919. /** @hidden */
  49920. 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;
  49921. /** @hidden */
  49922. 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;
  49923. }
  49924. }
  49925. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49926. import { Nullable } from "babylonjs/types";
  49927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49928. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49929. /**
  49930. * Implementation of the TGA Texture Loader.
  49931. * @hidden
  49932. */
  49933. export class _TGATextureLoader implements IInternalTextureLoader {
  49934. /**
  49935. * Defines wether the loader supports cascade loading the different faces.
  49936. */
  49937. readonly supportCascades: boolean;
  49938. /**
  49939. * This returns if the loader support the current file information.
  49940. * @param extension defines the file extension of the file being loaded
  49941. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49942. * @param fallback defines the fallback internal texture if any
  49943. * @param isBase64 defines whether the texture is encoded as a base64
  49944. * @param isBuffer defines whether the texture data are stored as a buffer
  49945. * @returns true if the loader can load the specified file
  49946. */
  49947. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49948. /**
  49949. * Transform the url before loading if required.
  49950. * @param rootUrl the url of the texture
  49951. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49952. * @returns the transformed texture
  49953. */
  49954. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49955. /**
  49956. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49957. * @param rootUrl the url of the texture
  49958. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49959. * @returns the fallback texture
  49960. */
  49961. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49962. /**
  49963. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49964. * @param data contains the texture data
  49965. * @param texture defines the BabylonJS internal texture
  49966. * @param createPolynomials will be true if polynomials have been requested
  49967. * @param onLoad defines the callback to trigger once the texture is ready
  49968. * @param onError defines the callback to trigger in case of error
  49969. */
  49970. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49971. /**
  49972. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49973. * @param data contains the texture data
  49974. * @param texture defines the BabylonJS internal texture
  49975. * @param callback defines the method to call once ready to upload
  49976. */
  49977. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49978. }
  49979. }
  49980. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49981. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49982. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49983. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49984. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49985. }
  49986. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49987. import { Scene } from "babylonjs/scene";
  49988. import { Texture } from "babylonjs/Materials/Textures/texture";
  49989. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49990. /**
  49991. * 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.
  49992. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49993. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49994. */
  49995. export class CustomProceduralTexture extends ProceduralTexture {
  49996. private _animate;
  49997. private _time;
  49998. private _config;
  49999. private _texturePath;
  50000. /**
  50001. * Instantiates a new Custom Procedural Texture.
  50002. * 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.
  50003. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50004. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50005. * @param name Define the name of the texture
  50006. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50007. * @param size Define the size of the texture to create
  50008. * @param scene Define the scene the texture belongs to
  50009. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50010. * @param generateMipMaps Define if the texture should creates mip maps or not
  50011. */
  50012. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50013. private _loadJson;
  50014. /**
  50015. * Is the texture ready to be used ? (rendered at least once)
  50016. * @returns true if ready, otherwise, false.
  50017. */
  50018. isReady(): boolean;
  50019. /**
  50020. * Render the texture to its associated render target.
  50021. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50022. */
  50023. render(useCameraPostProcess?: boolean): void;
  50024. /**
  50025. * Update the list of dependant textures samplers in the shader.
  50026. */
  50027. updateTextures(): void;
  50028. /**
  50029. * Update the uniform values of the procedural texture in the shader.
  50030. */
  50031. updateShaderUniforms(): void;
  50032. /**
  50033. * Define if the texture animates or not.
  50034. */
  50035. animate: boolean;
  50036. }
  50037. }
  50038. declare module "babylonjs/Shaders/noise.fragment" {
  50039. /** @hidden */
  50040. export var noisePixelShader: {
  50041. name: string;
  50042. shader: string;
  50043. };
  50044. }
  50045. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  50046. import { Nullable } from "babylonjs/types";
  50047. import { Scene } from "babylonjs/scene";
  50048. import { Texture } from "babylonjs/Materials/Textures/texture";
  50049. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50050. import "babylonjs/Shaders/noise.fragment";
  50051. /**
  50052. * Class used to generate noise procedural textures
  50053. */
  50054. export class NoiseProceduralTexture extends ProceduralTexture {
  50055. private _time;
  50056. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50057. brightness: number;
  50058. /** Defines the number of octaves to process */
  50059. octaves: number;
  50060. /** Defines the level of persistence (0.8 by default) */
  50061. persistence: number;
  50062. /** Gets or sets animation speed factor (default is 1) */
  50063. animationSpeedFactor: number;
  50064. /**
  50065. * Creates a new NoiseProceduralTexture
  50066. * @param name defines the name fo the texture
  50067. * @param size defines the size of the texture (default is 256)
  50068. * @param scene defines the hosting scene
  50069. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50070. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50071. */
  50072. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50073. private _updateShaderUniforms;
  50074. protected _getDefines(): string;
  50075. /** Generate the current state of the procedural texture */
  50076. render(useCameraPostProcess?: boolean): void;
  50077. /**
  50078. * Serializes this noise procedural texture
  50079. * @returns a serialized noise procedural texture object
  50080. */
  50081. serialize(): any;
  50082. /**
  50083. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50084. * @param parsedTexture defines parsed texture data
  50085. * @param scene defines the current scene
  50086. * @param rootUrl defines the root URL containing noise procedural texture information
  50087. * @returns a parsed NoiseProceduralTexture
  50088. */
  50089. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50090. }
  50091. }
  50092. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  50093. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  50094. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  50095. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50096. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  50097. }
  50098. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  50099. import { Nullable } from "babylonjs/types";
  50100. import { Scene } from "babylonjs/scene";
  50101. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50102. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50103. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  50104. /**
  50105. * Raw cube texture where the raw buffers are passed in
  50106. */
  50107. export class RawCubeTexture extends CubeTexture {
  50108. /**
  50109. * Creates a cube texture where the raw buffers are passed in.
  50110. * @param scene defines the scene the texture is attached to
  50111. * @param data defines the array of data to use to create each face
  50112. * @param size defines the size of the textures
  50113. * @param format defines the format of the data
  50114. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50115. * @param generateMipMaps defines if the engine should generate the mip levels
  50116. * @param invertY defines if data must be stored with Y axis inverted
  50117. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50118. * @param compression defines the compression used (null by default)
  50119. */
  50120. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50121. /**
  50122. * Updates the raw cube texture.
  50123. * @param data defines the data to store
  50124. * @param format defines the data format
  50125. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50126. * @param invertY defines if data must be stored with Y axis inverted
  50127. * @param compression defines the compression used (null by default)
  50128. * @param level defines which level of the texture to update
  50129. */
  50130. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50131. /**
  50132. * Updates a raw cube texture with RGBD encoded data.
  50133. * @param data defines the array of data [mipmap][face] to use to create each face
  50134. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50135. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50136. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50137. * @returns a promsie that resolves when the operation is complete
  50138. */
  50139. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50140. /**
  50141. * Clones the raw cube texture.
  50142. * @return a new cube texture
  50143. */
  50144. clone(): CubeTexture;
  50145. /** @hidden */
  50146. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50147. }
  50148. }
  50149. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  50150. import { Scene } from "babylonjs/scene";
  50151. import { Texture } from "babylonjs/Materials/Textures/texture";
  50152. /**
  50153. * Class used to store 3D textures containing user data
  50154. */
  50155. export class RawTexture3D extends Texture {
  50156. /** Gets or sets the texture format to use */
  50157. format: number;
  50158. private _engine;
  50159. /**
  50160. * Create a new RawTexture3D
  50161. * @param data defines the data of the texture
  50162. * @param width defines the width of the texture
  50163. * @param height defines the height of the texture
  50164. * @param depth defines the depth of the texture
  50165. * @param format defines the texture format to use
  50166. * @param scene defines the hosting scene
  50167. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50168. * @param invertY defines if texture must be stored with Y axis inverted
  50169. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50170. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50171. */
  50172. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50173. /** Gets or sets the texture format to use */
  50174. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50175. /**
  50176. * Update the texture with new data
  50177. * @param data defines the data to store in the texture
  50178. */
  50179. update(data: ArrayBufferView): void;
  50180. }
  50181. }
  50182. declare module "babylonjs/Materials/Textures/refractionTexture" {
  50183. import { Scene } from "babylonjs/scene";
  50184. import { Plane } from "babylonjs/Maths/math";
  50185. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50186. /**
  50187. * Creates a refraction texture used by refraction channel of the standard material.
  50188. * It is like a mirror but to see through a material.
  50189. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50190. */
  50191. export class RefractionTexture extends RenderTargetTexture {
  50192. /**
  50193. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50194. * 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.
  50195. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50196. */
  50197. refractionPlane: Plane;
  50198. /**
  50199. * Define how deep under the surface we should see.
  50200. */
  50201. depth: number;
  50202. /**
  50203. * Creates a refraction texture used by refraction channel of the standard material.
  50204. * It is like a mirror but to see through a material.
  50205. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50206. * @param name Define the texture name
  50207. * @param size Define the size of the underlying texture
  50208. * @param scene Define the scene the refraction belongs to
  50209. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50210. */
  50211. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50212. /**
  50213. * Clone the refraction texture.
  50214. * @returns the cloned texture
  50215. */
  50216. clone(): RefractionTexture;
  50217. /**
  50218. * Serialize the texture to a JSON representation you could use in Parse later on
  50219. * @returns the serialized JSON representation
  50220. */
  50221. serialize(): any;
  50222. }
  50223. }
  50224. declare module "babylonjs/Materials/Textures/index" {
  50225. export * from "babylonjs/Materials/Textures/baseTexture";
  50226. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  50227. export * from "babylonjs/Materials/Textures/cubeTexture";
  50228. export * from "babylonjs/Materials/Textures/dynamicTexture";
  50229. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  50230. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  50231. export * from "babylonjs/Materials/Textures/internalTexture";
  50232. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  50233. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  50234. export * from "babylonjs/Materials/Textures/Loaders/index";
  50235. export * from "babylonjs/Materials/Textures/mirrorTexture";
  50236. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  50237. export * from "babylonjs/Materials/Textures/Procedurals/index";
  50238. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  50239. export * from "babylonjs/Materials/Textures/rawTexture";
  50240. export * from "babylonjs/Materials/Textures/rawTexture3D";
  50241. export * from "babylonjs/Materials/Textures/refractionTexture";
  50242. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  50243. export * from "babylonjs/Materials/Textures/texture";
  50244. export * from "babylonjs/Materials/Textures/videoTexture";
  50245. }
  50246. declare module "babylonjs/Materials/index" {
  50247. export * from "babylonjs/Materials/Background/index";
  50248. export * from "babylonjs/Materials/colorCurves";
  50249. export * from "babylonjs/Materials/effect";
  50250. export * from "babylonjs/Materials/fresnelParameters";
  50251. export * from "babylonjs/Materials/imageProcessingConfiguration";
  50252. export * from "babylonjs/Materials/material";
  50253. export * from "babylonjs/Materials/materialDefines";
  50254. export * from "babylonjs/Materials/materialHelper";
  50255. export * from "babylonjs/Materials/multiMaterial";
  50256. export * from "babylonjs/Materials/PBR/index";
  50257. export * from "babylonjs/Materials/pushMaterial";
  50258. export * from "babylonjs/Materials/shaderMaterial";
  50259. export * from "babylonjs/Materials/standardMaterial";
  50260. export * from "babylonjs/Materials/Textures/index";
  50261. export * from "babylonjs/Materials/uniformBuffer";
  50262. export * from "babylonjs/Materials/materialFlags";
  50263. }
  50264. declare module "babylonjs/Maths/index" {
  50265. export * from "babylonjs/Maths/math.scalar";
  50266. export * from "babylonjs/Maths/math";
  50267. export * from "babylonjs/Maths/sphericalPolynomial";
  50268. }
  50269. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  50270. import { IDisposable } from "babylonjs/scene";
  50271. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50272. /**
  50273. * Configuration for Draco compression
  50274. */
  50275. export interface IDracoCompressionConfiguration {
  50276. /**
  50277. * Configuration for the decoder.
  50278. */
  50279. decoder?: {
  50280. /**
  50281. * The url to the WebAssembly module.
  50282. */
  50283. wasmUrl?: string;
  50284. /**
  50285. * The url to the WebAssembly binary.
  50286. */
  50287. wasmBinaryUrl?: string;
  50288. /**
  50289. * The url to the fallback JavaScript module.
  50290. */
  50291. fallbackUrl?: string;
  50292. };
  50293. }
  50294. /**
  50295. * Draco compression (https://google.github.io/draco/)
  50296. *
  50297. * This class wraps the Draco module.
  50298. *
  50299. * **Encoder**
  50300. *
  50301. * The encoder is not currently implemented.
  50302. *
  50303. * **Decoder**
  50304. *
  50305. * 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.
  50306. *
  50307. * To update the configuration, use the following code:
  50308. * ```javascript
  50309. * DracoCompression.Configuration = {
  50310. * decoder: {
  50311. * wasmUrl: "<url to the WebAssembly library>",
  50312. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  50313. * fallbackUrl: "<url to the fallback JavaScript library>",
  50314. * }
  50315. * };
  50316. * ```
  50317. *
  50318. * 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.
  50319. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  50320. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  50321. *
  50322. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  50323. * ```javascript
  50324. * var dracoCompression = new DracoCompression();
  50325. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  50326. * [VertexBuffer.PositionKind]: 0
  50327. * });
  50328. * ```
  50329. *
  50330. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  50331. */
  50332. export class DracoCompression implements IDisposable {
  50333. private static _DecoderModulePromise;
  50334. /**
  50335. * The configuration. Defaults to the following urls:
  50336. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  50337. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  50338. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  50339. */
  50340. static Configuration: IDracoCompressionConfiguration;
  50341. /**
  50342. * Returns true if the decoder is available.
  50343. */
  50344. static readonly DecoderAvailable: boolean;
  50345. /**
  50346. * Constructor
  50347. */
  50348. constructor();
  50349. /**
  50350. * Stop all async operations and release resources.
  50351. */
  50352. dispose(): void;
  50353. /**
  50354. * Decode Draco compressed mesh data to vertex data.
  50355. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  50356. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  50357. * @returns A promise that resolves with the decoded vertex data
  50358. */
  50359. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  50360. [kind: string]: number;
  50361. }): Promise<VertexData>;
  50362. private static _GetDecoderModule;
  50363. private static _LoadScriptAsync;
  50364. private static _LoadFileAsync;
  50365. }
  50366. }
  50367. declare module "babylonjs/Meshes/Compression/index" {
  50368. export * from "babylonjs/Meshes/Compression/dracoCompression";
  50369. }
  50370. declare module "babylonjs/Meshes/csg" {
  50371. import { Nullable } from "babylonjs/types";
  50372. import { Scene } from "babylonjs/scene";
  50373. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  50374. import { Mesh } from "babylonjs/Meshes/mesh";
  50375. import { Material } from "babylonjs/Materials/material";
  50376. /**
  50377. * Class for building Constructive Solid Geometry
  50378. */
  50379. export class CSG {
  50380. private polygons;
  50381. /**
  50382. * The world matrix
  50383. */
  50384. matrix: Matrix;
  50385. /**
  50386. * Stores the position
  50387. */
  50388. position: Vector3;
  50389. /**
  50390. * Stores the rotation
  50391. */
  50392. rotation: Vector3;
  50393. /**
  50394. * Stores the rotation quaternion
  50395. */
  50396. rotationQuaternion: Nullable<Quaternion>;
  50397. /**
  50398. * Stores the scaling vector
  50399. */
  50400. scaling: Vector3;
  50401. /**
  50402. * Convert the Mesh to CSG
  50403. * @param mesh The Mesh to convert to CSG
  50404. * @returns A new CSG from the Mesh
  50405. */
  50406. static FromMesh(mesh: Mesh): CSG;
  50407. /**
  50408. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  50409. * @param polygons Polygons used to construct a CSG solid
  50410. */
  50411. private static FromPolygons;
  50412. /**
  50413. * Clones, or makes a deep copy, of the CSG
  50414. * @returns A new CSG
  50415. */
  50416. clone(): CSG;
  50417. /**
  50418. * Unions this CSG with another CSG
  50419. * @param csg The CSG to union against this CSG
  50420. * @returns The unioned CSG
  50421. */
  50422. union(csg: CSG): CSG;
  50423. /**
  50424. * Unions this CSG with another CSG in place
  50425. * @param csg The CSG to union against this CSG
  50426. */
  50427. unionInPlace(csg: CSG): void;
  50428. /**
  50429. * Subtracts this CSG with another CSG
  50430. * @param csg The CSG to subtract against this CSG
  50431. * @returns A new CSG
  50432. */
  50433. subtract(csg: CSG): CSG;
  50434. /**
  50435. * Subtracts this CSG with another CSG in place
  50436. * @param csg The CSG to subtact against this CSG
  50437. */
  50438. subtractInPlace(csg: CSG): void;
  50439. /**
  50440. * Intersect this CSG with another CSG
  50441. * @param csg The CSG to intersect against this CSG
  50442. * @returns A new CSG
  50443. */
  50444. intersect(csg: CSG): CSG;
  50445. /**
  50446. * Intersects this CSG with another CSG in place
  50447. * @param csg The CSG to intersect against this CSG
  50448. */
  50449. intersectInPlace(csg: CSG): void;
  50450. /**
  50451. * Return a new CSG solid with solid and empty space switched. This solid is
  50452. * not modified.
  50453. * @returns A new CSG solid with solid and empty space switched
  50454. */
  50455. inverse(): CSG;
  50456. /**
  50457. * Inverses the CSG in place
  50458. */
  50459. inverseInPlace(): void;
  50460. /**
  50461. * This is used to keep meshes transformations so they can be restored
  50462. * when we build back a Babylon Mesh
  50463. * NB : All CSG operations are performed in world coordinates
  50464. * @param csg The CSG to copy the transform attributes from
  50465. * @returns This CSG
  50466. */
  50467. copyTransformAttributes(csg: CSG): CSG;
  50468. /**
  50469. * Build Raw mesh from CSG
  50470. * Coordinates here are in world space
  50471. * @param name The name of the mesh geometry
  50472. * @param scene The Scene
  50473. * @param keepSubMeshes Specifies if the submeshes should be kept
  50474. * @returns A new Mesh
  50475. */
  50476. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  50477. /**
  50478. * Build Mesh from CSG taking material and transforms into account
  50479. * @param name The name of the Mesh
  50480. * @param material The material of the Mesh
  50481. * @param scene The Scene
  50482. * @param keepSubMeshes Specifies if submeshes should be kept
  50483. * @returns The new Mesh
  50484. */
  50485. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50486. }
  50487. }
  50488. declare module "babylonjs/Meshes/trailMesh" {
  50489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50490. import { Mesh } from "babylonjs/Meshes/mesh";
  50491. import { Scene } from "babylonjs/scene";
  50492. /**
  50493. * Class used to create a trail following a mesh
  50494. */
  50495. export class TrailMesh extends Mesh {
  50496. private _generator;
  50497. private _autoStart;
  50498. private _running;
  50499. private _diameter;
  50500. private _length;
  50501. private _sectionPolygonPointsCount;
  50502. private _sectionVectors;
  50503. private _sectionNormalVectors;
  50504. private _beforeRenderObserver;
  50505. /**
  50506. * @constructor
  50507. * @param name The value used by scene.getMeshByName() to do a lookup.
  50508. * @param generator The mesh to generate a trail.
  50509. * @param scene The scene to add this mesh to.
  50510. * @param diameter Diameter of trailing mesh. Default is 1.
  50511. * @param length Length of trailing mesh. Default is 60.
  50512. * @param autoStart Automatically start trailing mesh. Default true.
  50513. */
  50514. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50515. /**
  50516. * "TrailMesh"
  50517. * @returns "TrailMesh"
  50518. */
  50519. getClassName(): string;
  50520. private _createMesh;
  50521. /**
  50522. * Start trailing mesh.
  50523. */
  50524. start(): void;
  50525. /**
  50526. * Stop trailing mesh.
  50527. */
  50528. stop(): void;
  50529. /**
  50530. * Update trailing mesh geometry.
  50531. */
  50532. update(): void;
  50533. /**
  50534. * Returns a new TrailMesh object.
  50535. * @param name is a string, the name given to the new mesh
  50536. * @param newGenerator use new generator object for cloned trail mesh
  50537. * @returns a new mesh
  50538. */
  50539. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50540. /**
  50541. * Serializes this trail mesh
  50542. * @param serializationObject object to write serialization to
  50543. */
  50544. serialize(serializationObject: any): void;
  50545. /**
  50546. * Parses a serialized trail mesh
  50547. * @param parsedMesh the serialized mesh
  50548. * @param scene the scene to create the trail mesh in
  50549. * @returns the created trail mesh
  50550. */
  50551. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50552. }
  50553. }
  50554. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50555. import { Nullable } from "babylonjs/types";
  50556. import { Scene } from "babylonjs/scene";
  50557. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50558. import { Mesh } from "babylonjs/Meshes/mesh";
  50559. /**
  50560. * Class containing static functions to help procedurally build meshes
  50561. */
  50562. export class RibbonBuilder {
  50563. /**
  50564. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50565. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50566. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50567. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50568. * * 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
  50569. * * 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
  50570. * * 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
  50571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50574. * * 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
  50575. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50576. * * 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
  50577. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50579. * @param name defines the name of the mesh
  50580. * @param options defines the options used to create the mesh
  50581. * @param scene defines the hosting scene
  50582. * @returns the ribbon mesh
  50583. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50584. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50585. */
  50586. static CreateRibbon(name: string, options: {
  50587. pathArray: Vector3[][];
  50588. closeArray?: boolean;
  50589. closePath?: boolean;
  50590. offset?: number;
  50591. updatable?: boolean;
  50592. sideOrientation?: number;
  50593. frontUVs?: Vector4;
  50594. backUVs?: Vector4;
  50595. instance?: Mesh;
  50596. invertUV?: boolean;
  50597. uvs?: Vector2[];
  50598. colors?: Color4[];
  50599. }, scene?: Nullable<Scene>): Mesh;
  50600. }
  50601. }
  50602. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  50603. import { Vector4 } from "babylonjs/Maths/math";
  50604. import { Mesh } from "babylonjs/Meshes/mesh";
  50605. /**
  50606. * Class containing static functions to help procedurally build meshes
  50607. */
  50608. export class TorusKnotBuilder {
  50609. /**
  50610. * Creates a torus knot mesh
  50611. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50612. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50613. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50614. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50618. * @param name defines the name of the mesh
  50619. * @param options defines the options used to create the mesh
  50620. * @param scene defines the hosting scene
  50621. * @returns the torus knot mesh
  50622. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50623. */
  50624. static CreateTorusKnot(name: string, options: {
  50625. radius?: number;
  50626. tube?: number;
  50627. radialSegments?: number;
  50628. tubularSegments?: number;
  50629. p?: number;
  50630. q?: number;
  50631. updatable?: boolean;
  50632. sideOrientation?: number;
  50633. frontUVs?: Vector4;
  50634. backUVs?: Vector4;
  50635. }, scene: any): Mesh;
  50636. }
  50637. }
  50638. declare module "babylonjs/Meshes/polygonMesh" {
  50639. import { Scene } from "babylonjs/scene";
  50640. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50641. import { Mesh } from "babylonjs/Meshes/mesh";
  50642. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50643. /**
  50644. * Polygon
  50645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50646. */
  50647. export class Polygon {
  50648. /**
  50649. * Creates a rectangle
  50650. * @param xmin bottom X coord
  50651. * @param ymin bottom Y coord
  50652. * @param xmax top X coord
  50653. * @param ymax top Y coord
  50654. * @returns points that make the resulting rectation
  50655. */
  50656. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50657. /**
  50658. * Creates a circle
  50659. * @param radius radius of circle
  50660. * @param cx scale in x
  50661. * @param cy scale in y
  50662. * @param numberOfSides number of sides that make up the circle
  50663. * @returns points that make the resulting circle
  50664. */
  50665. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50666. /**
  50667. * Creates a polygon from input string
  50668. * @param input Input polygon data
  50669. * @returns the parsed points
  50670. */
  50671. static Parse(input: string): Vector2[];
  50672. /**
  50673. * Starts building a polygon from x and y coordinates
  50674. * @param x x coordinate
  50675. * @param y y coordinate
  50676. * @returns the started path2
  50677. */
  50678. static StartingAt(x: number, y: number): Path2;
  50679. }
  50680. /**
  50681. * Builds a polygon
  50682. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50683. */
  50684. export class PolygonMeshBuilder {
  50685. private _points;
  50686. private _outlinepoints;
  50687. private _holes;
  50688. private _name;
  50689. private _scene;
  50690. private _epoints;
  50691. private _eholes;
  50692. private _addToepoint;
  50693. /**
  50694. * Babylon reference to the earcut plugin.
  50695. */
  50696. bjsEarcut: any;
  50697. /**
  50698. * Creates a PolygonMeshBuilder
  50699. * @param name name of the builder
  50700. * @param contours Path of the polygon
  50701. * @param scene scene to add to when creating the mesh
  50702. * @param earcutInjection can be used to inject your own earcut reference
  50703. */
  50704. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50705. /**
  50706. * Adds a whole within the polygon
  50707. * @param hole Array of points defining the hole
  50708. * @returns this
  50709. */
  50710. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50711. /**
  50712. * Creates the polygon
  50713. * @param updatable If the mesh should be updatable
  50714. * @param depth The depth of the mesh created
  50715. * @returns the created mesh
  50716. */
  50717. build(updatable?: boolean, depth?: number): Mesh;
  50718. /**
  50719. * Creates the polygon
  50720. * @param depth The depth of the mesh created
  50721. * @returns the created VertexData
  50722. */
  50723. buildVertexData(depth?: number): VertexData;
  50724. /**
  50725. * Adds a side to the polygon
  50726. * @param positions points that make the polygon
  50727. * @param normals normals of the polygon
  50728. * @param uvs uvs of the polygon
  50729. * @param indices indices of the polygon
  50730. * @param bounds bounds of the polygon
  50731. * @param points points of the polygon
  50732. * @param depth depth of the polygon
  50733. * @param flip flip of the polygon
  50734. */
  50735. private addSide;
  50736. }
  50737. }
  50738. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50739. import { Scene } from "babylonjs/scene";
  50740. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50741. import { Mesh } from "babylonjs/Meshes/mesh";
  50742. /**
  50743. * Class containing static functions to help procedurally build meshes
  50744. */
  50745. export class PolygonBuilder {
  50746. /**
  50747. * Creates a polygon mesh
  50748. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50749. * * 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
  50750. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50753. * * Remember you can only change the shape positions, not their number when updating a polygon
  50754. * @param name defines the name of the mesh
  50755. * @param options defines the options used to create the mesh
  50756. * @param scene defines the hosting scene
  50757. * @param earcutInjection can be used to inject your own earcut reference
  50758. * @returns the polygon mesh
  50759. */
  50760. static CreatePolygon(name: string, options: {
  50761. shape: Vector3[];
  50762. holes?: Vector3[][];
  50763. depth?: number;
  50764. faceUV?: Vector4[];
  50765. faceColors?: Color4[];
  50766. updatable?: boolean;
  50767. sideOrientation?: number;
  50768. frontUVs?: Vector4;
  50769. backUVs?: Vector4;
  50770. }, scene: Scene, earcutInjection?: any): Mesh;
  50771. /**
  50772. * Creates an extruded polygon mesh, with depth in the Y direction.
  50773. * * 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)
  50774. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50775. * @param name defines the name of the mesh
  50776. * @param options defines the options used to create the mesh
  50777. * @param scene defines the hosting scene
  50778. * @param earcutInjection can be used to inject your own earcut reference
  50779. * @returns the polygon mesh
  50780. */
  50781. static ExtrudePolygon(name: string, options: {
  50782. shape: Vector3[];
  50783. holes?: Vector3[][];
  50784. depth?: number;
  50785. faceUV?: Vector4[];
  50786. faceColors?: Color4[];
  50787. updatable?: boolean;
  50788. sideOrientation?: number;
  50789. frontUVs?: Vector4;
  50790. backUVs?: Vector4;
  50791. }, scene: Scene, earcutInjection?: any): Mesh;
  50792. }
  50793. }
  50794. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50795. import { Nullable } from "babylonjs/types";
  50796. import { Scene } from "babylonjs/scene";
  50797. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50798. import { Mesh } from "babylonjs/Meshes/mesh";
  50799. /**
  50800. * Class containing static functions to help procedurally build meshes
  50801. */
  50802. export class ShapeBuilder {
  50803. /**
  50804. * 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.
  50805. * * 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.
  50806. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50807. * * 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.
  50808. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50809. * * 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
  50810. * * 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
  50811. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50814. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50816. * @param name defines the name of the mesh
  50817. * @param options defines the options used to create the mesh
  50818. * @param scene defines the hosting scene
  50819. * @returns the extruded shape mesh
  50820. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50821. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50822. */
  50823. static ExtrudeShape(name: string, options: {
  50824. shape: Vector3[];
  50825. path: Vector3[];
  50826. scale?: number;
  50827. rotation?: number;
  50828. cap?: number;
  50829. updatable?: boolean;
  50830. sideOrientation?: number;
  50831. frontUVs?: Vector4;
  50832. backUVs?: Vector4;
  50833. instance?: Mesh;
  50834. invertUV?: boolean;
  50835. }, scene?: Nullable<Scene>): Mesh;
  50836. /**
  50837. * Creates an custom extruded shape mesh.
  50838. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50839. * * 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.
  50840. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50841. * * 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
  50842. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50843. * * 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
  50844. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50845. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50846. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50847. * * 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
  50848. * * 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
  50849. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50852. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50854. * @param name defines the name of the mesh
  50855. * @param options defines the options used to create the mesh
  50856. * @param scene defines the hosting scene
  50857. * @returns the custom extruded shape mesh
  50858. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50859. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50860. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50861. */
  50862. static ExtrudeShapeCustom(name: string, options: {
  50863. shape: Vector3[];
  50864. path: Vector3[];
  50865. scaleFunction?: any;
  50866. rotationFunction?: any;
  50867. ribbonCloseArray?: boolean;
  50868. ribbonClosePath?: boolean;
  50869. cap?: number;
  50870. updatable?: boolean;
  50871. sideOrientation?: number;
  50872. frontUVs?: Vector4;
  50873. backUVs?: Vector4;
  50874. instance?: Mesh;
  50875. invertUV?: boolean;
  50876. }, scene: Scene): Mesh;
  50877. private static _ExtrudeShapeGeneric;
  50878. }
  50879. }
  50880. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50881. import { Scene } from "babylonjs/scene";
  50882. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50883. import { Mesh } from "babylonjs/Meshes/mesh";
  50884. /**
  50885. * Class containing static functions to help procedurally build meshes
  50886. */
  50887. export class LatheBuilder {
  50888. /**
  50889. * Creates lathe mesh.
  50890. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50891. * * 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
  50892. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50893. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50894. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50895. * * 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
  50896. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50897. * * 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
  50898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50902. * @param name defines the name of the mesh
  50903. * @param options defines the options used to create the mesh
  50904. * @param scene defines the hosting scene
  50905. * @returns the lathe mesh
  50906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50907. */
  50908. static CreateLathe(name: string, options: {
  50909. shape: Vector3[];
  50910. radius?: number;
  50911. tessellation?: number;
  50912. clip?: number;
  50913. arc?: number;
  50914. closed?: boolean;
  50915. updatable?: boolean;
  50916. sideOrientation?: number;
  50917. frontUVs?: Vector4;
  50918. backUVs?: Vector4;
  50919. cap?: number;
  50920. invertUV?: boolean;
  50921. }, scene: Scene): Mesh;
  50922. }
  50923. }
  50924. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50925. import { Scene } from "babylonjs/scene";
  50926. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50927. import { Mesh } from "babylonjs/Meshes/mesh";
  50928. /**
  50929. * Class containing static functions to help procedurally build meshes
  50930. */
  50931. export class TubeBuilder {
  50932. /**
  50933. * Creates a tube mesh.
  50934. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50935. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50936. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50937. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50938. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50939. * * 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)
  50940. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50941. * * 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
  50942. * * 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
  50943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50945. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50947. * @param name defines the name of the mesh
  50948. * @param options defines the options used to create the mesh
  50949. * @param scene defines the hosting scene
  50950. * @returns the tube mesh
  50951. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50952. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50953. */
  50954. static CreateTube(name: string, options: {
  50955. path: Vector3[];
  50956. radius?: number;
  50957. tessellation?: number;
  50958. radiusFunction?: {
  50959. (i: number, distance: number): number;
  50960. };
  50961. cap?: number;
  50962. arc?: number;
  50963. updatable?: boolean;
  50964. sideOrientation?: number;
  50965. frontUVs?: Vector4;
  50966. backUVs?: Vector4;
  50967. instance?: Mesh;
  50968. invertUV?: boolean;
  50969. }, scene: Scene): Mesh;
  50970. }
  50971. }
  50972. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50973. import { Scene } from "babylonjs/scene";
  50974. import { Vector4 } from "babylonjs/Maths/math";
  50975. import { Mesh } from "babylonjs/Meshes/mesh";
  50976. /**
  50977. * Class containing static functions to help procedurally build meshes
  50978. */
  50979. export class IcoSphereBuilder {
  50980. /**
  50981. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50982. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50983. * * 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`)
  50984. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50985. * * 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
  50986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50989. * @param name defines the name of the mesh
  50990. * @param options defines the options used to create the mesh
  50991. * @param scene defines the hosting scene
  50992. * @returns the icosahedron mesh
  50993. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50994. */
  50995. static CreateIcoSphere(name: string, options: {
  50996. radius?: number;
  50997. radiusX?: number;
  50998. radiusY?: number;
  50999. radiusZ?: number;
  51000. flat?: boolean;
  51001. subdivisions?: number;
  51002. sideOrientation?: number;
  51003. frontUVs?: Vector4;
  51004. backUVs?: Vector4;
  51005. updatable?: boolean;
  51006. }, scene: Scene): Mesh;
  51007. }
  51008. }
  51009. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  51010. import { Vector3 } from "babylonjs/Maths/math";
  51011. import { Mesh } from "babylonjs/Meshes/mesh";
  51012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51013. /**
  51014. * Class containing static functions to help procedurally build meshes
  51015. */
  51016. export class DecalBuilder {
  51017. /**
  51018. * Creates a decal mesh.
  51019. * 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
  51020. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51021. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51022. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51023. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51024. * @param name defines the name of the mesh
  51025. * @param sourceMesh defines the mesh where the decal must be applied
  51026. * @param options defines the options used to create the mesh
  51027. * @param scene defines the hosting scene
  51028. * @returns the decal mesh
  51029. * @see https://doc.babylonjs.com/how_to/decals
  51030. */
  51031. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51032. position?: Vector3;
  51033. normal?: Vector3;
  51034. size?: Vector3;
  51035. angle?: number;
  51036. }): Mesh;
  51037. }
  51038. }
  51039. declare module "babylonjs/Meshes/meshBuilder" {
  51040. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  51041. import { Nullable } from "babylonjs/types";
  51042. import { Scene } from "babylonjs/scene";
  51043. import { Mesh } from "babylonjs/Meshes/mesh";
  51044. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51045. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51047. /**
  51048. * Class containing static functions to help procedurally build meshes
  51049. */
  51050. export class MeshBuilder {
  51051. /**
  51052. * Creates a box mesh
  51053. * * The parameter `size` sets the size (float) of each box side (default 1)
  51054. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51055. * * 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)
  51056. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51060. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51061. * @param name defines the name of the mesh
  51062. * @param options defines the options used to create the mesh
  51063. * @param scene defines the hosting scene
  51064. * @returns the box mesh
  51065. */
  51066. static CreateBox(name: string, options: {
  51067. size?: number;
  51068. width?: number;
  51069. height?: number;
  51070. depth?: number;
  51071. faceUV?: Vector4[];
  51072. faceColors?: Color4[];
  51073. sideOrientation?: number;
  51074. frontUVs?: Vector4;
  51075. backUVs?: Vector4;
  51076. updatable?: boolean;
  51077. }, scene?: Nullable<Scene>): Mesh;
  51078. /**
  51079. * Creates a sphere mesh
  51080. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51081. * * 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`)
  51082. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51083. * * 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
  51084. * * 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)
  51085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51088. * @param name defines the name of the mesh
  51089. * @param options defines the options used to create the mesh
  51090. * @param scene defines the hosting scene
  51091. * @returns the sphere mesh
  51092. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51093. */
  51094. static CreateSphere(name: string, options: {
  51095. segments?: number;
  51096. diameter?: number;
  51097. diameterX?: number;
  51098. diameterY?: number;
  51099. diameterZ?: number;
  51100. arc?: number;
  51101. slice?: number;
  51102. sideOrientation?: number;
  51103. frontUVs?: Vector4;
  51104. backUVs?: Vector4;
  51105. updatable?: boolean;
  51106. }, scene: any): Mesh;
  51107. /**
  51108. * Creates a plane polygonal mesh. By default, this is a disc
  51109. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  51110. * * 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
  51111. * * 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
  51112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51115. * @param name defines the name of the mesh
  51116. * @param options defines the options used to create the mesh
  51117. * @param scene defines the hosting scene
  51118. * @returns the plane polygonal mesh
  51119. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  51120. */
  51121. static CreateDisc(name: string, options: {
  51122. radius?: number;
  51123. tessellation?: number;
  51124. arc?: number;
  51125. updatable?: boolean;
  51126. sideOrientation?: number;
  51127. frontUVs?: Vector4;
  51128. backUVs?: Vector4;
  51129. }, scene?: Nullable<Scene>): Mesh;
  51130. /**
  51131. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51132. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51133. * * 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`)
  51134. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51135. * * 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
  51136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51137. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51139. * @param name defines the name of the mesh
  51140. * @param options defines the options used to create the mesh
  51141. * @param scene defines the hosting scene
  51142. * @returns the icosahedron mesh
  51143. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51144. */
  51145. static CreateIcoSphere(name: string, options: {
  51146. radius?: number;
  51147. radiusX?: number;
  51148. radiusY?: number;
  51149. radiusZ?: number;
  51150. flat?: boolean;
  51151. subdivisions?: number;
  51152. sideOrientation?: number;
  51153. frontUVs?: Vector4;
  51154. backUVs?: Vector4;
  51155. updatable?: boolean;
  51156. }, scene: Scene): Mesh;
  51157. /**
  51158. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51159. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51160. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51161. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51162. * * 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
  51163. * * 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
  51164. * * 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
  51165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51168. * * 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
  51169. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51170. * * 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
  51171. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51173. * @param name defines the name of the mesh
  51174. * @param options defines the options used to create the mesh
  51175. * @param scene defines the hosting scene
  51176. * @returns the ribbon mesh
  51177. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51178. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51179. */
  51180. static CreateRibbon(name: string, options: {
  51181. pathArray: Vector3[][];
  51182. closeArray?: boolean;
  51183. closePath?: boolean;
  51184. offset?: number;
  51185. updatable?: boolean;
  51186. sideOrientation?: number;
  51187. frontUVs?: Vector4;
  51188. backUVs?: Vector4;
  51189. instance?: Mesh;
  51190. invertUV?: boolean;
  51191. uvs?: Vector2[];
  51192. colors?: Color4[];
  51193. }, scene?: Nullable<Scene>): Mesh;
  51194. /**
  51195. * Creates a cylinder or a cone mesh
  51196. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51197. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51198. * * 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.
  51199. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51200. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51201. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51202. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51203. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51204. * * 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).
  51205. * * 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
  51206. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51207. * * 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
  51208. * * 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.
  51209. * * If `enclose` is false, a ring surface is one element.
  51210. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51211. * * 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
  51212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51215. * @param name defines the name of the mesh
  51216. * @param options defines the options used to create the mesh
  51217. * @param scene defines the hosting scene
  51218. * @returns the cylinder mesh
  51219. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51220. */
  51221. static CreateCylinder(name: string, options: {
  51222. height?: number;
  51223. diameterTop?: number;
  51224. diameterBottom?: number;
  51225. diameter?: number;
  51226. tessellation?: number;
  51227. subdivisions?: number;
  51228. arc?: number;
  51229. faceColors?: Color4[];
  51230. faceUV?: Vector4[];
  51231. updatable?: boolean;
  51232. hasRings?: boolean;
  51233. enclose?: boolean;
  51234. sideOrientation?: number;
  51235. frontUVs?: Vector4;
  51236. backUVs?: Vector4;
  51237. }, scene: any): Mesh;
  51238. /**
  51239. * Creates a torus mesh
  51240. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51241. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51242. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51246. * @param name defines the name of the mesh
  51247. * @param options defines the options used to create the mesh
  51248. * @param scene defines the hosting scene
  51249. * @returns the torus mesh
  51250. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51251. */
  51252. static CreateTorus(name: string, options: {
  51253. diameter?: number;
  51254. thickness?: number;
  51255. tessellation?: number;
  51256. updatable?: boolean;
  51257. sideOrientation?: number;
  51258. frontUVs?: Vector4;
  51259. backUVs?: Vector4;
  51260. }, scene: any): Mesh;
  51261. /**
  51262. * Creates a torus knot mesh
  51263. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51264. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51265. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51266. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51270. * @param name defines the name of the mesh
  51271. * @param options defines the options used to create the mesh
  51272. * @param scene defines the hosting scene
  51273. * @returns the torus knot mesh
  51274. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51275. */
  51276. static CreateTorusKnot(name: string, options: {
  51277. radius?: number;
  51278. tube?: number;
  51279. radialSegments?: number;
  51280. tubularSegments?: number;
  51281. p?: number;
  51282. q?: number;
  51283. updatable?: boolean;
  51284. sideOrientation?: number;
  51285. frontUVs?: Vector4;
  51286. backUVs?: Vector4;
  51287. }, scene: any): Mesh;
  51288. /**
  51289. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51290. * * 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
  51291. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51292. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51293. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51294. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51295. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51296. * * 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
  51297. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51300. * @param name defines the name of the new line system
  51301. * @param options defines the options used to create the line system
  51302. * @param scene defines the hosting scene
  51303. * @returns a new line system mesh
  51304. */
  51305. static CreateLineSystem(name: string, options: {
  51306. lines: Vector3[][];
  51307. updatable?: boolean;
  51308. instance?: Nullable<LinesMesh>;
  51309. colors?: Nullable<Color4[][]>;
  51310. useVertexAlpha?: boolean;
  51311. }, scene: Nullable<Scene>): LinesMesh;
  51312. /**
  51313. * Creates a line mesh
  51314. * 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
  51315. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51316. * * The parameter `points` is an array successive Vector3
  51317. * * 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
  51318. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51319. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51320. * * When updating an instance, remember that only point positions can change, not the number of points
  51321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51322. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51323. * @param name defines the name of the new line system
  51324. * @param options defines the options used to create the line system
  51325. * @param scene defines the hosting scene
  51326. * @returns a new line mesh
  51327. */
  51328. static CreateLines(name: string, options: {
  51329. points: Vector3[];
  51330. updatable?: boolean;
  51331. instance?: Nullable<LinesMesh>;
  51332. colors?: Color4[];
  51333. useVertexAlpha?: boolean;
  51334. }, scene?: Nullable<Scene>): LinesMesh;
  51335. /**
  51336. * Creates a dashed line mesh
  51337. * * 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
  51338. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51339. * * The parameter `points` is an array successive Vector3
  51340. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51341. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51342. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51343. * * 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
  51344. * * When updating an instance, remember that only point positions can change, not the number of points
  51345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51346. * @param name defines the name of the mesh
  51347. * @param options defines the options used to create the mesh
  51348. * @param scene defines the hosting scene
  51349. * @returns the dashed line mesh
  51350. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51351. */
  51352. static CreateDashedLines(name: string, options: {
  51353. points: Vector3[];
  51354. dashSize?: number;
  51355. gapSize?: number;
  51356. dashNb?: number;
  51357. updatable?: boolean;
  51358. instance?: LinesMesh;
  51359. }, scene?: Nullable<Scene>): LinesMesh;
  51360. /**
  51361. * 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.
  51362. * * 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.
  51363. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51364. * * 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.
  51365. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51366. * * 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
  51367. * * 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
  51368. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51371. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51373. * @param name defines the name of the mesh
  51374. * @param options defines the options used to create the mesh
  51375. * @param scene defines the hosting scene
  51376. * @returns the extruded shape mesh
  51377. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51379. */
  51380. static ExtrudeShape(name: string, options: {
  51381. shape: Vector3[];
  51382. path: Vector3[];
  51383. scale?: number;
  51384. rotation?: number;
  51385. cap?: number;
  51386. updatable?: boolean;
  51387. sideOrientation?: number;
  51388. frontUVs?: Vector4;
  51389. backUVs?: Vector4;
  51390. instance?: Mesh;
  51391. invertUV?: boolean;
  51392. }, scene?: Nullable<Scene>): Mesh;
  51393. /**
  51394. * Creates an custom extruded shape mesh.
  51395. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51396. * * 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.
  51397. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51398. * * 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
  51399. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51400. * * 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
  51401. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51402. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51403. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51404. * * 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
  51405. * * 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
  51406. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51409. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51411. * @param name defines the name of the mesh
  51412. * @param options defines the options used to create the mesh
  51413. * @param scene defines the hosting scene
  51414. * @returns the custom extruded shape mesh
  51415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51418. */
  51419. static ExtrudeShapeCustom(name: string, options: {
  51420. shape: Vector3[];
  51421. path: Vector3[];
  51422. scaleFunction?: any;
  51423. rotationFunction?: any;
  51424. ribbonCloseArray?: boolean;
  51425. ribbonClosePath?: boolean;
  51426. cap?: number;
  51427. updatable?: boolean;
  51428. sideOrientation?: number;
  51429. frontUVs?: Vector4;
  51430. backUVs?: Vector4;
  51431. instance?: Mesh;
  51432. invertUV?: boolean;
  51433. }, scene: Scene): Mesh;
  51434. /**
  51435. * Creates lathe mesh.
  51436. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51437. * * 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
  51438. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51439. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51440. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51441. * * 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
  51442. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51443. * * 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
  51444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51446. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51448. * @param name defines the name of the mesh
  51449. * @param options defines the options used to create the mesh
  51450. * @param scene defines the hosting scene
  51451. * @returns the lathe mesh
  51452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51453. */
  51454. static CreateLathe(name: string, options: {
  51455. shape: Vector3[];
  51456. radius?: number;
  51457. tessellation?: number;
  51458. clip?: number;
  51459. arc?: number;
  51460. closed?: boolean;
  51461. updatable?: boolean;
  51462. sideOrientation?: number;
  51463. frontUVs?: Vector4;
  51464. backUVs?: Vector4;
  51465. cap?: number;
  51466. invertUV?: boolean;
  51467. }, scene: Scene): Mesh;
  51468. /**
  51469. * Creates a plane mesh
  51470. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51471. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51472. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51476. * @param name defines the name of the mesh
  51477. * @param options defines the options used to create the mesh
  51478. * @param scene defines the hosting scene
  51479. * @returns the plane mesh
  51480. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51481. */
  51482. static CreatePlane(name: string, options: {
  51483. size?: number;
  51484. width?: number;
  51485. height?: number;
  51486. sideOrientation?: number;
  51487. frontUVs?: Vector4;
  51488. backUVs?: Vector4;
  51489. updatable?: boolean;
  51490. sourcePlane?: Plane;
  51491. }, scene: Scene): Mesh;
  51492. /**
  51493. * Creates a ground mesh
  51494. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51495. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51497. * @param name defines the name of the mesh
  51498. * @param options defines the options used to create the mesh
  51499. * @param scene defines the hosting scene
  51500. * @returns the ground mesh
  51501. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51502. */
  51503. static CreateGround(name: string, options: {
  51504. width?: number;
  51505. height?: number;
  51506. subdivisions?: number;
  51507. subdivisionsX?: number;
  51508. subdivisionsY?: number;
  51509. updatable?: boolean;
  51510. }, scene: any): Mesh;
  51511. /**
  51512. * Creates a tiled ground mesh
  51513. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51514. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51515. * * 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
  51516. * * 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
  51517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51518. * @param name defines the name of the mesh
  51519. * @param options defines the options used to create the mesh
  51520. * @param scene defines the hosting scene
  51521. * @returns the tiled ground mesh
  51522. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51523. */
  51524. static CreateTiledGround(name: string, options: {
  51525. xmin: number;
  51526. zmin: number;
  51527. xmax: number;
  51528. zmax: number;
  51529. subdivisions?: {
  51530. w: number;
  51531. h: number;
  51532. };
  51533. precision?: {
  51534. w: number;
  51535. h: number;
  51536. };
  51537. updatable?: boolean;
  51538. }, scene: Scene): Mesh;
  51539. /**
  51540. * Creates a ground mesh from a height map
  51541. * * The parameter `url` sets the URL of the height map image resource.
  51542. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51543. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51544. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51545. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51546. * * 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.
  51547. * * 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).
  51548. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51550. * @param name defines the name of the mesh
  51551. * @param url defines the url to the height map
  51552. * @param options defines the options used to create the mesh
  51553. * @param scene defines the hosting scene
  51554. * @returns the ground mesh
  51555. * @see https://doc.babylonjs.com/babylon101/height_map
  51556. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51557. */
  51558. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51559. width?: number;
  51560. height?: number;
  51561. subdivisions?: number;
  51562. minHeight?: number;
  51563. maxHeight?: number;
  51564. colorFilter?: Color3;
  51565. alphaFilter?: number;
  51566. updatable?: boolean;
  51567. onReady?: (mesh: GroundMesh) => void;
  51568. }, scene: Scene): GroundMesh;
  51569. /**
  51570. * Creates a polygon mesh
  51571. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51572. * * 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
  51573. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51576. * * Remember you can only change the shape positions, not their number when updating a polygon
  51577. * @param name defines the name of the mesh
  51578. * @param options defines the options used to create the mesh
  51579. * @param scene defines the hosting scene
  51580. * @param earcutInjection can be used to inject your own earcut reference
  51581. * @returns the polygon mesh
  51582. */
  51583. static CreatePolygon(name: string, options: {
  51584. shape: Vector3[];
  51585. holes?: Vector3[][];
  51586. depth?: number;
  51587. faceUV?: Vector4[];
  51588. faceColors?: Color4[];
  51589. updatable?: boolean;
  51590. sideOrientation?: number;
  51591. frontUVs?: Vector4;
  51592. backUVs?: Vector4;
  51593. }, scene: Scene, earcutInjection?: any): Mesh;
  51594. /**
  51595. * Creates an extruded polygon mesh, with depth in the Y direction.
  51596. * * 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)
  51597. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51598. * @param name defines the name of the mesh
  51599. * @param options defines the options used to create the mesh
  51600. * @param scene defines the hosting scene
  51601. * @param earcutInjection can be used to inject your own earcut reference
  51602. * @returns the polygon mesh
  51603. */
  51604. static ExtrudePolygon(name: string, options: {
  51605. shape: Vector3[];
  51606. holes?: Vector3[][];
  51607. depth?: number;
  51608. faceUV?: Vector4[];
  51609. faceColors?: Color4[];
  51610. updatable?: boolean;
  51611. sideOrientation?: number;
  51612. frontUVs?: Vector4;
  51613. backUVs?: Vector4;
  51614. }, scene: Scene, earcutInjection?: any): Mesh;
  51615. /**
  51616. * Creates a tube mesh.
  51617. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51618. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51619. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51620. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51621. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51622. * * 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)
  51623. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51624. * * 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
  51625. * * 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
  51626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51628. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51630. * @param name defines the name of the mesh
  51631. * @param options defines the options used to create the mesh
  51632. * @param scene defines the hosting scene
  51633. * @returns the tube mesh
  51634. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51635. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51636. */
  51637. static CreateTube(name: string, options: {
  51638. path: Vector3[];
  51639. radius?: number;
  51640. tessellation?: number;
  51641. radiusFunction?: {
  51642. (i: number, distance: number): number;
  51643. };
  51644. cap?: number;
  51645. arc?: number;
  51646. updatable?: boolean;
  51647. sideOrientation?: number;
  51648. frontUVs?: Vector4;
  51649. backUVs?: Vector4;
  51650. instance?: Mesh;
  51651. invertUV?: boolean;
  51652. }, scene: Scene): Mesh;
  51653. /**
  51654. * Creates a polyhedron mesh
  51655. * * 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
  51656. * * The parameter `size` (positive float, default 1) sets the polygon size
  51657. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51658. * * 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`
  51659. * * 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
  51660. * * 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)`)
  51661. * * 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
  51662. * * 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
  51663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51666. * @param name defines the name of the mesh
  51667. * @param options defines the options used to create the mesh
  51668. * @param scene defines the hosting scene
  51669. * @returns the polyhedron mesh
  51670. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51671. */
  51672. static CreatePolyhedron(name: string, options: {
  51673. type?: number;
  51674. size?: number;
  51675. sizeX?: number;
  51676. sizeY?: number;
  51677. sizeZ?: number;
  51678. custom?: any;
  51679. faceUV?: Vector4[];
  51680. faceColors?: Color4[];
  51681. flat?: boolean;
  51682. updatable?: boolean;
  51683. sideOrientation?: number;
  51684. frontUVs?: Vector4;
  51685. backUVs?: Vector4;
  51686. }, scene: Scene): Mesh;
  51687. /**
  51688. * Creates a decal mesh.
  51689. * 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
  51690. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51691. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51692. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51693. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51694. * @param name defines the name of the mesh
  51695. * @param sourceMesh defines the mesh where the decal must be applied
  51696. * @param options defines the options used to create the mesh
  51697. * @param scene defines the hosting scene
  51698. * @returns the decal mesh
  51699. * @see https://doc.babylonjs.com/how_to/decals
  51700. */
  51701. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51702. position?: Vector3;
  51703. normal?: Vector3;
  51704. size?: Vector3;
  51705. angle?: number;
  51706. }): Mesh;
  51707. }
  51708. }
  51709. declare module "babylonjs/Meshes/meshSimplification" {
  51710. import { Mesh } from "babylonjs/Meshes/mesh";
  51711. /**
  51712. * A simplifier interface for future simplification implementations
  51713. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51714. */
  51715. export interface ISimplifier {
  51716. /**
  51717. * Simplification of a given mesh according to the given settings.
  51718. * Since this requires computation, it is assumed that the function runs async.
  51719. * @param settings The settings of the simplification, including quality and distance
  51720. * @param successCallback A callback that will be called after the mesh was simplified.
  51721. * @param errorCallback in case of an error, this callback will be called. optional.
  51722. */
  51723. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51724. }
  51725. /**
  51726. * Expected simplification settings.
  51727. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51728. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51729. */
  51730. export interface ISimplificationSettings {
  51731. /**
  51732. * Gets or sets the expected quality
  51733. */
  51734. quality: number;
  51735. /**
  51736. * Gets or sets the distance when this optimized version should be used
  51737. */
  51738. distance: number;
  51739. /**
  51740. * Gets an already optimized mesh
  51741. */
  51742. optimizeMesh?: boolean;
  51743. }
  51744. /**
  51745. * Class used to specify simplification options
  51746. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51747. */
  51748. export class SimplificationSettings implements ISimplificationSettings {
  51749. /** expected quality */
  51750. quality: number;
  51751. /** distance when this optimized version should be used */
  51752. distance: number;
  51753. /** already optimized mesh */
  51754. optimizeMesh?: boolean | undefined;
  51755. /**
  51756. * Creates a SimplificationSettings
  51757. * @param quality expected quality
  51758. * @param distance distance when this optimized version should be used
  51759. * @param optimizeMesh already optimized mesh
  51760. */
  51761. constructor(
  51762. /** expected quality */
  51763. quality: number,
  51764. /** distance when this optimized version should be used */
  51765. distance: number,
  51766. /** already optimized mesh */
  51767. optimizeMesh?: boolean | undefined);
  51768. }
  51769. /**
  51770. * Interface used to define a simplification task
  51771. */
  51772. export interface ISimplificationTask {
  51773. /**
  51774. * Array of settings
  51775. */
  51776. settings: Array<ISimplificationSettings>;
  51777. /**
  51778. * Simplification type
  51779. */
  51780. simplificationType: SimplificationType;
  51781. /**
  51782. * Mesh to simplify
  51783. */
  51784. mesh: Mesh;
  51785. /**
  51786. * Callback called on success
  51787. */
  51788. successCallback?: () => void;
  51789. /**
  51790. * Defines if parallel processing can be used
  51791. */
  51792. parallelProcessing: boolean;
  51793. }
  51794. /**
  51795. * Queue used to order the simplification tasks
  51796. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51797. */
  51798. export class SimplificationQueue {
  51799. private _simplificationArray;
  51800. /**
  51801. * Gets a boolean indicating that the process is still running
  51802. */
  51803. running: boolean;
  51804. /**
  51805. * Creates a new queue
  51806. */
  51807. constructor();
  51808. /**
  51809. * Adds a new simplification task
  51810. * @param task defines a task to add
  51811. */
  51812. addTask(task: ISimplificationTask): void;
  51813. /**
  51814. * Execute next task
  51815. */
  51816. executeNext(): void;
  51817. /**
  51818. * Execute a simplification task
  51819. * @param task defines the task to run
  51820. */
  51821. runSimplification(task: ISimplificationTask): void;
  51822. private getSimplifier;
  51823. }
  51824. /**
  51825. * The implemented types of simplification
  51826. * At the moment only Quadratic Error Decimation is implemented
  51827. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51828. */
  51829. export enum SimplificationType {
  51830. /** Quadratic error decimation */
  51831. QUADRATIC = 0
  51832. }
  51833. }
  51834. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51835. import { Scene } from "babylonjs/scene";
  51836. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51837. import { ISceneComponent } from "babylonjs/sceneComponent";
  51838. module "babylonjs/scene" {
  51839. interface Scene {
  51840. /** @hidden (Backing field) */
  51841. _simplificationQueue: SimplificationQueue;
  51842. /**
  51843. * Gets or sets the simplification queue attached to the scene
  51844. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51845. */
  51846. simplificationQueue: SimplificationQueue;
  51847. }
  51848. }
  51849. module "babylonjs/Meshes/mesh" {
  51850. interface Mesh {
  51851. /**
  51852. * Simplify the mesh according to the given array of settings.
  51853. * Function will return immediately and will simplify async
  51854. * @param settings a collection of simplification settings
  51855. * @param parallelProcessing should all levels calculate parallel or one after the other
  51856. * @param simplificationType the type of simplification to run
  51857. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51858. * @returns the current mesh
  51859. */
  51860. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51861. }
  51862. }
  51863. /**
  51864. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51865. * created in a scene
  51866. */
  51867. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51868. /**
  51869. * The component name helpfull to identify the component in the list of scene components.
  51870. */
  51871. readonly name: string;
  51872. /**
  51873. * The scene the component belongs to.
  51874. */
  51875. scene: Scene;
  51876. /**
  51877. * Creates a new instance of the component for the given scene
  51878. * @param scene Defines the scene to register the component in
  51879. */
  51880. constructor(scene: Scene);
  51881. /**
  51882. * Registers the component in a given scene
  51883. */
  51884. register(): void;
  51885. /**
  51886. * Rebuilds the elements related to this component in case of
  51887. * context lost for instance.
  51888. */
  51889. rebuild(): void;
  51890. /**
  51891. * Disposes the component and the associated ressources
  51892. */
  51893. dispose(): void;
  51894. private _beforeCameraUpdate;
  51895. }
  51896. }
  51897. declare module "babylonjs/Meshes/Builders/index" {
  51898. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51899. export * from "babylonjs/Meshes/Builders/discBuilder";
  51900. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51901. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51902. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51903. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51904. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51905. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51906. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51907. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51908. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51909. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51910. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51911. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51912. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51913. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51914. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51915. }
  51916. declare module "babylonjs/Meshes/index" {
  51917. export * from "babylonjs/Meshes/abstractMesh";
  51918. export * from "babylonjs/Meshes/buffer";
  51919. export * from "babylonjs/Meshes/Compression/index";
  51920. export * from "babylonjs/Meshes/csg";
  51921. export * from "babylonjs/Meshes/geometry";
  51922. export * from "babylonjs/Meshes/groundMesh";
  51923. export * from "babylonjs/Meshes/trailMesh";
  51924. export * from "babylonjs/Meshes/instancedMesh";
  51925. export * from "babylonjs/Meshes/linesMesh";
  51926. export * from "babylonjs/Meshes/mesh";
  51927. export * from "babylonjs/Meshes/mesh.vertexData";
  51928. export * from "babylonjs/Meshes/meshBuilder";
  51929. export * from "babylonjs/Meshes/meshSimplification";
  51930. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51931. export * from "babylonjs/Meshes/polygonMesh";
  51932. export * from "babylonjs/Meshes/subMesh";
  51933. export * from "babylonjs/Meshes/transformNode";
  51934. export * from "babylonjs/Meshes/Builders/index";
  51935. }
  51936. declare module "babylonjs/Morph/index" {
  51937. export * from "babylonjs/Morph/morphTarget";
  51938. export * from "babylonjs/Morph/morphTargetManager";
  51939. }
  51940. declare module "babylonjs/Offline/database" {
  51941. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51942. /**
  51943. * Class used to enable access to IndexedDB
  51944. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51945. */
  51946. export class Database implements IOfflineProvider {
  51947. private _callbackManifestChecked;
  51948. private _currentSceneUrl;
  51949. private _db;
  51950. private _enableSceneOffline;
  51951. private _enableTexturesOffline;
  51952. private _manifestVersionFound;
  51953. private _mustUpdateRessources;
  51954. private _hasReachedQuota;
  51955. private _isSupported;
  51956. private _idbFactory;
  51957. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51958. private static IsUASupportingBlobStorage;
  51959. /**
  51960. * Gets a boolean indicating if Database storate is enabled (off by default)
  51961. */
  51962. static IDBStorageEnabled: boolean;
  51963. /**
  51964. * Gets a boolean indicating if scene must be saved in the database
  51965. */
  51966. readonly enableSceneOffline: boolean;
  51967. /**
  51968. * Gets a boolean indicating if textures must be saved in the database
  51969. */
  51970. readonly enableTexturesOffline: boolean;
  51971. /**
  51972. * Creates a new Database
  51973. * @param urlToScene defines the url to load the scene
  51974. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51975. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51976. */
  51977. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51978. private static _ParseURL;
  51979. private static _ReturnFullUrlLocation;
  51980. private _checkManifestFile;
  51981. /**
  51982. * Open the database and make it available
  51983. * @param successCallback defines the callback to call on success
  51984. * @param errorCallback defines the callback to call on error
  51985. */
  51986. open(successCallback: () => void, errorCallback: () => void): void;
  51987. /**
  51988. * Loads an image from the database
  51989. * @param url defines the url to load from
  51990. * @param image defines the target DOM image
  51991. */
  51992. loadImage(url: string, image: HTMLImageElement): void;
  51993. private _loadImageFromDBAsync;
  51994. private _saveImageIntoDBAsync;
  51995. private _checkVersionFromDB;
  51996. private _loadVersionFromDBAsync;
  51997. private _saveVersionIntoDBAsync;
  51998. /**
  51999. * Loads a file from database
  52000. * @param url defines the URL to load from
  52001. * @param sceneLoaded defines a callback to call on success
  52002. * @param progressCallBack defines a callback to call when progress changed
  52003. * @param errorCallback defines a callback to call on error
  52004. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  52005. */
  52006. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  52007. private _loadFileAsync;
  52008. private _saveFileAsync;
  52009. /**
  52010. * Validates if xhr data is correct
  52011. * @param xhr defines the request to validate
  52012. * @param dataType defines the expected data type
  52013. * @returns true if data is correct
  52014. */
  52015. private static _ValidateXHRData;
  52016. }
  52017. }
  52018. declare module "babylonjs/Offline/index" {
  52019. export * from "babylonjs/Offline/database";
  52020. export * from "babylonjs/Offline/IOfflineProvider";
  52021. }
  52022. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  52023. /** @hidden */
  52024. export var gpuUpdateParticlesPixelShader: {
  52025. name: string;
  52026. shader: string;
  52027. };
  52028. }
  52029. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  52030. /** @hidden */
  52031. export var gpuUpdateParticlesVertexShader: {
  52032. name: string;
  52033. shader: string;
  52034. };
  52035. }
  52036. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  52037. /** @hidden */
  52038. export var clipPlaneFragmentDeclaration2: {
  52039. name: string;
  52040. shader: string;
  52041. };
  52042. }
  52043. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  52044. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  52045. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52046. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52047. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52048. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52049. /** @hidden */
  52050. export var gpuRenderParticlesPixelShader: {
  52051. name: string;
  52052. shader: string;
  52053. };
  52054. }
  52055. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  52056. /** @hidden */
  52057. export var clipPlaneVertexDeclaration2: {
  52058. name: string;
  52059. shader: string;
  52060. };
  52061. }
  52062. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  52063. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  52064. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52065. /** @hidden */
  52066. export var gpuRenderParticlesVertexShader: {
  52067. name: string;
  52068. shader: string;
  52069. };
  52070. }
  52071. declare module "babylonjs/Particles/gpuParticleSystem" {
  52072. import { Nullable } from "babylonjs/types";
  52073. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  52074. import { Observable } from "babylonjs/Misc/observable";
  52075. import { Color4, Color3 } from "babylonjs/Maths/math";
  52076. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52077. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  52078. import { Scene, IDisposable } from "babylonjs/scene";
  52079. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  52080. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  52081. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  52082. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  52083. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  52084. /**
  52085. * This represents a GPU particle system in Babylon
  52086. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  52087. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  52088. */
  52089. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  52090. /**
  52091. * The layer mask we are rendering the particles through.
  52092. */
  52093. layerMask: number;
  52094. private _capacity;
  52095. private _activeCount;
  52096. private _currentActiveCount;
  52097. private _accumulatedCount;
  52098. private _renderEffect;
  52099. private _updateEffect;
  52100. private _buffer0;
  52101. private _buffer1;
  52102. private _spriteBuffer;
  52103. private _updateVAO;
  52104. private _renderVAO;
  52105. private _targetIndex;
  52106. private _sourceBuffer;
  52107. private _targetBuffer;
  52108. private _engine;
  52109. private _currentRenderId;
  52110. private _started;
  52111. private _stopped;
  52112. private _timeDelta;
  52113. private _randomTexture;
  52114. private _randomTexture2;
  52115. private _attributesStrideSize;
  52116. private _updateEffectOptions;
  52117. private _randomTextureSize;
  52118. private _actualFrame;
  52119. private readonly _rawTextureWidth;
  52120. /**
  52121. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  52122. */
  52123. static readonly IsSupported: boolean;
  52124. /**
  52125. * An event triggered when the system is disposed.
  52126. */
  52127. onDisposeObservable: Observable<GPUParticleSystem>;
  52128. /**
  52129. * Gets the maximum number of particles active at the same time.
  52130. * @returns The max number of active particles.
  52131. */
  52132. getCapacity(): number;
  52133. /**
  52134. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  52135. * to override the particles.
  52136. */
  52137. forceDepthWrite: boolean;
  52138. /**
  52139. * Gets or set the number of active particles
  52140. */
  52141. activeParticleCount: number;
  52142. private _preWarmDone;
  52143. /**
  52144. * Is this system ready to be used/rendered
  52145. * @return true if the system is ready
  52146. */
  52147. isReady(): boolean;
  52148. /**
  52149. * Gets if the system has been started. (Note: this will still be true after stop is called)
  52150. * @returns True if it has been started, otherwise false.
  52151. */
  52152. isStarted(): boolean;
  52153. /**
  52154. * Starts the particle system and begins to emit
  52155. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  52156. */
  52157. start(delay?: number): void;
  52158. /**
  52159. * Stops the particle system.
  52160. */
  52161. stop(): void;
  52162. /**
  52163. * Remove all active particles
  52164. */
  52165. reset(): void;
  52166. /**
  52167. * Returns the string "GPUParticleSystem"
  52168. * @returns a string containing the class name
  52169. */
  52170. getClassName(): string;
  52171. private _colorGradientsTexture;
  52172. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  52173. /**
  52174. * Adds a new color gradient
  52175. * @param gradient defines the gradient to use (between 0 and 1)
  52176. * @param color1 defines the color to affect to the specified gradient
  52177. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  52178. * @returns the current particle system
  52179. */
  52180. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  52181. /**
  52182. * Remove a specific color gradient
  52183. * @param gradient defines the gradient to remove
  52184. * @returns the current particle system
  52185. */
  52186. removeColorGradient(gradient: number): GPUParticleSystem;
  52187. private _angularSpeedGradientsTexture;
  52188. private _sizeGradientsTexture;
  52189. private _velocityGradientsTexture;
  52190. private _limitVelocityGradientsTexture;
  52191. private _dragGradientsTexture;
  52192. private _addFactorGradient;
  52193. /**
  52194. * Adds a new size gradient
  52195. * @param gradient defines the gradient to use (between 0 and 1)
  52196. * @param factor defines the size factor to affect to the specified gradient
  52197. * @returns the current particle system
  52198. */
  52199. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  52200. /**
  52201. * Remove a specific size gradient
  52202. * @param gradient defines the gradient to remove
  52203. * @returns the current particle system
  52204. */
  52205. removeSizeGradient(gradient: number): GPUParticleSystem;
  52206. /**
  52207. * Adds a new angular speed gradient
  52208. * @param gradient defines the gradient to use (between 0 and 1)
  52209. * @param factor defines the angular speed to affect to the specified gradient
  52210. * @returns the current particle system
  52211. */
  52212. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  52213. /**
  52214. * Remove a specific angular speed gradient
  52215. * @param gradient defines the gradient to remove
  52216. * @returns the current particle system
  52217. */
  52218. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  52219. /**
  52220. * Adds a new velocity gradient
  52221. * @param gradient defines the gradient to use (between 0 and 1)
  52222. * @param factor defines the velocity to affect to the specified gradient
  52223. * @returns the current particle system
  52224. */
  52225. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52226. /**
  52227. * Remove a specific velocity gradient
  52228. * @param gradient defines the gradient to remove
  52229. * @returns the current particle system
  52230. */
  52231. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52232. /**
  52233. * Adds a new limit velocity gradient
  52234. * @param gradient defines the gradient to use (between 0 and 1)
  52235. * @param factor defines the limit velocity value to affect to the specified gradient
  52236. * @returns the current particle system
  52237. */
  52238. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52239. /**
  52240. * Remove a specific limit velocity gradient
  52241. * @param gradient defines the gradient to remove
  52242. * @returns the current particle system
  52243. */
  52244. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52245. /**
  52246. * Adds a new drag gradient
  52247. * @param gradient defines the gradient to use (between 0 and 1)
  52248. * @param factor defines the drag value to affect to the specified gradient
  52249. * @returns the current particle system
  52250. */
  52251. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52252. /**
  52253. * Remove a specific drag gradient
  52254. * @param gradient defines the gradient to remove
  52255. * @returns the current particle system
  52256. */
  52257. removeDragGradient(gradient: number): GPUParticleSystem;
  52258. /**
  52259. * Not supported by GPUParticleSystem
  52260. * @param gradient defines the gradient to use (between 0 and 1)
  52261. * @param factor defines the emit rate value to affect to the specified gradient
  52262. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52263. * @returns the current particle system
  52264. */
  52265. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52266. /**
  52267. * Not supported by GPUParticleSystem
  52268. * @param gradient defines the gradient to remove
  52269. * @returns the current particle system
  52270. */
  52271. removeEmitRateGradient(gradient: number): IParticleSystem;
  52272. /**
  52273. * Not supported by GPUParticleSystem
  52274. * @param gradient defines the gradient to use (between 0 and 1)
  52275. * @param factor defines the start size value to affect to the specified gradient
  52276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52277. * @returns the current particle system
  52278. */
  52279. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52280. /**
  52281. * Not supported by GPUParticleSystem
  52282. * @param gradient defines the gradient to remove
  52283. * @returns the current particle system
  52284. */
  52285. removeStartSizeGradient(gradient: number): IParticleSystem;
  52286. /**
  52287. * Not supported by GPUParticleSystem
  52288. * @param gradient defines the gradient to use (between 0 and 1)
  52289. * @param min defines the color remap minimal range
  52290. * @param max defines the color remap maximal range
  52291. * @returns the current particle system
  52292. */
  52293. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52294. /**
  52295. * Not supported by GPUParticleSystem
  52296. * @param gradient defines the gradient to remove
  52297. * @returns the current particle system
  52298. */
  52299. removeColorRemapGradient(): IParticleSystem;
  52300. /**
  52301. * Not supported by GPUParticleSystem
  52302. * @param gradient defines the gradient to use (between 0 and 1)
  52303. * @param min defines the alpha remap minimal range
  52304. * @param max defines the alpha remap maximal range
  52305. * @returns the current particle system
  52306. */
  52307. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52308. /**
  52309. * Not supported by GPUParticleSystem
  52310. * @param gradient defines the gradient to remove
  52311. * @returns the current particle system
  52312. */
  52313. removeAlphaRemapGradient(): IParticleSystem;
  52314. /**
  52315. * Not supported by GPUParticleSystem
  52316. * @param gradient defines the gradient to use (between 0 and 1)
  52317. * @param color defines the color to affect to the specified gradient
  52318. * @returns the current particle system
  52319. */
  52320. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  52321. /**
  52322. * Not supported by GPUParticleSystem
  52323. * @param gradient defines the gradient to remove
  52324. * @returns the current particle system
  52325. */
  52326. removeRampGradient(): IParticleSystem;
  52327. /**
  52328. * Not supported by GPUParticleSystem
  52329. * @returns the list of ramp gradients
  52330. */
  52331. getRampGradients(): Nullable<Array<Color3Gradient>>;
  52332. /**
  52333. * Not supported by GPUParticleSystem
  52334. * Gets or sets a boolean indicating that ramp gradients must be used
  52335. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  52336. */
  52337. useRampGradients: boolean;
  52338. /**
  52339. * Not supported by GPUParticleSystem
  52340. * @param gradient defines the gradient to use (between 0 and 1)
  52341. * @param factor defines the life time factor to affect to the specified gradient
  52342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52343. * @returns the current particle system
  52344. */
  52345. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52346. /**
  52347. * Not supported by GPUParticleSystem
  52348. * @param gradient defines the gradient to remove
  52349. * @returns the current particle system
  52350. */
  52351. removeLifeTimeGradient(gradient: number): IParticleSystem;
  52352. /**
  52353. * Instantiates a GPU particle system.
  52354. * 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.
  52355. * @param name The name of the particle system
  52356. * @param options The options used to create the system
  52357. * @param scene The scene the particle system belongs to
  52358. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  52359. */
  52360. constructor(name: string, options: Partial<{
  52361. capacity: number;
  52362. randomTextureSize: number;
  52363. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  52364. protected _reset(): void;
  52365. private _createUpdateVAO;
  52366. private _createRenderVAO;
  52367. private _initialize;
  52368. /** @hidden */
  52369. _recreateUpdateEffect(): void;
  52370. /** @hidden */
  52371. _recreateRenderEffect(): void;
  52372. /**
  52373. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  52374. * @param preWarm defines if we are in the pre-warmimg phase
  52375. */
  52376. animate(preWarm?: boolean): void;
  52377. private _createFactorGradientTexture;
  52378. private _createSizeGradientTexture;
  52379. private _createAngularSpeedGradientTexture;
  52380. private _createVelocityGradientTexture;
  52381. private _createLimitVelocityGradientTexture;
  52382. private _createDragGradientTexture;
  52383. private _createColorGradientTexture;
  52384. /**
  52385. * Renders the particle system in its current state
  52386. * @param preWarm defines if the system should only update the particles but not render them
  52387. * @returns the current number of particles
  52388. */
  52389. render(preWarm?: boolean): number;
  52390. /**
  52391. * Rebuilds the particle system
  52392. */
  52393. rebuild(): void;
  52394. private _releaseBuffers;
  52395. private _releaseVAOs;
  52396. /**
  52397. * Disposes the particle system and free the associated resources
  52398. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  52399. */
  52400. dispose(disposeTexture?: boolean): void;
  52401. /**
  52402. * Clones the particle system.
  52403. * @param name The name of the cloned object
  52404. * @param newEmitter The new emitter to use
  52405. * @returns the cloned particle system
  52406. */
  52407. clone(name: string, newEmitter: any): GPUParticleSystem;
  52408. /**
  52409. * Serializes the particle system to a JSON object.
  52410. * @returns the JSON object
  52411. */
  52412. serialize(): any;
  52413. /**
  52414. * Parses a JSON object to create a GPU particle system.
  52415. * @param parsedParticleSystem The JSON object to parse
  52416. * @param scene The scene to create the particle system in
  52417. * @param rootUrl The root url to use to load external dependencies like texture
  52418. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  52419. * @returns the parsed GPU particle system
  52420. */
  52421. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  52422. }
  52423. }
  52424. declare module "babylonjs/Particles/particleSystemSet" {
  52425. import { Nullable } from "babylonjs/types";
  52426. import { Color3 } from "babylonjs/Maths/math";
  52427. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52429. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52430. import { Scene, IDisposable } from "babylonjs/scene";
  52431. /**
  52432. * Represents a set of particle systems working together to create a specific effect
  52433. */
  52434. export class ParticleSystemSet implements IDisposable {
  52435. private _emitterCreationOptions;
  52436. private _emitterNode;
  52437. /**
  52438. * Gets the particle system list
  52439. */
  52440. systems: IParticleSystem[];
  52441. /**
  52442. * Gets the emitter node used with this set
  52443. */
  52444. readonly emitterNode: Nullable<TransformNode>;
  52445. /**
  52446. * Creates a new emitter mesh as a sphere
  52447. * @param options defines the options used to create the sphere
  52448. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  52449. * @param scene defines the hosting scene
  52450. */
  52451. setEmitterAsSphere(options: {
  52452. diameter: number;
  52453. segments: number;
  52454. color: Color3;
  52455. }, renderingGroupId: number, scene: Scene): void;
  52456. /**
  52457. * Starts all particle systems of the set
  52458. * @param emitter defines an optional mesh to use as emitter for the particle systems
  52459. */
  52460. start(emitter?: AbstractMesh): void;
  52461. /**
  52462. * Release all associated resources
  52463. */
  52464. dispose(): void;
  52465. /**
  52466. * Serialize the set into a JSON compatible object
  52467. * @returns a JSON compatible representation of the set
  52468. */
  52469. serialize(): any;
  52470. /**
  52471. * Parse a new ParticleSystemSet from a serialized source
  52472. * @param data defines a JSON compatible representation of the set
  52473. * @param scene defines the hosting scene
  52474. * @param gpu defines if we want GPU particles or CPU particles
  52475. * @returns a new ParticleSystemSet
  52476. */
  52477. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  52478. }
  52479. }
  52480. declare module "babylonjs/Particles/particleHelper" {
  52481. import { Nullable } from "babylonjs/types";
  52482. import { Scene } from "babylonjs/scene";
  52483. import { Vector3 } from "babylonjs/Maths/math";
  52484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52485. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52486. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  52487. /**
  52488. * This class is made for on one-liner static method to help creating particle system set.
  52489. */
  52490. export class ParticleHelper {
  52491. /**
  52492. * Gets or sets base Assets URL
  52493. */
  52494. static BaseAssetsUrl: string;
  52495. /**
  52496. * Create a default particle system that you can tweak
  52497. * @param emitter defines the emitter to use
  52498. * @param capacity defines the system capacity (default is 500 particles)
  52499. * @param scene defines the hosting scene
  52500. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  52501. * @returns the new Particle system
  52502. */
  52503. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  52504. /**
  52505. * This is the main static method (one-liner) of this helper to create different particle systems
  52506. * @param type This string represents the type to the particle system to create
  52507. * @param scene The scene where the particle system should live
  52508. * @param gpu If the system will use gpu
  52509. * @returns the ParticleSystemSet created
  52510. */
  52511. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  52512. /**
  52513. * Static function used to export a particle system to a ParticleSystemSet variable.
  52514. * Please note that the emitter shape is not exported
  52515. * @param systems defines the particle systems to export
  52516. * @returns the created particle system set
  52517. */
  52518. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  52519. }
  52520. }
  52521. declare module "babylonjs/Particles/particleSystemComponent" {
  52522. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52523. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  52524. import "babylonjs/Shaders/particles.vertex";
  52525. module "babylonjs/Engines/engine" {
  52526. interface Engine {
  52527. /**
  52528. * Create an effect to use with particle systems.
  52529. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  52530. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  52531. * @param uniformsNames defines a list of attribute names
  52532. * @param samplers defines an array of string used to represent textures
  52533. * @param defines defines the string containing the defines to use to compile the shaders
  52534. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  52535. * @param onCompiled defines a function to call when the effect creation is successful
  52536. * @param onError defines a function to call when the effect creation has failed
  52537. * @returns the new Effect
  52538. */
  52539. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52540. }
  52541. }
  52542. module "babylonjs/Meshes/mesh" {
  52543. interface Mesh {
  52544. /**
  52545. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52546. * @returns an array of IParticleSystem
  52547. */
  52548. getEmittedParticleSystems(): IParticleSystem[];
  52549. /**
  52550. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52551. * @returns an array of IParticleSystem
  52552. */
  52553. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52554. }
  52555. }
  52556. /**
  52557. * @hidden
  52558. */
  52559. export var _IDoNeedToBeInTheBuild: number;
  52560. }
  52561. declare module "babylonjs/Particles/index" {
  52562. export * from "babylonjs/Particles/baseParticleSystem";
  52563. export * from "babylonjs/Particles/EmitterTypes/index";
  52564. export * from "babylonjs/Particles/gpuParticleSystem";
  52565. export * from "babylonjs/Particles/IParticleSystem";
  52566. export * from "babylonjs/Particles/particle";
  52567. export * from "babylonjs/Particles/particleHelper";
  52568. export * from "babylonjs/Particles/particleSystem";
  52569. export * from "babylonjs/Particles/particleSystemComponent";
  52570. export * from "babylonjs/Particles/particleSystemSet";
  52571. export * from "babylonjs/Particles/solidParticle";
  52572. export * from "babylonjs/Particles/solidParticleSystem";
  52573. export * from "babylonjs/Particles/subEmitter";
  52574. }
  52575. declare module "babylonjs/Physics/physicsEngineComponent" {
  52576. import { Nullable } from "babylonjs/types";
  52577. import { Observable, Observer } from "babylonjs/Misc/observable";
  52578. import { Vector3 } from "babylonjs/Maths/math";
  52579. import { Mesh } from "babylonjs/Meshes/mesh";
  52580. import { ISceneComponent } from "babylonjs/sceneComponent";
  52581. import { Scene } from "babylonjs/scene";
  52582. import { Node } from "babylonjs/node";
  52583. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52584. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52585. module "babylonjs/scene" {
  52586. interface Scene {
  52587. /** @hidden (Backing field) */
  52588. _physicsEngine: Nullable<IPhysicsEngine>;
  52589. /**
  52590. * Gets the current physics engine
  52591. * @returns a IPhysicsEngine or null if none attached
  52592. */
  52593. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52594. /**
  52595. * Enables physics to the current scene
  52596. * @param gravity defines the scene's gravity for the physics engine
  52597. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52598. * @return a boolean indicating if the physics engine was initialized
  52599. */
  52600. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52601. /**
  52602. * Disables and disposes the physics engine associated with the scene
  52603. */
  52604. disablePhysicsEngine(): void;
  52605. /**
  52606. * Gets a boolean indicating if there is an active physics engine
  52607. * @returns a boolean indicating if there is an active physics engine
  52608. */
  52609. isPhysicsEnabled(): boolean;
  52610. /**
  52611. * Deletes a physics compound impostor
  52612. * @param compound defines the compound to delete
  52613. */
  52614. deleteCompoundImpostor(compound: any): void;
  52615. /**
  52616. * An event triggered when physic simulation is about to be run
  52617. */
  52618. onBeforePhysicsObservable: Observable<Scene>;
  52619. /**
  52620. * An event triggered when physic simulation has been done
  52621. */
  52622. onAfterPhysicsObservable: Observable<Scene>;
  52623. }
  52624. }
  52625. module "babylonjs/Meshes/abstractMesh" {
  52626. interface AbstractMesh {
  52627. /** @hidden */
  52628. _physicsImpostor: Nullable<PhysicsImpostor>;
  52629. /**
  52630. * Gets or sets impostor used for physic simulation
  52631. * @see http://doc.babylonjs.com/features/physics_engine
  52632. */
  52633. physicsImpostor: Nullable<PhysicsImpostor>;
  52634. /**
  52635. * Gets the current physics impostor
  52636. * @see http://doc.babylonjs.com/features/physics_engine
  52637. * @returns a physics impostor or null
  52638. */
  52639. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52640. /** Apply a physic impulse to the mesh
  52641. * @param force defines the force to apply
  52642. * @param contactPoint defines where to apply the force
  52643. * @returns the current mesh
  52644. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52645. */
  52646. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52647. /**
  52648. * Creates a physic joint between two meshes
  52649. * @param otherMesh defines the other mesh to use
  52650. * @param pivot1 defines the pivot to use on this mesh
  52651. * @param pivot2 defines the pivot to use on the other mesh
  52652. * @param options defines additional options (can be plugin dependent)
  52653. * @returns the current mesh
  52654. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52655. */
  52656. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52657. /** @hidden */
  52658. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52659. }
  52660. }
  52661. /**
  52662. * Defines the physics engine scene component responsible to manage a physics engine
  52663. */
  52664. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52665. /**
  52666. * The component name helpful to identify the component in the list of scene components.
  52667. */
  52668. readonly name: string;
  52669. /**
  52670. * The scene the component belongs to.
  52671. */
  52672. scene: Scene;
  52673. /**
  52674. * Creates a new instance of the component for the given scene
  52675. * @param scene Defines the scene to register the component in
  52676. */
  52677. constructor(scene: Scene);
  52678. /**
  52679. * Registers the component in a given scene
  52680. */
  52681. register(): void;
  52682. /**
  52683. * Rebuilds the elements related to this component in case of
  52684. * context lost for instance.
  52685. */
  52686. rebuild(): void;
  52687. /**
  52688. * Disposes the component and the associated ressources
  52689. */
  52690. dispose(): void;
  52691. }
  52692. }
  52693. declare module "babylonjs/Physics/physicsHelper" {
  52694. import { Nullable } from "babylonjs/types";
  52695. import { Vector3 } from "babylonjs/Maths/math";
  52696. import { Mesh } from "babylonjs/Meshes/mesh";
  52697. import { Scene } from "babylonjs/scene";
  52698. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52699. /**
  52700. * A helper for physics simulations
  52701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52702. */
  52703. export class PhysicsHelper {
  52704. private _scene;
  52705. private _physicsEngine;
  52706. /**
  52707. * Initializes the Physics helper
  52708. * @param scene Babylon.js scene
  52709. */
  52710. constructor(scene: Scene);
  52711. /**
  52712. * Applies a radial explosion impulse
  52713. * @param origin the origin of the explosion
  52714. * @param radiusOrEventOptions the radius or the options of radial explosion
  52715. * @param strength the explosion strength
  52716. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52717. * @returns A physics radial explosion event, or null
  52718. */
  52719. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52720. /**
  52721. * Applies a radial explosion force
  52722. * @param origin the origin of the explosion
  52723. * @param radiusOrEventOptions the radius or the options of radial explosion
  52724. * @param strength the explosion strength
  52725. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52726. * @returns A physics radial explosion event, or null
  52727. */
  52728. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52729. /**
  52730. * Creates a gravitational field
  52731. * @param origin the origin of the explosion
  52732. * @param radiusOrEventOptions the radius or the options of radial explosion
  52733. * @param strength the explosion strength
  52734. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52735. * @returns A physics gravitational field event, or null
  52736. */
  52737. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52738. /**
  52739. * Creates a physics updraft event
  52740. * @param origin the origin of the updraft
  52741. * @param radiusOrEventOptions the radius or the options of the updraft
  52742. * @param strength the strength of the updraft
  52743. * @param height the height of the updraft
  52744. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52745. * @returns A physics updraft event, or null
  52746. */
  52747. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52748. /**
  52749. * Creates a physics vortex event
  52750. * @param origin the of the vortex
  52751. * @param radiusOrEventOptions the radius or the options of the vortex
  52752. * @param strength the strength of the vortex
  52753. * @param height the height of the vortex
  52754. * @returns a Physics vortex event, or null
  52755. * A physics vortex event or null
  52756. */
  52757. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  52758. }
  52759. /**
  52760. * Represents a physics radial explosion event
  52761. */
  52762. class PhysicsRadialExplosionEvent {
  52763. private _scene;
  52764. private _options;
  52765. private _sphere;
  52766. private _dataFetched;
  52767. /**
  52768. * Initializes a radial explosioin event
  52769. * @param _scene BabylonJS scene
  52770. * @param _options The options for the vortex event
  52771. */
  52772. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  52773. /**
  52774. * Returns the data related to the radial explosion event (sphere).
  52775. * @returns The radial explosion event data
  52776. */
  52777. getData(): PhysicsRadialExplosionEventData;
  52778. /**
  52779. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52780. * @param impostor A physics imposter
  52781. * @param origin the origin of the explosion
  52782. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52783. */
  52784. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  52785. /**
  52786. * Disposes the sphere.
  52787. * @param force Specifies if the sphere should be disposed by force
  52788. */
  52789. dispose(force?: boolean): void;
  52790. /*** Helpers ***/
  52791. private _prepareSphere;
  52792. private _intersectsWithSphere;
  52793. }
  52794. /**
  52795. * Represents a gravitational field event
  52796. */
  52797. class PhysicsGravitationalFieldEvent {
  52798. private _physicsHelper;
  52799. private _scene;
  52800. private _origin;
  52801. private _options;
  52802. private _tickCallback;
  52803. private _sphere;
  52804. private _dataFetched;
  52805. /**
  52806. * Initializes the physics gravitational field event
  52807. * @param _physicsHelper A physics helper
  52808. * @param _scene BabylonJS scene
  52809. * @param _origin The origin position of the gravitational field event
  52810. * @param _options The options for the vortex event
  52811. */
  52812. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52813. /**
  52814. * Returns the data related to the gravitational field event (sphere).
  52815. * @returns A gravitational field event
  52816. */
  52817. getData(): PhysicsGravitationalFieldEventData;
  52818. /**
  52819. * Enables the gravitational field.
  52820. */
  52821. enable(): void;
  52822. /**
  52823. * Disables the gravitational field.
  52824. */
  52825. disable(): void;
  52826. /**
  52827. * Disposes the sphere.
  52828. * @param force The force to dispose from the gravitational field event
  52829. */
  52830. dispose(force?: boolean): void;
  52831. private _tick;
  52832. }
  52833. /**
  52834. * Represents a physics updraft event
  52835. */
  52836. class PhysicsUpdraftEvent {
  52837. private _scene;
  52838. private _origin;
  52839. private _options;
  52840. private _physicsEngine;
  52841. private _originTop;
  52842. private _originDirection;
  52843. private _tickCallback;
  52844. private _cylinder;
  52845. private _cylinderPosition;
  52846. private _dataFetched;
  52847. /**
  52848. * Initializes the physics updraft event
  52849. * @param _scene BabylonJS scene
  52850. * @param _origin The origin position of the updraft
  52851. * @param _options The options for the updraft event
  52852. */
  52853. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52854. /**
  52855. * Returns the data related to the updraft event (cylinder).
  52856. * @returns A physics updraft event
  52857. */
  52858. getData(): PhysicsUpdraftEventData;
  52859. /**
  52860. * Enables the updraft.
  52861. */
  52862. enable(): void;
  52863. /**
  52864. * Disables the updraft.
  52865. */
  52866. disable(): void;
  52867. /**
  52868. * Disposes the cylinder.
  52869. * @param force Specifies if the updraft should be disposed by force
  52870. */
  52871. dispose(force?: boolean): void;
  52872. private getImpostorForceAndContactPoint;
  52873. private _tick;
  52874. /*** Helpers ***/
  52875. private _prepareCylinder;
  52876. private _intersectsWithCylinder;
  52877. }
  52878. /**
  52879. * Represents a physics vortex event
  52880. */
  52881. class PhysicsVortexEvent {
  52882. private _scene;
  52883. private _origin;
  52884. private _options;
  52885. private _physicsEngine;
  52886. private _originTop;
  52887. private _tickCallback;
  52888. private _cylinder;
  52889. private _cylinderPosition;
  52890. private _dataFetched;
  52891. /**
  52892. * Initializes the physics vortex event
  52893. * @param _scene The BabylonJS scene
  52894. * @param _origin The origin position of the vortex
  52895. * @param _options The options for the vortex event
  52896. */
  52897. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52898. /**
  52899. * Returns the data related to the vortex event (cylinder).
  52900. * @returns The physics vortex event data
  52901. */
  52902. getData(): PhysicsVortexEventData;
  52903. /**
  52904. * Enables the vortex.
  52905. */
  52906. enable(): void;
  52907. /**
  52908. * Disables the cortex.
  52909. */
  52910. disable(): void;
  52911. /**
  52912. * Disposes the sphere.
  52913. * @param force
  52914. */
  52915. dispose(force?: boolean): void;
  52916. private getImpostorForceAndContactPoint;
  52917. private _tick;
  52918. /*** Helpers ***/
  52919. private _prepareCylinder;
  52920. private _intersectsWithCylinder;
  52921. }
  52922. /**
  52923. * Options fot the radial explosion event
  52924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52925. */
  52926. export class PhysicsRadialExplosionEventOptions {
  52927. /**
  52928. * The radius of the sphere for the radial explosion.
  52929. */
  52930. radius: number;
  52931. /**
  52932. * The strenth of the explosion.
  52933. */
  52934. strength: number;
  52935. /**
  52936. * The strenght of the force in correspondence to the distance of the affected object
  52937. */
  52938. falloff: PhysicsRadialImpulseFalloff;
  52939. /**
  52940. * Sphere options for the radial explosion.
  52941. */
  52942. sphere: {
  52943. segments: number;
  52944. diameter: number;
  52945. };
  52946. }
  52947. /**
  52948. * Options fot the updraft event
  52949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52950. */
  52951. export class PhysicsUpdraftEventOptions {
  52952. /**
  52953. * The radius of the cylinder for the vortex
  52954. */
  52955. radius: number;
  52956. /**
  52957. * The strenth of the updraft.
  52958. */
  52959. strength: number;
  52960. /**
  52961. * The height of the cylinder for the updraft.
  52962. */
  52963. height: number;
  52964. /**
  52965. * The mode for the the updraft.
  52966. */
  52967. updraftMode: PhysicsUpdraftMode;
  52968. }
  52969. /**
  52970. * Options fot the vortex event
  52971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52972. */
  52973. export class PhysicsVortexEventOptions {
  52974. /**
  52975. * The radius of the cylinder for the vortex
  52976. */
  52977. radius: number;
  52978. /**
  52979. * The strenth of the vortex.
  52980. */
  52981. strength: number;
  52982. /**
  52983. * The height of the cylinder for the vortex.
  52984. */
  52985. height: number;
  52986. /**
  52987. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52988. */
  52989. centripetalForceThreshold: number;
  52990. /**
  52991. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52992. */
  52993. centripetalForceMultiplier: number;
  52994. /**
  52995. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52996. */
  52997. centrifugalForceMultiplier: number;
  52998. /**
  52999. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53000. */
  53001. updraftForceMultiplier: number;
  53002. }
  53003. /**
  53004. * The strenght of the force in correspondence to the distance of the affected object
  53005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53006. */
  53007. export enum PhysicsRadialImpulseFalloff {
  53008. /** Defines that impulse is constant in strength across it's whole radius */
  53009. Constant = 0,
  53010. /** Defines that impulse gets weaker if it's further from the origin */
  53011. Linear = 1
  53012. }
  53013. /**
  53014. * The strength of the force in correspondence to the distance of the affected object
  53015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53016. */
  53017. export enum PhysicsUpdraftMode {
  53018. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  53019. Center = 0,
  53020. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  53021. Perpendicular = 1
  53022. }
  53023. /**
  53024. * Interface for a physics force and contact point
  53025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53026. */
  53027. export interface PhysicsForceAndContactPoint {
  53028. /**
  53029. * The force applied at the contact point
  53030. */
  53031. force: Vector3;
  53032. /**
  53033. * The contact point
  53034. */
  53035. contactPoint: Vector3;
  53036. }
  53037. /**
  53038. * Interface for radial explosion event data
  53039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53040. */
  53041. export interface PhysicsRadialExplosionEventData {
  53042. /**
  53043. * A sphere used for the radial explosion event
  53044. */
  53045. sphere: Mesh;
  53046. }
  53047. /**
  53048. * Interface for gravitational field event data
  53049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53050. */
  53051. export interface PhysicsGravitationalFieldEventData {
  53052. /**
  53053. * A sphere mesh used for the gravitational field event
  53054. */
  53055. sphere: Mesh;
  53056. }
  53057. /**
  53058. * Interface for updraft event data
  53059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53060. */
  53061. export interface PhysicsUpdraftEventData {
  53062. /**
  53063. * A cylinder used for the updraft event
  53064. */
  53065. cylinder: Mesh;
  53066. }
  53067. /**
  53068. * Interface for vortex event data
  53069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53070. */
  53071. export interface PhysicsVortexEventData {
  53072. /**
  53073. * A cylinder used for the vortex event
  53074. */
  53075. cylinder: Mesh;
  53076. }
  53077. }
  53078. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53079. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  53080. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53081. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53082. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53083. import { Nullable } from "babylonjs/types";
  53084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53085. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53086. /**
  53087. * AmmoJS Physics plugin
  53088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53089. * @see https://github.com/kripken/ammo.js/
  53090. */
  53091. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53092. private _useDeltaForWorldStep;
  53093. /**
  53094. * Reference to the Ammo library
  53095. */
  53096. bjsAMMO: any;
  53097. /**
  53098. * Created ammoJS world which physics bodies are added to
  53099. */
  53100. world: any;
  53101. /**
  53102. * Name of the plugin
  53103. */
  53104. name: string;
  53105. private _timeStep;
  53106. private _fixedTimeStep;
  53107. private _maxSteps;
  53108. private _tmpQuaternion;
  53109. private _tmpAmmoTransform;
  53110. private _tmpAmmoQuaternion;
  53111. private _tmpAmmoConcreteContactResultCallback;
  53112. private _collisionConfiguration;
  53113. private _dispatcher;
  53114. private _overlappingPairCache;
  53115. private _solver;
  53116. private _softBodySolver;
  53117. private _tmpAmmoVectorA;
  53118. private _tmpAmmoVectorB;
  53119. private _tmpAmmoVectorC;
  53120. private _tmpAmmoVectorD;
  53121. private _tmpContactCallbackResult;
  53122. private _tmpAmmoVectorRCA;
  53123. private _tmpAmmoVectorRCB;
  53124. private _raycastResult;
  53125. private static readonly DISABLE_COLLISION_FLAG;
  53126. private static readonly KINEMATIC_FLAG;
  53127. private static readonly DISABLE_DEACTIVATION_FLAG;
  53128. /**
  53129. * Initializes the ammoJS plugin
  53130. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53131. * @param ammoInjection can be used to inject your own ammo reference
  53132. */
  53133. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  53134. /**
  53135. * Sets the gravity of the physics world (m/(s^2))
  53136. * @param gravity Gravity to set
  53137. */
  53138. setGravity(gravity: Vector3): void;
  53139. /**
  53140. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53141. * @param timeStep timestep to use in seconds
  53142. */
  53143. setTimeStep(timeStep: number): void;
  53144. /**
  53145. * 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)
  53146. * @param fixedTimeStep fixedTimeStep to use in seconds
  53147. */
  53148. setFixedTimeStep(fixedTimeStep: number): void;
  53149. /**
  53150. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53151. * @param maxSteps the maximum number of steps by the physics engine per frame
  53152. */
  53153. setMaxSteps(maxSteps: number): void;
  53154. /**
  53155. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53156. * @returns the current timestep in seconds
  53157. */
  53158. getTimeStep(): number;
  53159. private _isImpostorInContact;
  53160. private _isImpostorPairInContact;
  53161. private _stepSimulation;
  53162. /**
  53163. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53164. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53165. * After the step the babylon meshes are set to the position of the physics imposters
  53166. * @param delta amount of time to step forward
  53167. * @param impostors array of imposters to update before/after the step
  53168. */
  53169. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53170. /**
  53171. * Update babylon mesh to match physics world object
  53172. * @param impostor imposter to match
  53173. */
  53174. private _afterSoftStep;
  53175. /**
  53176. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53177. * @param impostor imposter to match
  53178. */
  53179. private _ropeStep;
  53180. /**
  53181. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53182. * @param impostor imposter to match
  53183. */
  53184. private _softbodyOrClothStep;
  53185. private _tmpVector;
  53186. private _tmpMatrix;
  53187. /**
  53188. * Applies an impulse on the imposter
  53189. * @param impostor imposter to apply impulse to
  53190. * @param force amount of force to be applied to the imposter
  53191. * @param contactPoint the location to apply the impulse on the imposter
  53192. */
  53193. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53194. /**
  53195. * Applies a force on the imposter
  53196. * @param impostor imposter to apply force
  53197. * @param force amount of force to be applied to the imposter
  53198. * @param contactPoint the location to apply the force on the imposter
  53199. */
  53200. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53201. /**
  53202. * Creates a physics body using the plugin
  53203. * @param impostor the imposter to create the physics body on
  53204. */
  53205. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53206. /**
  53207. * Removes the physics body from the imposter and disposes of the body's memory
  53208. * @param impostor imposter to remove the physics body from
  53209. */
  53210. removePhysicsBody(impostor: PhysicsImpostor): void;
  53211. /**
  53212. * Generates a joint
  53213. * @param impostorJoint the imposter joint to create the joint with
  53214. */
  53215. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53216. /**
  53217. * Removes a joint
  53218. * @param impostorJoint the imposter joint to remove the joint from
  53219. */
  53220. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53221. private _addMeshVerts;
  53222. /**
  53223. * Initialise the soft body vertices to match its object's (mesh) vertices
  53224. * Softbody vertices (nodes) are in world space and to match this
  53225. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53226. * @param impostor to create the softbody for
  53227. */
  53228. private _softVertexData;
  53229. /**
  53230. * Create an impostor's soft body
  53231. * @param impostor to create the softbody for
  53232. */
  53233. private _createSoftbody;
  53234. /**
  53235. * Create cloth for an impostor
  53236. * @param impostor to create the softbody for
  53237. */
  53238. private _createCloth;
  53239. /**
  53240. * Create rope for an impostor
  53241. * @param impostor to create the softbody for
  53242. */
  53243. private _createRope;
  53244. private _addHullVerts;
  53245. private _createShape;
  53246. /**
  53247. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53248. * @param impostor imposter containing the physics body and babylon object
  53249. */
  53250. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53251. /**
  53252. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53253. * @param impostor imposter containing the physics body and babylon object
  53254. * @param newPosition new position
  53255. * @param newRotation new rotation
  53256. */
  53257. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53258. /**
  53259. * If this plugin is supported
  53260. * @returns true if its supported
  53261. */
  53262. isSupported(): boolean;
  53263. /**
  53264. * Sets the linear velocity of the physics body
  53265. * @param impostor imposter to set the velocity on
  53266. * @param velocity velocity to set
  53267. */
  53268. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53269. /**
  53270. * Sets the angular velocity of the physics body
  53271. * @param impostor imposter to set the velocity on
  53272. * @param velocity velocity to set
  53273. */
  53274. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53275. /**
  53276. * gets the linear velocity
  53277. * @param impostor imposter to get linear velocity from
  53278. * @returns linear velocity
  53279. */
  53280. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53281. /**
  53282. * gets the angular velocity
  53283. * @param impostor imposter to get angular velocity from
  53284. * @returns angular velocity
  53285. */
  53286. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53287. /**
  53288. * Sets the mass of physics body
  53289. * @param impostor imposter to set the mass on
  53290. * @param mass mass to set
  53291. */
  53292. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53293. /**
  53294. * Gets the mass of the physics body
  53295. * @param impostor imposter to get the mass from
  53296. * @returns mass
  53297. */
  53298. getBodyMass(impostor: PhysicsImpostor): number;
  53299. /**
  53300. * Gets friction of the impostor
  53301. * @param impostor impostor to get friction from
  53302. * @returns friction value
  53303. */
  53304. getBodyFriction(impostor: PhysicsImpostor): number;
  53305. /**
  53306. * Sets friction of the impostor
  53307. * @param impostor impostor to set friction on
  53308. * @param friction friction value
  53309. */
  53310. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53311. /**
  53312. * Gets restitution of the impostor
  53313. * @param impostor impostor to get restitution from
  53314. * @returns restitution value
  53315. */
  53316. getBodyRestitution(impostor: PhysicsImpostor): number;
  53317. /**
  53318. * Sets resitution of the impostor
  53319. * @param impostor impostor to set resitution on
  53320. * @param restitution resitution value
  53321. */
  53322. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53323. /**
  53324. * Gets pressure inside the impostor
  53325. * @param impostor impostor to get pressure from
  53326. * @returns pressure value
  53327. */
  53328. getBodyPressure(impostor: PhysicsImpostor): number;
  53329. /**
  53330. * Sets pressure inside a soft body impostor
  53331. * Cloth and rope must remain 0 pressure
  53332. * @param impostor impostor to set pressure on
  53333. * @param pressure pressure value
  53334. */
  53335. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53336. /**
  53337. * Gets stiffness of the impostor
  53338. * @param impostor impostor to get stiffness from
  53339. * @returns pressure value
  53340. */
  53341. getBodyStiffness(impostor: PhysicsImpostor): number;
  53342. /**
  53343. * Sets stiffness of the impostor
  53344. * @param impostor impostor to set stiffness on
  53345. * @param stiffness stiffness value from 0 to 1
  53346. */
  53347. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53348. /**
  53349. * Gets velocityIterations of the impostor
  53350. * @param impostor impostor to get velocity iterations from
  53351. * @returns velocityIterations value
  53352. */
  53353. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53354. /**
  53355. * Sets velocityIterations of the impostor
  53356. * @param impostor impostor to set velocity iterations on
  53357. * @param velocityIterations velocityIterations value
  53358. */
  53359. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53360. /**
  53361. * Gets positionIterations of the impostor
  53362. * @param impostor impostor to get position iterations from
  53363. * @returns positionIterations value
  53364. */
  53365. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53366. /**
  53367. * Sets positionIterations of the impostor
  53368. * @param impostor impostor to set position on
  53369. * @param positionIterations positionIterations value
  53370. */
  53371. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53372. /**
  53373. * Append an anchor to a cloth object
  53374. * @param impostor is the cloth impostor to add anchor to
  53375. * @param otherImpostor is the rigid impostor to anchor to
  53376. * @param width ratio across width from 0 to 1
  53377. * @param height ratio up height from 0 to 1
  53378. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53379. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53380. */
  53381. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53382. /**
  53383. * Append an hook to a rope object
  53384. * @param impostor is the rope impostor to add hook to
  53385. * @param otherImpostor is the rigid impostor to hook to
  53386. * @param length ratio along the rope from 0 to 1
  53387. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53388. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53389. */
  53390. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53391. /**
  53392. * Sleeps the physics body and stops it from being active
  53393. * @param impostor impostor to sleep
  53394. */
  53395. sleepBody(impostor: PhysicsImpostor): void;
  53396. /**
  53397. * Activates the physics body
  53398. * @param impostor impostor to activate
  53399. */
  53400. wakeUpBody(impostor: PhysicsImpostor): void;
  53401. /**
  53402. * Updates the distance parameters of the joint
  53403. * @param joint joint to update
  53404. * @param maxDistance maximum distance of the joint
  53405. * @param minDistance minimum distance of the joint
  53406. */
  53407. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53408. /**
  53409. * Sets a motor on the joint
  53410. * @param joint joint to set motor on
  53411. * @param speed speed of the motor
  53412. * @param maxForce maximum force of the motor
  53413. * @param motorIndex index of the motor
  53414. */
  53415. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53416. /**
  53417. * Sets the motors limit
  53418. * @param joint joint to set limit on
  53419. * @param upperLimit upper limit
  53420. * @param lowerLimit lower limit
  53421. */
  53422. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53423. /**
  53424. * Syncs the position and rotation of a mesh with the impostor
  53425. * @param mesh mesh to sync
  53426. * @param impostor impostor to update the mesh with
  53427. */
  53428. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53429. /**
  53430. * Gets the radius of the impostor
  53431. * @param impostor impostor to get radius from
  53432. * @returns the radius
  53433. */
  53434. getRadius(impostor: PhysicsImpostor): number;
  53435. /**
  53436. * Gets the box size of the impostor
  53437. * @param impostor impostor to get box size from
  53438. * @param result the resulting box size
  53439. */
  53440. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53441. /**
  53442. * Disposes of the impostor
  53443. */
  53444. dispose(): void;
  53445. /**
  53446. * Does a raycast in the physics world
  53447. * @param from when should the ray start?
  53448. * @param to when should the ray end?
  53449. * @returns PhysicsRaycastResult
  53450. */
  53451. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53452. }
  53453. }
  53454. declare module "babylonjs/Physics/Plugins/index" {
  53455. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  53456. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  53457. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  53458. }
  53459. declare module "babylonjs/Physics/index" {
  53460. export * from "babylonjs/Physics/IPhysicsEngine";
  53461. export * from "babylonjs/Physics/physicsEngine";
  53462. export * from "babylonjs/Physics/physicsEngineComponent";
  53463. export * from "babylonjs/Physics/physicsHelper";
  53464. export * from "babylonjs/Physics/physicsImpostor";
  53465. export * from "babylonjs/Physics/physicsJoint";
  53466. export * from "babylonjs/Physics/Plugins/index";
  53467. }
  53468. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  53469. /** @hidden */
  53470. export var blackAndWhitePixelShader: {
  53471. name: string;
  53472. shader: string;
  53473. };
  53474. }
  53475. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  53476. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53477. import { Camera } from "babylonjs/Cameras/camera";
  53478. import { Engine } from "babylonjs/Engines/engine";
  53479. import "babylonjs/Shaders/blackAndWhite.fragment";
  53480. /**
  53481. * Post process used to render in black and white
  53482. */
  53483. export class BlackAndWhitePostProcess extends PostProcess {
  53484. /**
  53485. * Linear about to convert he result to black and white (default: 1)
  53486. */
  53487. degree: number;
  53488. /**
  53489. * Creates a black and white post process
  53490. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53491. * @param name The name of the effect.
  53492. * @param options The required width/height ratio to downsize to before computing the render pass.
  53493. * @param camera The camera to apply the render pass to.
  53494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53495. * @param engine The engine which the post process will be applied. (default: current engine)
  53496. * @param reusable If the post process can be reused on the same frame. (default: false)
  53497. */
  53498. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53499. }
  53500. }
  53501. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  53502. import { Nullable } from "babylonjs/types";
  53503. import { Camera } from "babylonjs/Cameras/camera";
  53504. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53505. import { Engine } from "babylonjs/Engines/engine";
  53506. /**
  53507. * This represents a set of one or more post processes in Babylon.
  53508. * A post process can be used to apply a shader to a texture after it is rendered.
  53509. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53510. */
  53511. export class PostProcessRenderEffect {
  53512. private _postProcesses;
  53513. private _getPostProcesses;
  53514. private _singleInstance;
  53515. private _cameras;
  53516. private _indicesForCamera;
  53517. /**
  53518. * Name of the effect
  53519. * @hidden
  53520. */
  53521. _name: string;
  53522. /**
  53523. * Instantiates a post process render effect.
  53524. * A post process can be used to apply a shader to a texture after it is rendered.
  53525. * @param engine The engine the effect is tied to
  53526. * @param name The name of the effect
  53527. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53528. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53529. */
  53530. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53531. /**
  53532. * Checks if all the post processes in the effect are supported.
  53533. */
  53534. readonly isSupported: boolean;
  53535. /**
  53536. * Updates the current state of the effect
  53537. * @hidden
  53538. */
  53539. _update(): void;
  53540. /**
  53541. * Attaches the effect on cameras
  53542. * @param cameras The camera to attach to.
  53543. * @hidden
  53544. */
  53545. _attachCameras(cameras: Camera): void;
  53546. /**
  53547. * Attaches the effect on cameras
  53548. * @param cameras The camera to attach to.
  53549. * @hidden
  53550. */
  53551. _attachCameras(cameras: Camera[]): void;
  53552. /**
  53553. * Detatches the effect on cameras
  53554. * @param cameras The camera to detatch from.
  53555. * @hidden
  53556. */
  53557. _detachCameras(cameras: Camera): void;
  53558. /**
  53559. * Detatches the effect on cameras
  53560. * @param cameras The camera to detatch from.
  53561. * @hidden
  53562. */
  53563. _detachCameras(cameras: Camera[]): void;
  53564. /**
  53565. * Enables the effect on given cameras
  53566. * @param cameras The camera to enable.
  53567. * @hidden
  53568. */
  53569. _enable(cameras: Camera): void;
  53570. /**
  53571. * Enables the effect on given cameras
  53572. * @param cameras The camera to enable.
  53573. * @hidden
  53574. */
  53575. _enable(cameras: Nullable<Camera[]>): void;
  53576. /**
  53577. * Disables the effect on the given cameras
  53578. * @param cameras The camera to disable.
  53579. * @hidden
  53580. */
  53581. _disable(cameras: Camera): void;
  53582. /**
  53583. * Disables the effect on the given cameras
  53584. * @param cameras The camera to disable.
  53585. * @hidden
  53586. */
  53587. _disable(cameras: Nullable<Camera[]>): void;
  53588. /**
  53589. * Gets a list of the post processes contained in the effect.
  53590. * @param camera The camera to get the post processes on.
  53591. * @returns The list of the post processes in the effect.
  53592. */
  53593. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53594. }
  53595. }
  53596. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  53597. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53598. /** @hidden */
  53599. export var extractHighlightsPixelShader: {
  53600. name: string;
  53601. shader: string;
  53602. };
  53603. }
  53604. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  53605. import { Nullable } from "babylonjs/types";
  53606. import { Camera } from "babylonjs/Cameras/camera";
  53607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53608. import { Engine } from "babylonjs/Engines/engine";
  53609. import "babylonjs/Shaders/extractHighlights.fragment";
  53610. /**
  53611. * 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.
  53612. */
  53613. export class ExtractHighlightsPostProcess extends PostProcess {
  53614. /**
  53615. * The luminance threshold, pixels below this value will be set to black.
  53616. */
  53617. threshold: number;
  53618. /** @hidden */
  53619. _exposure: number;
  53620. /**
  53621. * Post process which has the input texture to be used when performing highlight extraction
  53622. * @hidden
  53623. */
  53624. _inputPostProcess: Nullable<PostProcess>;
  53625. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53626. }
  53627. }
  53628. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  53629. /** @hidden */
  53630. export var bloomMergePixelShader: {
  53631. name: string;
  53632. shader: string;
  53633. };
  53634. }
  53635. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  53636. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53637. import { Nullable } from "babylonjs/types";
  53638. import { Engine } from "babylonjs/Engines/engine";
  53639. import { Camera } from "babylonjs/Cameras/camera";
  53640. import "babylonjs/Shaders/bloomMerge.fragment";
  53641. /**
  53642. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53643. */
  53644. export class BloomMergePostProcess extends PostProcess {
  53645. /** Weight of the bloom to be added to the original input. */
  53646. weight: number;
  53647. /**
  53648. * Creates a new instance of @see BloomMergePostProcess
  53649. * @param name The name of the effect.
  53650. * @param originalFromInput Post process which's input will be used for the merge.
  53651. * @param blurred Blurred highlights post process which's output will be used.
  53652. * @param weight Weight of the bloom to be added to the original input.
  53653. * @param options The required width/height ratio to downsize to before computing the render pass.
  53654. * @param camera The camera to apply the render pass to.
  53655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53656. * @param engine The engine which the post process will be applied. (default: current engine)
  53657. * @param reusable If the post process can be reused on the same frame. (default: false)
  53658. * @param textureType Type of textures used when performing the post process. (default: 0)
  53659. * @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)
  53660. */
  53661. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  53662. /** Weight of the bloom to be added to the original input. */
  53663. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53664. }
  53665. }
  53666. declare module "babylonjs/PostProcesses/bloomEffect" {
  53667. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53668. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53669. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53670. import { Camera } from "babylonjs/Cameras/camera";
  53671. import { Scene } from "babylonjs/scene";
  53672. /**
  53673. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  53674. */
  53675. export class BloomEffect extends PostProcessRenderEffect {
  53676. private bloomScale;
  53677. /**
  53678. * @hidden Internal
  53679. */
  53680. _effects: Array<PostProcess>;
  53681. /**
  53682. * @hidden Internal
  53683. */
  53684. _downscale: ExtractHighlightsPostProcess;
  53685. private _blurX;
  53686. private _blurY;
  53687. private _merge;
  53688. /**
  53689. * The luminance threshold to find bright areas of the image to bloom.
  53690. */
  53691. threshold: number;
  53692. /**
  53693. * The strength of the bloom.
  53694. */
  53695. weight: number;
  53696. /**
  53697. * Specifies the size of the bloom blur kernel, relative to the final output size
  53698. */
  53699. kernel: number;
  53700. /**
  53701. * Creates a new instance of @see BloomEffect
  53702. * @param scene The scene the effect belongs to.
  53703. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  53704. * @param bloomKernel The size of the kernel to be used when applying the blur.
  53705. * @param bloomWeight The the strength of bloom.
  53706. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53707. * @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)
  53708. */
  53709. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  53710. /**
  53711. * Disposes each of the internal effects for a given camera.
  53712. * @param camera The camera to dispose the effect on.
  53713. */
  53714. disposeEffects(camera: Camera): void;
  53715. /**
  53716. * @hidden Internal
  53717. */
  53718. _updateEffects(): void;
  53719. /**
  53720. * Internal
  53721. * @returns if all the contained post processes are ready.
  53722. * @hidden
  53723. */
  53724. _isReady(): boolean;
  53725. }
  53726. }
  53727. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  53728. /** @hidden */
  53729. export var chromaticAberrationPixelShader: {
  53730. name: string;
  53731. shader: string;
  53732. };
  53733. }
  53734. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  53735. import { Vector2 } from "babylonjs/Maths/math";
  53736. import { Nullable } from "babylonjs/types";
  53737. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53738. import { Camera } from "babylonjs/Cameras/camera";
  53739. import { Engine } from "babylonjs/Engines/engine";
  53740. import "babylonjs/Shaders/chromaticAberration.fragment";
  53741. /**
  53742. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53743. */
  53744. export class ChromaticAberrationPostProcess extends PostProcess {
  53745. /**
  53746. * The amount of seperation of rgb channels (default: 30)
  53747. */
  53748. aberrationAmount: number;
  53749. /**
  53750. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53751. */
  53752. radialIntensity: number;
  53753. /**
  53754. * 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))
  53755. */
  53756. direction: Vector2;
  53757. /**
  53758. * 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))
  53759. */
  53760. centerPosition: Vector2;
  53761. /**
  53762. * Creates a new instance ChromaticAberrationPostProcess
  53763. * @param name The name of the effect.
  53764. * @param screenWidth The width of the screen to apply the effect on.
  53765. * @param screenHeight The height of the screen to apply the effect on.
  53766. * @param options The required width/height ratio to downsize to before computing the render pass.
  53767. * @param camera The camera to apply the render pass to.
  53768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53769. * @param engine The engine which the post process will be applied. (default: current engine)
  53770. * @param reusable If the post process can be reused on the same frame. (default: false)
  53771. * @param textureType Type of textures used when performing the post process. (default: 0)
  53772. * @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)
  53773. */
  53774. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53775. }
  53776. }
  53777. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  53778. /** @hidden */
  53779. export var circleOfConfusionPixelShader: {
  53780. name: string;
  53781. shader: string;
  53782. };
  53783. }
  53784. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  53785. import { Nullable } from "babylonjs/types";
  53786. import { Engine } from "babylonjs/Engines/engine";
  53787. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53788. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53789. import { Camera } from "babylonjs/Cameras/camera";
  53790. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53791. /**
  53792. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53793. */
  53794. export class CircleOfConfusionPostProcess extends PostProcess {
  53795. /**
  53796. * 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.
  53797. */
  53798. lensSize: number;
  53799. /**
  53800. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53801. */
  53802. fStop: number;
  53803. /**
  53804. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53805. */
  53806. focusDistance: number;
  53807. /**
  53808. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53809. */
  53810. focalLength: number;
  53811. private _depthTexture;
  53812. /**
  53813. * Creates a new instance CircleOfConfusionPostProcess
  53814. * @param name The name of the effect.
  53815. * @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.
  53816. * @param options The required width/height ratio to downsize to before computing the render pass.
  53817. * @param camera The camera to apply the render pass to.
  53818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53819. * @param engine The engine which the post process will be applied. (default: current engine)
  53820. * @param reusable If the post process can be reused on the same frame. (default: false)
  53821. * @param textureType Type of textures used when performing the post process. (default: 0)
  53822. * @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)
  53823. */
  53824. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53825. /**
  53826. * 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.
  53827. */
  53828. depthTexture: RenderTargetTexture;
  53829. }
  53830. }
  53831. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53832. /** @hidden */
  53833. export var colorCorrectionPixelShader: {
  53834. name: string;
  53835. shader: string;
  53836. };
  53837. }
  53838. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53839. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53840. import { Engine } from "babylonjs/Engines/engine";
  53841. import { Camera } from "babylonjs/Cameras/camera";
  53842. import "babylonjs/Shaders/colorCorrection.fragment";
  53843. /**
  53844. *
  53845. * This post-process allows the modification of rendered colors by using
  53846. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53847. *
  53848. * The object needs to be provided an url to a texture containing the color
  53849. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53850. * Use an image editing software to tweak the LUT to match your needs.
  53851. *
  53852. * For an example of a color LUT, see here:
  53853. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53854. * For explanations on color grading, see here:
  53855. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53856. *
  53857. */
  53858. export class ColorCorrectionPostProcess extends PostProcess {
  53859. private _colorTableTexture;
  53860. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53861. }
  53862. }
  53863. declare module "babylonjs/Shaders/convolution.fragment" {
  53864. /** @hidden */
  53865. export var convolutionPixelShader: {
  53866. name: string;
  53867. shader: string;
  53868. };
  53869. }
  53870. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53871. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53872. import { Nullable } from "babylonjs/types";
  53873. import { Camera } from "babylonjs/Cameras/camera";
  53874. import { Engine } from "babylonjs/Engines/engine";
  53875. import "babylonjs/Shaders/convolution.fragment";
  53876. /**
  53877. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53878. * input texture to perform effects such as edge detection or sharpening
  53879. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53880. */
  53881. export class ConvolutionPostProcess extends PostProcess {
  53882. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53883. kernel: number[];
  53884. /**
  53885. * Creates a new instance ConvolutionPostProcess
  53886. * @param name The name of the effect.
  53887. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53888. * @param options The required width/height ratio to downsize to before computing the render pass.
  53889. * @param camera The camera to apply the render pass to.
  53890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53891. * @param engine The engine which the post process will be applied. (default: current engine)
  53892. * @param reusable If the post process can be reused on the same frame. (default: false)
  53893. * @param textureType Type of textures used when performing the post process. (default: 0)
  53894. */
  53895. constructor(name: string,
  53896. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53897. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53898. /**
  53899. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53900. */
  53901. static EdgeDetect0Kernel: number[];
  53902. /**
  53903. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53904. */
  53905. static EdgeDetect1Kernel: number[];
  53906. /**
  53907. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53908. */
  53909. static EdgeDetect2Kernel: number[];
  53910. /**
  53911. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53912. */
  53913. static SharpenKernel: number[];
  53914. /**
  53915. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53916. */
  53917. static EmbossKernel: number[];
  53918. /**
  53919. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53920. */
  53921. static GaussianKernel: number[];
  53922. }
  53923. }
  53924. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53925. import { Nullable } from "babylonjs/types";
  53926. import { Vector2 } from "babylonjs/Maths/math";
  53927. import { Camera } from "babylonjs/Cameras/camera";
  53928. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53929. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53930. import { Engine } from "babylonjs/Engines/engine";
  53931. import { Scene } from "babylonjs/scene";
  53932. /**
  53933. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53934. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53935. * based on samples that have a large difference in distance than the center pixel.
  53936. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53937. */
  53938. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53939. direction: Vector2;
  53940. /**
  53941. * Creates a new instance CircleOfConfusionPostProcess
  53942. * @param name The name of the effect.
  53943. * @param scene The scene the effect belongs to.
  53944. * @param direction The direction the blur should be applied.
  53945. * @param kernel The size of the kernel used to blur.
  53946. * @param options The required width/height ratio to downsize to before computing the render pass.
  53947. * @param camera The camera to apply the render pass to.
  53948. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53949. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53951. * @param engine The engine which the post process will be applied. (default: current engine)
  53952. * @param reusable If the post process can be reused on the same frame. (default: false)
  53953. * @param textureType Type of textures used when performing the post process. (default: 0)
  53954. * @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)
  53955. */
  53956. 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);
  53957. }
  53958. }
  53959. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53960. /** @hidden */
  53961. export var depthOfFieldMergePixelShader: {
  53962. name: string;
  53963. shader: string;
  53964. };
  53965. }
  53966. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53967. import { Nullable } from "babylonjs/types";
  53968. import { Camera } from "babylonjs/Cameras/camera";
  53969. import { Effect } from "babylonjs/Materials/effect";
  53970. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53971. import { Engine } from "babylonjs/Engines/engine";
  53972. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53973. /**
  53974. * Options to be set when merging outputs from the default pipeline.
  53975. */
  53976. export class DepthOfFieldMergePostProcessOptions {
  53977. /**
  53978. * The original image to merge on top of
  53979. */
  53980. originalFromInput: PostProcess;
  53981. /**
  53982. * Parameters to perform the merge of the depth of field effect
  53983. */
  53984. depthOfField?: {
  53985. circleOfConfusion: PostProcess;
  53986. blurSteps: Array<PostProcess>;
  53987. };
  53988. /**
  53989. * Parameters to perform the merge of bloom effect
  53990. */
  53991. bloom?: {
  53992. blurred: PostProcess;
  53993. weight: number;
  53994. };
  53995. }
  53996. /**
  53997. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53998. */
  53999. export class DepthOfFieldMergePostProcess extends PostProcess {
  54000. private blurSteps;
  54001. /**
  54002. * Creates a new instance of DepthOfFieldMergePostProcess
  54003. * @param name The name of the effect.
  54004. * @param originalFromInput Post process which's input will be used for the merge.
  54005. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54006. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54007. * @param options The required width/height ratio to downsize to before computing the render pass.
  54008. * @param camera The camera to apply the render pass to.
  54009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54010. * @param engine The engine which the post process will be applied. (default: current engine)
  54011. * @param reusable If the post process can be reused on the same frame. (default: false)
  54012. * @param textureType Type of textures used when performing the post process. (default: 0)
  54013. * @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)
  54014. */
  54015. 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);
  54016. /**
  54017. * Updates the effect with the current post process compile time values and recompiles the shader.
  54018. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54019. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54020. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54021. * @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
  54022. * @param onCompiled Called when the shader has been compiled.
  54023. * @param onError Called if there is an error when compiling a shader.
  54024. */
  54025. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54026. }
  54027. }
  54028. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54029. import { Nullable } from "babylonjs/types";
  54030. import { Camera } from "babylonjs/Cameras/camera";
  54031. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54032. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54033. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54034. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54035. import { Scene } from "babylonjs/scene";
  54036. /**
  54037. * Specifies the level of max blur that should be applied when using the depth of field effect
  54038. */
  54039. export enum DepthOfFieldEffectBlurLevel {
  54040. /**
  54041. * Subtle blur
  54042. */
  54043. Low = 0,
  54044. /**
  54045. * Medium blur
  54046. */
  54047. Medium = 1,
  54048. /**
  54049. * Large blur
  54050. */
  54051. High = 2
  54052. }
  54053. /**
  54054. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54055. */
  54056. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54057. private _circleOfConfusion;
  54058. /**
  54059. * @hidden Internal, blurs from high to low
  54060. */
  54061. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54062. private _depthOfFieldBlurY;
  54063. private _dofMerge;
  54064. /**
  54065. * @hidden Internal post processes in depth of field effect
  54066. */
  54067. _effects: Array<PostProcess>;
  54068. /**
  54069. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54070. */
  54071. focalLength: number;
  54072. /**
  54073. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54074. */
  54075. fStop: number;
  54076. /**
  54077. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54078. */
  54079. focusDistance: number;
  54080. /**
  54081. * 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.
  54082. */
  54083. lensSize: number;
  54084. /**
  54085. * Creates a new instance DepthOfFieldEffect
  54086. * @param scene The scene the effect belongs to.
  54087. * @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.
  54088. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54089. * @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)
  54090. */
  54091. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54092. /**
  54093. * 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.
  54094. */
  54095. depthTexture: RenderTargetTexture;
  54096. /**
  54097. * Disposes each of the internal effects for a given camera.
  54098. * @param camera The camera to dispose the effect on.
  54099. */
  54100. disposeEffects(camera: Camera): void;
  54101. /**
  54102. * @hidden Internal
  54103. */
  54104. _updateEffects(): void;
  54105. /**
  54106. * Internal
  54107. * @returns if all the contained post processes are ready.
  54108. * @hidden
  54109. */
  54110. _isReady(): boolean;
  54111. }
  54112. }
  54113. declare module "babylonjs/Shaders/displayPass.fragment" {
  54114. /** @hidden */
  54115. export var displayPassPixelShader: {
  54116. name: string;
  54117. shader: string;
  54118. };
  54119. }
  54120. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54121. import { Nullable } from "babylonjs/types";
  54122. import { Camera } from "babylonjs/Cameras/camera";
  54123. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54124. import { Engine } from "babylonjs/Engines/engine";
  54125. import "babylonjs/Shaders/displayPass.fragment";
  54126. /**
  54127. * DisplayPassPostProcess which produces an output the same as it's input
  54128. */
  54129. export class DisplayPassPostProcess extends PostProcess {
  54130. /**
  54131. * Creates the DisplayPassPostProcess
  54132. * @param name The name of the effect.
  54133. * @param options The required width/height ratio to downsize to before computing the render pass.
  54134. * @param camera The camera to apply the render pass to.
  54135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54136. * @param engine The engine which the post process will be applied. (default: current engine)
  54137. * @param reusable If the post process can be reused on the same frame. (default: false)
  54138. */
  54139. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54140. }
  54141. }
  54142. declare module "babylonjs/Shaders/filter.fragment" {
  54143. /** @hidden */
  54144. export var filterPixelShader: {
  54145. name: string;
  54146. shader: string;
  54147. };
  54148. }
  54149. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54150. import { Nullable } from "babylonjs/types";
  54151. import { Matrix } from "babylonjs/Maths/math";
  54152. import { Camera } from "babylonjs/Cameras/camera";
  54153. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54154. import { Engine } from "babylonjs/Engines/engine";
  54155. import "babylonjs/Shaders/filter.fragment";
  54156. /**
  54157. * Applies a kernel filter to the image
  54158. */
  54159. export class FilterPostProcess extends PostProcess {
  54160. /** The matrix to be applied to the image */
  54161. kernelMatrix: Matrix;
  54162. /**
  54163. *
  54164. * @param name The name of the effect.
  54165. * @param kernelMatrix The matrix to be applied to the image
  54166. * @param options The required width/height ratio to downsize to before computing the render pass.
  54167. * @param camera The camera to apply the render pass to.
  54168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54169. * @param engine The engine which the post process will be applied. (default: current engine)
  54170. * @param reusable If the post process can be reused on the same frame. (default: false)
  54171. */
  54172. constructor(name: string,
  54173. /** The matrix to be applied to the image */
  54174. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54175. }
  54176. }
  54177. declare module "babylonjs/Shaders/fxaa.fragment" {
  54178. /** @hidden */
  54179. export var fxaaPixelShader: {
  54180. name: string;
  54181. shader: string;
  54182. };
  54183. }
  54184. declare module "babylonjs/Shaders/fxaa.vertex" {
  54185. /** @hidden */
  54186. export var fxaaVertexShader: {
  54187. name: string;
  54188. shader: string;
  54189. };
  54190. }
  54191. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54192. import { Nullable } from "babylonjs/types";
  54193. import { Camera } from "babylonjs/Cameras/camera";
  54194. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54195. import { Engine } from "babylonjs/Engines/engine";
  54196. import "babylonjs/Shaders/fxaa.fragment";
  54197. import "babylonjs/Shaders/fxaa.vertex";
  54198. /**
  54199. * Fxaa post process
  54200. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54201. */
  54202. export class FxaaPostProcess extends PostProcess {
  54203. /** @hidden */
  54204. texelWidth: number;
  54205. /** @hidden */
  54206. texelHeight: number;
  54207. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54208. private _getDefines;
  54209. }
  54210. }
  54211. declare module "babylonjs/Shaders/grain.fragment" {
  54212. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54213. /** @hidden */
  54214. export var grainPixelShader: {
  54215. name: string;
  54216. shader: string;
  54217. };
  54218. }
  54219. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54220. import { Nullable } from "babylonjs/types";
  54221. import { Camera } from "babylonjs/Cameras/camera";
  54222. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54223. import { Engine } from "babylonjs/Engines/engine";
  54224. import "babylonjs/Shaders/grain.fragment";
  54225. /**
  54226. * The GrainPostProcess adds noise to the image at mid luminance levels
  54227. */
  54228. export class GrainPostProcess extends PostProcess {
  54229. /**
  54230. * The intensity of the grain added (default: 30)
  54231. */
  54232. intensity: number;
  54233. /**
  54234. * If the grain should be randomized on every frame
  54235. */
  54236. animated: boolean;
  54237. /**
  54238. * Creates a new instance of @see GrainPostProcess
  54239. * @param name The name of the effect.
  54240. * @param options The required width/height ratio to downsize to before computing the render pass.
  54241. * @param camera The camera to apply the render pass to.
  54242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54243. * @param engine The engine which the post process will be applied. (default: current engine)
  54244. * @param reusable If the post process can be reused on the same frame. (default: false)
  54245. * @param textureType Type of textures used when performing the post process. (default: 0)
  54246. * @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)
  54247. */
  54248. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54249. }
  54250. }
  54251. declare module "babylonjs/Shaders/highlights.fragment" {
  54252. /** @hidden */
  54253. export var highlightsPixelShader: {
  54254. name: string;
  54255. shader: string;
  54256. };
  54257. }
  54258. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54259. import { Nullable } from "babylonjs/types";
  54260. import { Camera } from "babylonjs/Cameras/camera";
  54261. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54262. import { Engine } from "babylonjs/Engines/engine";
  54263. import "babylonjs/Shaders/highlights.fragment";
  54264. /**
  54265. * Extracts highlights from the image
  54266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54267. */
  54268. export class HighlightsPostProcess extends PostProcess {
  54269. /**
  54270. * Extracts highlights from the image
  54271. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54272. * @param name The name of the effect.
  54273. * @param options The required width/height ratio to downsize to before computing the render pass.
  54274. * @param camera The camera to apply the render pass to.
  54275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54276. * @param engine The engine which the post process will be applied. (default: current engine)
  54277. * @param reusable If the post process can be reused on the same frame. (default: false)
  54278. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54279. */
  54280. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54281. }
  54282. }
  54283. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54284. /** @hidden */
  54285. export var mrtFragmentDeclaration: {
  54286. name: string;
  54287. shader: string;
  54288. };
  54289. }
  54290. declare module "babylonjs/Shaders/geometry.fragment" {
  54291. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54292. /** @hidden */
  54293. export var geometryPixelShader: {
  54294. name: string;
  54295. shader: string;
  54296. };
  54297. }
  54298. declare module "babylonjs/Shaders/geometry.vertex" {
  54299. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54300. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54301. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54302. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54303. /** @hidden */
  54304. export var geometryVertexShader: {
  54305. name: string;
  54306. shader: string;
  54307. };
  54308. }
  54309. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54310. import { Matrix } from "babylonjs/Maths/math";
  54311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54312. import { Mesh } from "babylonjs/Meshes/mesh";
  54313. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54314. import { Effect } from "babylonjs/Materials/effect";
  54315. import { Scene } from "babylonjs/scene";
  54316. import "babylonjs/Shaders/geometry.fragment";
  54317. import "babylonjs/Shaders/geometry.vertex";
  54318. /**
  54319. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54320. */
  54321. export class GeometryBufferRenderer {
  54322. /**
  54323. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54324. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54325. */
  54326. static readonly POSITION_TEXTURE_TYPE: number;
  54327. /**
  54328. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54329. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54330. */
  54331. static readonly VELOCITY_TEXTURE_TYPE: number;
  54332. /**
  54333. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54334. * in order to compute objects velocities when enableVelocity is set to "true"
  54335. * @hidden
  54336. */
  54337. _previousTransformationMatrices: {
  54338. [index: number]: Matrix;
  54339. };
  54340. private _scene;
  54341. private _multiRenderTarget;
  54342. private _ratio;
  54343. private _enablePosition;
  54344. private _enableVelocity;
  54345. private _positionIndex;
  54346. private _velocityIndex;
  54347. protected _effect: Effect;
  54348. protected _cachedDefines: string;
  54349. /**
  54350. * Set the render list (meshes to be rendered) used in the G buffer.
  54351. */
  54352. renderList: Mesh[];
  54353. /**
  54354. * Gets wether or not G buffer are supported by the running hardware.
  54355. * This requires draw buffer supports
  54356. */
  54357. readonly isSupported: boolean;
  54358. /**
  54359. * Returns the index of the given texture type in the G-Buffer textures array
  54360. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54361. * @returns the index of the given texture type in the G-Buffer textures array
  54362. */
  54363. getTextureIndex(textureType: number): number;
  54364. /**
  54365. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54366. */
  54367. /**
  54368. * Sets whether or not objects positions are enabled for the G buffer.
  54369. */
  54370. enablePosition: boolean;
  54371. /**
  54372. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54373. */
  54374. /**
  54375. * Sets wether or not objects velocities are enabled for the G buffer.
  54376. */
  54377. enableVelocity: boolean;
  54378. /**
  54379. * Gets the scene associated with the buffer.
  54380. */
  54381. readonly scene: Scene;
  54382. /**
  54383. * Gets the ratio used by the buffer during its creation.
  54384. * How big is the buffer related to the main canvas.
  54385. */
  54386. readonly ratio: number;
  54387. /** @hidden */
  54388. static _SceneComponentInitialization: (scene: Scene) => void;
  54389. /**
  54390. * Creates a new G Buffer for the scene
  54391. * @param scene The scene the buffer belongs to
  54392. * @param ratio How big is the buffer related to the main canvas.
  54393. */
  54394. constructor(scene: Scene, ratio?: number);
  54395. /**
  54396. * Checks wether everything is ready to render a submesh to the G buffer.
  54397. * @param subMesh the submesh to check readiness for
  54398. * @param useInstances is the mesh drawn using instance or not
  54399. * @returns true if ready otherwise false
  54400. */
  54401. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54402. /**
  54403. * Gets the current underlying G Buffer.
  54404. * @returns the buffer
  54405. */
  54406. getGBuffer(): MultiRenderTarget;
  54407. /**
  54408. * Gets the number of samples used to render the buffer (anti aliasing).
  54409. */
  54410. /**
  54411. * Sets the number of samples used to render the buffer (anti aliasing).
  54412. */
  54413. samples: number;
  54414. /**
  54415. * Disposes the renderer and frees up associated resources.
  54416. */
  54417. dispose(): void;
  54418. protected _createRenderTargets(): void;
  54419. }
  54420. }
  54421. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54422. import { Nullable } from "babylonjs/types";
  54423. import { Scene } from "babylonjs/scene";
  54424. import { ISceneComponent } from "babylonjs/sceneComponent";
  54425. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54426. module "babylonjs/scene" {
  54427. interface Scene {
  54428. /** @hidden (Backing field) */
  54429. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54430. /**
  54431. * Gets or Sets the current geometry buffer associated to the scene.
  54432. */
  54433. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54434. /**
  54435. * Enables a GeometryBufferRender and associates it with the scene
  54436. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54437. * @returns the GeometryBufferRenderer
  54438. */
  54439. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54440. /**
  54441. * Disables the GeometryBufferRender associated with the scene
  54442. */
  54443. disableGeometryBufferRenderer(): void;
  54444. }
  54445. }
  54446. /**
  54447. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54448. * in several rendering techniques.
  54449. */
  54450. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54451. /**
  54452. * The component name helpful to identify the component in the list of scene components.
  54453. */
  54454. readonly name: string;
  54455. /**
  54456. * The scene the component belongs to.
  54457. */
  54458. scene: Scene;
  54459. /**
  54460. * Creates a new instance of the component for the given scene
  54461. * @param scene Defines the scene to register the component in
  54462. */
  54463. constructor(scene: Scene);
  54464. /**
  54465. * Registers the component in a given scene
  54466. */
  54467. register(): void;
  54468. /**
  54469. * Rebuilds the elements related to this component in case of
  54470. * context lost for instance.
  54471. */
  54472. rebuild(): void;
  54473. /**
  54474. * Disposes the component and the associated ressources
  54475. */
  54476. dispose(): void;
  54477. private _gatherRenderTargets;
  54478. }
  54479. }
  54480. declare module "babylonjs/Shaders/motionBlur.fragment" {
  54481. /** @hidden */
  54482. export var motionBlurPixelShader: {
  54483. name: string;
  54484. shader: string;
  54485. };
  54486. }
  54487. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  54488. import { Nullable } from "babylonjs/types";
  54489. import { Camera } from "babylonjs/Cameras/camera";
  54490. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54491. import { Scene } from "babylonjs/scene";
  54492. import "babylonjs/Animations/animatable";
  54493. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54494. import "babylonjs/Shaders/motionBlur.fragment";
  54495. import { Engine } from "babylonjs/Engines/engine";
  54496. /**
  54497. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54498. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54499. * As an example, all you have to do is to create the post-process:
  54500. * var mb = new BABYLON.MotionBlurPostProcess(
  54501. * 'mb', // The name of the effect.
  54502. * scene, // The scene containing the objects to blur according to their velocity.
  54503. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54504. * camera // The camera to apply the render pass to.
  54505. * );
  54506. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54507. */
  54508. export class MotionBlurPostProcess extends PostProcess {
  54509. /**
  54510. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54511. */
  54512. motionStrength: number;
  54513. /**
  54514. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54515. */
  54516. /**
  54517. * Sets the number of iterations to be used for motion blur quality
  54518. */
  54519. motionBlurSamples: number;
  54520. private _motionBlurSamples;
  54521. private _geometryBufferRenderer;
  54522. /**
  54523. * Creates a new instance MotionBlurPostProcess
  54524. * @param name The name of the effect.
  54525. * @param scene The scene containing the objects to blur according to their velocity.
  54526. * @param options The required width/height ratio to downsize to before computing the render pass.
  54527. * @param camera The camera to apply the render pass to.
  54528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54529. * @param engine The engine which the post process will be applied. (default: current engine)
  54530. * @param reusable If the post process can be reused on the same frame. (default: false)
  54531. * @param textureType Type of textures used when performing the post process. (default: 0)
  54532. * @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)
  54533. */
  54534. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54535. /**
  54536. * Disposes the post process.
  54537. * @param camera The camera to dispose the post process on.
  54538. */
  54539. dispose(camera?: Camera): void;
  54540. }
  54541. }
  54542. declare module "babylonjs/Shaders/refraction.fragment" {
  54543. /** @hidden */
  54544. export var refractionPixelShader: {
  54545. name: string;
  54546. shader: string;
  54547. };
  54548. }
  54549. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  54550. import { Color3 } from "babylonjs/Maths/math";
  54551. import { Camera } from "babylonjs/Cameras/camera";
  54552. import { Texture } from "babylonjs/Materials/Textures/texture";
  54553. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54554. import { Engine } from "babylonjs/Engines/engine";
  54555. import "babylonjs/Shaders/refraction.fragment";
  54556. /**
  54557. * Post process which applies a refractin texture
  54558. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54559. */
  54560. export class RefractionPostProcess extends PostProcess {
  54561. /** the base color of the refraction (used to taint the rendering) */
  54562. color: Color3;
  54563. /** simulated refraction depth */
  54564. depth: number;
  54565. /** the coefficient of the base color (0 to remove base color tainting) */
  54566. colorLevel: number;
  54567. private _refTexture;
  54568. private _ownRefractionTexture;
  54569. /**
  54570. * Gets or sets the refraction texture
  54571. * Please note that you are responsible for disposing the texture if you set it manually
  54572. */
  54573. refractionTexture: Texture;
  54574. /**
  54575. * Initializes the RefractionPostProcess
  54576. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54577. * @param name The name of the effect.
  54578. * @param refractionTextureUrl Url of the refraction texture to use
  54579. * @param color the base color of the refraction (used to taint the rendering)
  54580. * @param depth simulated refraction depth
  54581. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54582. * @param camera The camera to apply the render pass to.
  54583. * @param options The required width/height ratio to downsize to before computing the render pass.
  54584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54585. * @param engine The engine which the post process will be applied. (default: current engine)
  54586. * @param reusable If the post process can be reused on the same frame. (default: false)
  54587. */
  54588. constructor(name: string, refractionTextureUrl: string,
  54589. /** the base color of the refraction (used to taint the rendering) */
  54590. color: Color3,
  54591. /** simulated refraction depth */
  54592. depth: number,
  54593. /** the coefficient of the base color (0 to remove base color tainting) */
  54594. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54595. /**
  54596. * Disposes of the post process
  54597. * @param camera Camera to dispose post process on
  54598. */
  54599. dispose(camera: Camera): void;
  54600. }
  54601. }
  54602. declare module "babylonjs/Shaders/sharpen.fragment" {
  54603. /** @hidden */
  54604. export var sharpenPixelShader: {
  54605. name: string;
  54606. shader: string;
  54607. };
  54608. }
  54609. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  54610. import { Nullable } from "babylonjs/types";
  54611. import { Camera } from "babylonjs/Cameras/camera";
  54612. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54613. import "babylonjs/Shaders/sharpen.fragment";
  54614. import { Engine } from "babylonjs/Engines/engine";
  54615. /**
  54616. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54617. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54618. */
  54619. export class SharpenPostProcess extends PostProcess {
  54620. /**
  54621. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54622. */
  54623. colorAmount: number;
  54624. /**
  54625. * How much sharpness should be applied (default: 0.3)
  54626. */
  54627. edgeAmount: number;
  54628. /**
  54629. * Creates a new instance ConvolutionPostProcess
  54630. * @param name The name of the effect.
  54631. * @param options The required width/height ratio to downsize to before computing the render pass.
  54632. * @param camera The camera to apply the render pass to.
  54633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54634. * @param engine The engine which the post process will be applied. (default: current engine)
  54635. * @param reusable If the post process can be reused on the same frame. (default: false)
  54636. * @param textureType Type of textures used when performing the post process. (default: 0)
  54637. * @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)
  54638. */
  54639. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54640. }
  54641. }
  54642. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  54643. import { Nullable } from "babylonjs/types";
  54644. import { Camera } from "babylonjs/Cameras/camera";
  54645. import { Engine } from "babylonjs/Engines/engine";
  54646. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54647. import { IInspectable } from "babylonjs/Misc/iInspectable";
  54648. /**
  54649. * PostProcessRenderPipeline
  54650. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54651. */
  54652. export class PostProcessRenderPipeline {
  54653. private engine;
  54654. private _renderEffects;
  54655. private _renderEffectsForIsolatedPass;
  54656. /**
  54657. * List of inspectable custom properties (used by the Inspector)
  54658. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  54659. */
  54660. inspectableCustomProperties: IInspectable[];
  54661. /**
  54662. * @hidden
  54663. */
  54664. protected _cameras: Camera[];
  54665. /** @hidden */
  54666. _name: string;
  54667. /**
  54668. * Gets pipeline name
  54669. */
  54670. readonly name: string;
  54671. /**
  54672. * Initializes a PostProcessRenderPipeline
  54673. * @param engine engine to add the pipeline to
  54674. * @param name name of the pipeline
  54675. */
  54676. constructor(engine: Engine, name: string);
  54677. /**
  54678. * Gets the class name
  54679. * @returns "PostProcessRenderPipeline"
  54680. */
  54681. getClassName(): string;
  54682. /**
  54683. * If all the render effects in the pipeline are supported
  54684. */
  54685. readonly isSupported: boolean;
  54686. /**
  54687. * Adds an effect to the pipeline
  54688. * @param renderEffect the effect to add
  54689. */
  54690. addEffect(renderEffect: PostProcessRenderEffect): void;
  54691. /** @hidden */
  54692. _rebuild(): void;
  54693. /** @hidden */
  54694. _enableEffect(renderEffectName: string, cameras: Camera): void;
  54695. /** @hidden */
  54696. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  54697. /** @hidden */
  54698. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54699. /** @hidden */
  54700. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54701. /** @hidden */
  54702. _attachCameras(cameras: Camera, unique: boolean): void;
  54703. /** @hidden */
  54704. _attachCameras(cameras: Camera[], unique: boolean): void;
  54705. /** @hidden */
  54706. _detachCameras(cameras: Camera): void;
  54707. /** @hidden */
  54708. _detachCameras(cameras: Nullable<Camera[]>): void;
  54709. /** @hidden */
  54710. _update(): void;
  54711. /** @hidden */
  54712. _reset(): void;
  54713. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  54714. /**
  54715. * Disposes of the pipeline
  54716. */
  54717. dispose(): void;
  54718. }
  54719. }
  54720. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54721. import { Camera } from "babylonjs/Cameras/camera";
  54722. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54723. /**
  54724. * PostProcessRenderPipelineManager class
  54725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54726. */
  54727. export class PostProcessRenderPipelineManager {
  54728. private _renderPipelines;
  54729. /**
  54730. * Initializes a PostProcessRenderPipelineManager
  54731. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54732. */
  54733. constructor();
  54734. /**
  54735. * Gets the list of supported render pipelines
  54736. */
  54737. readonly supportedPipelines: PostProcessRenderPipeline[];
  54738. /**
  54739. * Adds a pipeline to the manager
  54740. * @param renderPipeline The pipeline to add
  54741. */
  54742. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54743. /**
  54744. * Attaches a camera to the pipeline
  54745. * @param renderPipelineName The name of the pipeline to attach to
  54746. * @param cameras the camera to attach
  54747. * @param unique if the camera can be attached multiple times to the pipeline
  54748. */
  54749. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54750. /**
  54751. * Detaches a camera from the pipeline
  54752. * @param renderPipelineName The name of the pipeline to detach from
  54753. * @param cameras the camera to detach
  54754. */
  54755. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54756. /**
  54757. * Enables an effect by name on a pipeline
  54758. * @param renderPipelineName the name of the pipeline to enable the effect in
  54759. * @param renderEffectName the name of the effect to enable
  54760. * @param cameras the cameras that the effect should be enabled on
  54761. */
  54762. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54763. /**
  54764. * Disables an effect by name on a pipeline
  54765. * @param renderPipelineName the name of the pipeline to disable the effect in
  54766. * @param renderEffectName the name of the effect to disable
  54767. * @param cameras the cameras that the effect should be disabled on
  54768. */
  54769. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54770. /**
  54771. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54772. */
  54773. update(): void;
  54774. /** @hidden */
  54775. _rebuild(): void;
  54776. /**
  54777. * Disposes of the manager and pipelines
  54778. */
  54779. dispose(): void;
  54780. }
  54781. }
  54782. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54783. import { ISceneComponent } from "babylonjs/sceneComponent";
  54784. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54785. import { Scene } from "babylonjs/scene";
  54786. module "babylonjs/scene" {
  54787. interface Scene {
  54788. /** @hidden (Backing field) */
  54789. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54790. /**
  54791. * Gets the postprocess render pipeline manager
  54792. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54793. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54794. */
  54795. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54796. }
  54797. }
  54798. /**
  54799. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54800. */
  54801. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54802. /**
  54803. * The component name helpfull to identify the component in the list of scene components.
  54804. */
  54805. readonly name: string;
  54806. /**
  54807. * The scene the component belongs to.
  54808. */
  54809. scene: Scene;
  54810. /**
  54811. * Creates a new instance of the component for the given scene
  54812. * @param scene Defines the scene to register the component in
  54813. */
  54814. constructor(scene: Scene);
  54815. /**
  54816. * Registers the component in a given scene
  54817. */
  54818. register(): void;
  54819. /**
  54820. * Rebuilds the elements related to this component in case of
  54821. * context lost for instance.
  54822. */
  54823. rebuild(): void;
  54824. /**
  54825. * Disposes the component and the associated ressources
  54826. */
  54827. dispose(): void;
  54828. private _gatherRenderTargets;
  54829. }
  54830. }
  54831. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54832. import { IAnimatable } from "babylonjs/Misc/tools";
  54833. import { Camera } from "babylonjs/Cameras/camera";
  54834. import { IDisposable } from "babylonjs/scene";
  54835. import { Scene } from "babylonjs/scene";
  54836. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54837. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54838. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54839. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54840. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54841. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54842. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54843. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54844. import { Animation } from "babylonjs/Animations/animation";
  54845. /**
  54846. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54847. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54848. */
  54849. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54850. private _scene;
  54851. private _camerasToBeAttached;
  54852. /**
  54853. * ID of the sharpen post process,
  54854. */
  54855. private readonly SharpenPostProcessId;
  54856. /**
  54857. * @ignore
  54858. * ID of the image processing post process;
  54859. */
  54860. readonly ImageProcessingPostProcessId: string;
  54861. /**
  54862. * @ignore
  54863. * ID of the Fast Approximate Anti-Aliasing post process;
  54864. */
  54865. readonly FxaaPostProcessId: string;
  54866. /**
  54867. * ID of the chromatic aberration post process,
  54868. */
  54869. private readonly ChromaticAberrationPostProcessId;
  54870. /**
  54871. * ID of the grain post process
  54872. */
  54873. private readonly GrainPostProcessId;
  54874. /**
  54875. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54876. */
  54877. sharpen: SharpenPostProcess;
  54878. private _sharpenEffect;
  54879. private bloom;
  54880. /**
  54881. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54882. */
  54883. depthOfField: DepthOfFieldEffect;
  54884. /**
  54885. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54886. */
  54887. fxaa: FxaaPostProcess;
  54888. /**
  54889. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54890. */
  54891. imageProcessing: ImageProcessingPostProcess;
  54892. /**
  54893. * Chromatic aberration post process which will shift rgb colors in the image
  54894. */
  54895. chromaticAberration: ChromaticAberrationPostProcess;
  54896. private _chromaticAberrationEffect;
  54897. /**
  54898. * Grain post process which add noise to the image
  54899. */
  54900. grain: GrainPostProcess;
  54901. private _grainEffect;
  54902. /**
  54903. * Glow post process which adds a glow to emissive areas of the image
  54904. */
  54905. private _glowLayer;
  54906. /**
  54907. * Animations which can be used to tweak settings over a period of time
  54908. */
  54909. animations: Animation[];
  54910. private _imageProcessingConfigurationObserver;
  54911. private _sharpenEnabled;
  54912. private _bloomEnabled;
  54913. private _depthOfFieldEnabled;
  54914. private _depthOfFieldBlurLevel;
  54915. private _fxaaEnabled;
  54916. private _imageProcessingEnabled;
  54917. private _defaultPipelineTextureType;
  54918. private _bloomScale;
  54919. private _chromaticAberrationEnabled;
  54920. private _grainEnabled;
  54921. private _buildAllowed;
  54922. /**
  54923. * Gets active scene
  54924. */
  54925. readonly scene: Scene;
  54926. /**
  54927. * Enable or disable the sharpen process from the pipeline
  54928. */
  54929. sharpenEnabled: boolean;
  54930. private _resizeObserver;
  54931. private _hardwareScaleLevel;
  54932. private _bloomKernel;
  54933. /**
  54934. * Specifies the size of the bloom blur kernel, relative to the final output size
  54935. */
  54936. bloomKernel: number;
  54937. /**
  54938. * Specifies the weight of the bloom in the final rendering
  54939. */
  54940. private _bloomWeight;
  54941. /**
  54942. * Specifies the luma threshold for the area that will be blurred by the bloom
  54943. */
  54944. private _bloomThreshold;
  54945. private _hdr;
  54946. /**
  54947. * The strength of the bloom.
  54948. */
  54949. bloomWeight: number;
  54950. /**
  54951. * The strength of the bloom.
  54952. */
  54953. bloomThreshold: number;
  54954. /**
  54955. * The scale of the bloom, lower value will provide better performance.
  54956. */
  54957. bloomScale: number;
  54958. /**
  54959. * Enable or disable the bloom from the pipeline
  54960. */
  54961. bloomEnabled: boolean;
  54962. private _rebuildBloom;
  54963. /**
  54964. * If the depth of field is enabled.
  54965. */
  54966. depthOfFieldEnabled: boolean;
  54967. /**
  54968. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54969. */
  54970. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54971. /**
  54972. * If the anti aliasing is enabled.
  54973. */
  54974. fxaaEnabled: boolean;
  54975. private _samples;
  54976. /**
  54977. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54978. */
  54979. samples: number;
  54980. /**
  54981. * If image processing is enabled.
  54982. */
  54983. imageProcessingEnabled: boolean;
  54984. /**
  54985. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54986. */
  54987. glowLayerEnabled: boolean;
  54988. /**
  54989. * Enable or disable the chromaticAberration process from the pipeline
  54990. */
  54991. chromaticAberrationEnabled: boolean;
  54992. /**
  54993. * Enable or disable the grain process from the pipeline
  54994. */
  54995. grainEnabled: boolean;
  54996. /**
  54997. * @constructor
  54998. * @param name - The rendering pipeline name (default: "")
  54999. * @param hdr - If high dynamic range textures should be used (default: true)
  55000. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55001. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55002. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55003. */
  55004. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55005. /**
  55006. * Get the class name
  55007. * @returns "DefaultRenderingPipeline"
  55008. */
  55009. getClassName(): string;
  55010. /**
  55011. * Force the compilation of the entire pipeline.
  55012. */
  55013. prepare(): void;
  55014. private _hasCleared;
  55015. private _prevPostProcess;
  55016. private _prevPrevPostProcess;
  55017. private _setAutoClearAndTextureSharing;
  55018. private _depthOfFieldSceneObserver;
  55019. private _buildPipeline;
  55020. private _disposePostProcesses;
  55021. /**
  55022. * Adds a camera to the pipeline
  55023. * @param camera the camera to be added
  55024. */
  55025. addCamera(camera: Camera): void;
  55026. /**
  55027. * Removes a camera from the pipeline
  55028. * @param camera the camera to remove
  55029. */
  55030. removeCamera(camera: Camera): void;
  55031. /**
  55032. * Dispose of the pipeline and stop all post processes
  55033. */
  55034. dispose(): void;
  55035. /**
  55036. * Serialize the rendering pipeline (Used when exporting)
  55037. * @returns the serialized object
  55038. */
  55039. serialize(): any;
  55040. /**
  55041. * Parse the serialized pipeline
  55042. * @param source Source pipeline.
  55043. * @param scene The scene to load the pipeline to.
  55044. * @param rootUrl The URL of the serialized pipeline.
  55045. * @returns An instantiated pipeline from the serialized object.
  55046. */
  55047. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55048. }
  55049. }
  55050. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55051. /** @hidden */
  55052. export var lensHighlightsPixelShader: {
  55053. name: string;
  55054. shader: string;
  55055. };
  55056. }
  55057. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55058. /** @hidden */
  55059. export var depthOfFieldPixelShader: {
  55060. name: string;
  55061. shader: string;
  55062. };
  55063. }
  55064. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55065. import { Camera } from "babylonjs/Cameras/camera";
  55066. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55067. import { Scene } from "babylonjs/scene";
  55068. import "babylonjs/Shaders/chromaticAberration.fragment";
  55069. import "babylonjs/Shaders/lensHighlights.fragment";
  55070. import "babylonjs/Shaders/depthOfField.fragment";
  55071. /**
  55072. * BABYLON.JS Chromatic Aberration GLSL Shader
  55073. * Author: Olivier Guyot
  55074. * Separates very slightly R, G and B colors on the edges of the screen
  55075. * Inspired by Francois Tarlier & Martins Upitis
  55076. */
  55077. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55078. /**
  55079. * @ignore
  55080. * The chromatic aberration PostProcess id in the pipeline
  55081. */
  55082. LensChromaticAberrationEffect: string;
  55083. /**
  55084. * @ignore
  55085. * The highlights enhancing PostProcess id in the pipeline
  55086. */
  55087. HighlightsEnhancingEffect: string;
  55088. /**
  55089. * @ignore
  55090. * The depth-of-field PostProcess id in the pipeline
  55091. */
  55092. LensDepthOfFieldEffect: string;
  55093. private _scene;
  55094. private _depthTexture;
  55095. private _grainTexture;
  55096. private _chromaticAberrationPostProcess;
  55097. private _highlightsPostProcess;
  55098. private _depthOfFieldPostProcess;
  55099. private _edgeBlur;
  55100. private _grainAmount;
  55101. private _chromaticAberration;
  55102. private _distortion;
  55103. private _highlightsGain;
  55104. private _highlightsThreshold;
  55105. private _dofDistance;
  55106. private _dofAperture;
  55107. private _dofDarken;
  55108. private _dofPentagon;
  55109. private _blurNoise;
  55110. /**
  55111. * @constructor
  55112. *
  55113. * Effect parameters are as follow:
  55114. * {
  55115. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55116. * edge_blur: number; // from 0 to x (1 for realism)
  55117. * distortion: number; // from 0 to x (1 for realism)
  55118. * grain_amount: number; // from 0 to 1
  55119. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55120. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55121. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55122. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55123. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55124. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55125. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55126. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55127. * }
  55128. * Note: if an effect parameter is unset, effect is disabled
  55129. *
  55130. * @param name The rendering pipeline name
  55131. * @param parameters - An object containing all parameters (see above)
  55132. * @param scene The scene linked to this pipeline
  55133. * @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)
  55134. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55135. */
  55136. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55137. /**
  55138. * Get the class name
  55139. * @returns "LensRenderingPipeline"
  55140. */
  55141. getClassName(): string;
  55142. /**
  55143. * Gets associated scene
  55144. */
  55145. readonly scene: Scene;
  55146. /**
  55147. * Gets or sets the edge blur
  55148. */
  55149. edgeBlur: number;
  55150. /**
  55151. * Gets or sets the grain amount
  55152. */
  55153. grainAmount: number;
  55154. /**
  55155. * Gets or sets the chromatic aberration amount
  55156. */
  55157. chromaticAberration: number;
  55158. /**
  55159. * Gets or sets the depth of field aperture
  55160. */
  55161. dofAperture: number;
  55162. /**
  55163. * Gets or sets the edge distortion
  55164. */
  55165. edgeDistortion: number;
  55166. /**
  55167. * Gets or sets the depth of field distortion
  55168. */
  55169. dofDistortion: number;
  55170. /**
  55171. * Gets or sets the darken out of focus amount
  55172. */
  55173. darkenOutOfFocus: number;
  55174. /**
  55175. * Gets or sets a boolean indicating if blur noise is enabled
  55176. */
  55177. blurNoise: boolean;
  55178. /**
  55179. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55180. */
  55181. pentagonBokeh: boolean;
  55182. /**
  55183. * Gets or sets the highlight grain amount
  55184. */
  55185. highlightsGain: number;
  55186. /**
  55187. * Gets or sets the highlight threshold
  55188. */
  55189. highlightsThreshold: number;
  55190. /**
  55191. * Sets the amount of blur at the edges
  55192. * @param amount blur amount
  55193. */
  55194. setEdgeBlur(amount: number): void;
  55195. /**
  55196. * Sets edge blur to 0
  55197. */
  55198. disableEdgeBlur(): void;
  55199. /**
  55200. * Sets the amout of grain
  55201. * @param amount Amount of grain
  55202. */
  55203. setGrainAmount(amount: number): void;
  55204. /**
  55205. * Set grain amount to 0
  55206. */
  55207. disableGrain(): void;
  55208. /**
  55209. * Sets the chromatic aberration amount
  55210. * @param amount amount of chromatic aberration
  55211. */
  55212. setChromaticAberration(amount: number): void;
  55213. /**
  55214. * Sets chromatic aberration amount to 0
  55215. */
  55216. disableChromaticAberration(): void;
  55217. /**
  55218. * Sets the EdgeDistortion amount
  55219. * @param amount amount of EdgeDistortion
  55220. */
  55221. setEdgeDistortion(amount: number): void;
  55222. /**
  55223. * Sets edge distortion to 0
  55224. */
  55225. disableEdgeDistortion(): void;
  55226. /**
  55227. * Sets the FocusDistance amount
  55228. * @param amount amount of FocusDistance
  55229. */
  55230. setFocusDistance(amount: number): void;
  55231. /**
  55232. * Disables depth of field
  55233. */
  55234. disableDepthOfField(): void;
  55235. /**
  55236. * Sets the Aperture amount
  55237. * @param amount amount of Aperture
  55238. */
  55239. setAperture(amount: number): void;
  55240. /**
  55241. * Sets the DarkenOutOfFocus amount
  55242. * @param amount amount of DarkenOutOfFocus
  55243. */
  55244. setDarkenOutOfFocus(amount: number): void;
  55245. private _pentagonBokehIsEnabled;
  55246. /**
  55247. * Creates a pentagon bokeh effect
  55248. */
  55249. enablePentagonBokeh(): void;
  55250. /**
  55251. * Disables the pentagon bokeh effect
  55252. */
  55253. disablePentagonBokeh(): void;
  55254. /**
  55255. * Enables noise blur
  55256. */
  55257. enableNoiseBlur(): void;
  55258. /**
  55259. * Disables noise blur
  55260. */
  55261. disableNoiseBlur(): void;
  55262. /**
  55263. * Sets the HighlightsGain amount
  55264. * @param amount amount of HighlightsGain
  55265. */
  55266. setHighlightsGain(amount: number): void;
  55267. /**
  55268. * Sets the HighlightsThreshold amount
  55269. * @param amount amount of HighlightsThreshold
  55270. */
  55271. setHighlightsThreshold(amount: number): void;
  55272. /**
  55273. * Disables highlights
  55274. */
  55275. disableHighlights(): void;
  55276. /**
  55277. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55278. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55279. */
  55280. dispose(disableDepthRender?: boolean): void;
  55281. private _createChromaticAberrationPostProcess;
  55282. private _createHighlightsPostProcess;
  55283. private _createDepthOfFieldPostProcess;
  55284. private _createGrainTexture;
  55285. }
  55286. }
  55287. declare module "babylonjs/Shaders/ssao2.fragment" {
  55288. /** @hidden */
  55289. export var ssao2PixelShader: {
  55290. name: string;
  55291. shader: string;
  55292. };
  55293. }
  55294. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55295. /** @hidden */
  55296. export var ssaoCombinePixelShader: {
  55297. name: string;
  55298. shader: string;
  55299. };
  55300. }
  55301. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55302. import { Camera } from "babylonjs/Cameras/camera";
  55303. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55304. import { Scene } from "babylonjs/scene";
  55305. import "babylonjs/Shaders/ssao2.fragment";
  55306. import "babylonjs/Shaders/ssaoCombine.fragment";
  55307. /**
  55308. * Render pipeline to produce ssao effect
  55309. */
  55310. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55311. /**
  55312. * @ignore
  55313. * The PassPostProcess id in the pipeline that contains the original scene color
  55314. */
  55315. SSAOOriginalSceneColorEffect: string;
  55316. /**
  55317. * @ignore
  55318. * The SSAO PostProcess id in the pipeline
  55319. */
  55320. SSAORenderEffect: string;
  55321. /**
  55322. * @ignore
  55323. * The horizontal blur PostProcess id in the pipeline
  55324. */
  55325. SSAOBlurHRenderEffect: string;
  55326. /**
  55327. * @ignore
  55328. * The vertical blur PostProcess id in the pipeline
  55329. */
  55330. SSAOBlurVRenderEffect: string;
  55331. /**
  55332. * @ignore
  55333. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55334. */
  55335. SSAOCombineRenderEffect: string;
  55336. /**
  55337. * The output strength of the SSAO post-process. Default value is 1.0.
  55338. */
  55339. totalStrength: number;
  55340. /**
  55341. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55342. */
  55343. maxZ: number;
  55344. /**
  55345. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55346. */
  55347. minZAspect: number;
  55348. private _samples;
  55349. /**
  55350. * Number of samples used for the SSAO calculations. Default value is 8
  55351. */
  55352. samples: number;
  55353. private _textureSamples;
  55354. /**
  55355. * Number of samples to use for antialiasing
  55356. */
  55357. textureSamples: number;
  55358. /**
  55359. * Ratio object used for SSAO ratio and blur ratio
  55360. */
  55361. private _ratio;
  55362. /**
  55363. * Dynamically generated sphere sampler.
  55364. */
  55365. private _sampleSphere;
  55366. /**
  55367. * Blur filter offsets
  55368. */
  55369. private _samplerOffsets;
  55370. private _expensiveBlur;
  55371. /**
  55372. * If bilateral blur should be used
  55373. */
  55374. expensiveBlur: boolean;
  55375. /**
  55376. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55377. */
  55378. radius: number;
  55379. /**
  55380. * The base color of the SSAO post-process
  55381. * The final result is "base + ssao" between [0, 1]
  55382. */
  55383. base: number;
  55384. /**
  55385. * Support test.
  55386. */
  55387. static readonly IsSupported: boolean;
  55388. private _scene;
  55389. private _depthTexture;
  55390. private _normalTexture;
  55391. private _randomTexture;
  55392. private _originalColorPostProcess;
  55393. private _ssaoPostProcess;
  55394. private _blurHPostProcess;
  55395. private _blurVPostProcess;
  55396. private _ssaoCombinePostProcess;
  55397. private _firstUpdate;
  55398. /**
  55399. * Gets active scene
  55400. */
  55401. readonly scene: Scene;
  55402. /**
  55403. * @constructor
  55404. * @param name The rendering pipeline name
  55405. * @param scene The scene linked to this pipeline
  55406. * @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 }
  55407. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55408. */
  55409. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55410. /**
  55411. * Get the class name
  55412. * @returns "SSAO2RenderingPipeline"
  55413. */
  55414. getClassName(): string;
  55415. /**
  55416. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55417. */
  55418. dispose(disableGeometryBufferRenderer?: boolean): void;
  55419. private _createBlurPostProcess;
  55420. /** @hidden */
  55421. _rebuild(): void;
  55422. private _bits;
  55423. private _radicalInverse_VdC;
  55424. private _hammersley;
  55425. private _hemisphereSample_uniform;
  55426. private _generateHemisphere;
  55427. private _createSSAOPostProcess;
  55428. private _createSSAOCombinePostProcess;
  55429. private _createRandomTexture;
  55430. /**
  55431. * Serialize the rendering pipeline (Used when exporting)
  55432. * @returns the serialized object
  55433. */
  55434. serialize(): any;
  55435. /**
  55436. * Parse the serialized pipeline
  55437. * @param source Source pipeline.
  55438. * @param scene The scene to load the pipeline to.
  55439. * @param rootUrl The URL of the serialized pipeline.
  55440. * @returns An instantiated pipeline from the serialized object.
  55441. */
  55442. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55443. }
  55444. }
  55445. declare module "babylonjs/Shaders/ssao.fragment" {
  55446. /** @hidden */
  55447. export var ssaoPixelShader: {
  55448. name: string;
  55449. shader: string;
  55450. };
  55451. }
  55452. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  55453. import { Camera } from "babylonjs/Cameras/camera";
  55454. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55455. import { Scene } from "babylonjs/scene";
  55456. import "babylonjs/Shaders/ssao.fragment";
  55457. import "babylonjs/Shaders/ssaoCombine.fragment";
  55458. /**
  55459. * Render pipeline to produce ssao effect
  55460. */
  55461. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55462. /**
  55463. * @ignore
  55464. * The PassPostProcess id in the pipeline that contains the original scene color
  55465. */
  55466. SSAOOriginalSceneColorEffect: string;
  55467. /**
  55468. * @ignore
  55469. * The SSAO PostProcess id in the pipeline
  55470. */
  55471. SSAORenderEffect: string;
  55472. /**
  55473. * @ignore
  55474. * The horizontal blur PostProcess id in the pipeline
  55475. */
  55476. SSAOBlurHRenderEffect: string;
  55477. /**
  55478. * @ignore
  55479. * The vertical blur PostProcess id in the pipeline
  55480. */
  55481. SSAOBlurVRenderEffect: string;
  55482. /**
  55483. * @ignore
  55484. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55485. */
  55486. SSAOCombineRenderEffect: string;
  55487. /**
  55488. * The output strength of the SSAO post-process. Default value is 1.0.
  55489. */
  55490. totalStrength: number;
  55491. /**
  55492. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55493. */
  55494. radius: number;
  55495. /**
  55496. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55497. * Must not be equal to fallOff and superior to fallOff.
  55498. * Default value is 0.0075
  55499. */
  55500. area: number;
  55501. /**
  55502. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55503. * Must not be equal to area and inferior to area.
  55504. * Default value is 0.000001
  55505. */
  55506. fallOff: number;
  55507. /**
  55508. * The base color of the SSAO post-process
  55509. * The final result is "base + ssao" between [0, 1]
  55510. */
  55511. base: number;
  55512. private _scene;
  55513. private _depthTexture;
  55514. private _randomTexture;
  55515. private _originalColorPostProcess;
  55516. private _ssaoPostProcess;
  55517. private _blurHPostProcess;
  55518. private _blurVPostProcess;
  55519. private _ssaoCombinePostProcess;
  55520. private _firstUpdate;
  55521. /**
  55522. * Gets active scene
  55523. */
  55524. readonly scene: Scene;
  55525. /**
  55526. * @constructor
  55527. * @param name - The rendering pipeline name
  55528. * @param scene - The scene linked to this pipeline
  55529. * @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 }
  55530. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55531. */
  55532. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55533. /**
  55534. * Get the class name
  55535. * @returns "SSAORenderingPipeline"
  55536. */
  55537. getClassName(): string;
  55538. /**
  55539. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55540. */
  55541. dispose(disableDepthRender?: boolean): void;
  55542. private _createBlurPostProcess;
  55543. /** @hidden */
  55544. _rebuild(): void;
  55545. private _createSSAOPostProcess;
  55546. private _createSSAOCombinePostProcess;
  55547. private _createRandomTexture;
  55548. }
  55549. }
  55550. declare module "babylonjs/Shaders/standard.fragment" {
  55551. /** @hidden */
  55552. export var standardPixelShader: {
  55553. name: string;
  55554. shader: string;
  55555. };
  55556. }
  55557. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  55558. import { Nullable } from "babylonjs/types";
  55559. import { IAnimatable } from "babylonjs/Misc/tools";
  55560. import { Camera } from "babylonjs/Cameras/camera";
  55561. import { Texture } from "babylonjs/Materials/Textures/texture";
  55562. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55563. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55564. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55565. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55566. import { IDisposable } from "babylonjs/scene";
  55567. import { SpotLight } from "babylonjs/Lights/spotLight";
  55568. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  55569. import { Scene } from "babylonjs/scene";
  55570. import { Animation } from "babylonjs/Animations/animation";
  55571. import "babylonjs/Shaders/standard.fragment";
  55572. /**
  55573. * Standard rendering pipeline
  55574. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55575. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55576. */
  55577. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55578. /**
  55579. * Public members
  55580. */
  55581. /**
  55582. * Post-process which contains the original scene color before the pipeline applies all the effects
  55583. */
  55584. originalPostProcess: Nullable<PostProcess>;
  55585. /**
  55586. * Post-process used to down scale an image x4
  55587. */
  55588. downSampleX4PostProcess: Nullable<PostProcess>;
  55589. /**
  55590. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55591. */
  55592. brightPassPostProcess: Nullable<PostProcess>;
  55593. /**
  55594. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55595. */
  55596. blurHPostProcesses: PostProcess[];
  55597. /**
  55598. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55599. */
  55600. blurVPostProcesses: PostProcess[];
  55601. /**
  55602. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55603. */
  55604. textureAdderPostProcess: Nullable<PostProcess>;
  55605. /**
  55606. * Post-process used to create volumetric lighting effect
  55607. */
  55608. volumetricLightPostProcess: Nullable<PostProcess>;
  55609. /**
  55610. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55611. */
  55612. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55613. /**
  55614. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55615. */
  55616. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55617. /**
  55618. * Post-process used to merge the volumetric light effect and the real scene color
  55619. */
  55620. volumetricLightMergePostProces: Nullable<PostProcess>;
  55621. /**
  55622. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55623. */
  55624. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55625. /**
  55626. * Base post-process used to calculate the average luminance of the final image for HDR
  55627. */
  55628. luminancePostProcess: Nullable<PostProcess>;
  55629. /**
  55630. * Post-processes used to create down sample post-processes in order to get
  55631. * the average luminance of the final image for HDR
  55632. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55633. */
  55634. luminanceDownSamplePostProcesses: PostProcess[];
  55635. /**
  55636. * Post-process used to create a HDR effect (light adaptation)
  55637. */
  55638. hdrPostProcess: Nullable<PostProcess>;
  55639. /**
  55640. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  55641. */
  55642. textureAdderFinalPostProcess: Nullable<PostProcess>;
  55643. /**
  55644. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  55645. */
  55646. lensFlareFinalPostProcess: Nullable<PostProcess>;
  55647. /**
  55648. * Post-process used to merge the final HDR post-process and the real scene color
  55649. */
  55650. hdrFinalPostProcess: Nullable<PostProcess>;
  55651. /**
  55652. * Post-process used to create a lens flare effect
  55653. */
  55654. lensFlarePostProcess: Nullable<PostProcess>;
  55655. /**
  55656. * Post-process that merges the result of the lens flare post-process and the real scene color
  55657. */
  55658. lensFlareComposePostProcess: Nullable<PostProcess>;
  55659. /**
  55660. * Post-process used to create a motion blur effect
  55661. */
  55662. motionBlurPostProcess: Nullable<PostProcess>;
  55663. /**
  55664. * Post-process used to create a depth of field effect
  55665. */
  55666. depthOfFieldPostProcess: Nullable<PostProcess>;
  55667. /**
  55668. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55669. */
  55670. fxaaPostProcess: Nullable<FxaaPostProcess>;
  55671. /**
  55672. * Represents the brightness threshold in order to configure the illuminated surfaces
  55673. */
  55674. brightThreshold: number;
  55675. /**
  55676. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  55677. */
  55678. blurWidth: number;
  55679. /**
  55680. * Sets if the blur for highlighted surfaces must be only horizontal
  55681. */
  55682. horizontalBlur: boolean;
  55683. /**
  55684. * Sets the overall exposure used by the pipeline
  55685. */
  55686. exposure: number;
  55687. /**
  55688. * Texture used typically to simulate "dirty" on camera lens
  55689. */
  55690. lensTexture: Nullable<Texture>;
  55691. /**
  55692. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  55693. */
  55694. volumetricLightCoefficient: number;
  55695. /**
  55696. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  55697. */
  55698. volumetricLightPower: number;
  55699. /**
  55700. * Used the set the blur intensity to smooth the volumetric lights
  55701. */
  55702. volumetricLightBlurScale: number;
  55703. /**
  55704. * Light (spot or directional) used to generate the volumetric lights rays
  55705. * The source light must have a shadow generate so the pipeline can get its
  55706. * depth map
  55707. */
  55708. sourceLight: Nullable<SpotLight | DirectionalLight>;
  55709. /**
  55710. * For eye adaptation, represents the minimum luminance the eye can see
  55711. */
  55712. hdrMinimumLuminance: number;
  55713. /**
  55714. * For eye adaptation, represents the decrease luminance speed
  55715. */
  55716. hdrDecreaseRate: number;
  55717. /**
  55718. * For eye adaptation, represents the increase luminance speed
  55719. */
  55720. hdrIncreaseRate: number;
  55721. /**
  55722. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55723. */
  55724. lensColorTexture: Nullable<Texture>;
  55725. /**
  55726. * The overall strengh for the lens flare effect
  55727. */
  55728. lensFlareStrength: number;
  55729. /**
  55730. * Dispersion coefficient for lens flare ghosts
  55731. */
  55732. lensFlareGhostDispersal: number;
  55733. /**
  55734. * Main lens flare halo width
  55735. */
  55736. lensFlareHaloWidth: number;
  55737. /**
  55738. * Based on the lens distortion effect, defines how much the lens flare result
  55739. * is distorted
  55740. */
  55741. lensFlareDistortionStrength: number;
  55742. /**
  55743. * Lens star texture must be used to simulate rays on the flares and is available
  55744. * in the documentation
  55745. */
  55746. lensStarTexture: Nullable<Texture>;
  55747. /**
  55748. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55749. * flare effect by taking account of the dirt texture
  55750. */
  55751. lensFlareDirtTexture: Nullable<Texture>;
  55752. /**
  55753. * Represents the focal length for the depth of field effect
  55754. */
  55755. depthOfFieldDistance: number;
  55756. /**
  55757. * Represents the blur intensity for the blurred part of the depth of field effect
  55758. */
  55759. depthOfFieldBlurWidth: number;
  55760. /**
  55761. * For motion blur, defines how much the image is blurred by the movement
  55762. */
  55763. motionStrength: number;
  55764. /**
  55765. * List of animations for the pipeline (IAnimatable implementation)
  55766. */
  55767. animations: Animation[];
  55768. /**
  55769. * Private members
  55770. */
  55771. private _scene;
  55772. private _currentDepthOfFieldSource;
  55773. private _basePostProcess;
  55774. private _hdrCurrentLuminance;
  55775. private _floatTextureType;
  55776. private _ratio;
  55777. private _bloomEnabled;
  55778. private _depthOfFieldEnabled;
  55779. private _vlsEnabled;
  55780. private _lensFlareEnabled;
  55781. private _hdrEnabled;
  55782. private _motionBlurEnabled;
  55783. private _fxaaEnabled;
  55784. private _motionBlurSamples;
  55785. private _volumetricLightStepsCount;
  55786. private _samples;
  55787. /**
  55788. * @ignore
  55789. * Specifies if the bloom pipeline is enabled
  55790. */
  55791. BloomEnabled: boolean;
  55792. /**
  55793. * @ignore
  55794. * Specifies if the depth of field pipeline is enabed
  55795. */
  55796. DepthOfFieldEnabled: boolean;
  55797. /**
  55798. * @ignore
  55799. * Specifies if the lens flare pipeline is enabed
  55800. */
  55801. LensFlareEnabled: boolean;
  55802. /**
  55803. * @ignore
  55804. * Specifies if the HDR pipeline is enabled
  55805. */
  55806. HDREnabled: boolean;
  55807. /**
  55808. * @ignore
  55809. * Specifies if the volumetric lights scattering effect is enabled
  55810. */
  55811. VLSEnabled: boolean;
  55812. /**
  55813. * @ignore
  55814. * Specifies if the motion blur effect is enabled
  55815. */
  55816. MotionBlurEnabled: boolean;
  55817. /**
  55818. * Specifies if anti-aliasing is enabled
  55819. */
  55820. fxaaEnabled: boolean;
  55821. /**
  55822. * Specifies the number of steps used to calculate the volumetric lights
  55823. * Typically in interval [50, 200]
  55824. */
  55825. volumetricLightStepsCount: number;
  55826. /**
  55827. * Specifies the number of samples used for the motion blur effect
  55828. * Typically in interval [16, 64]
  55829. */
  55830. motionBlurSamples: number;
  55831. /**
  55832. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55833. */
  55834. samples: number;
  55835. /**
  55836. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55837. * @constructor
  55838. * @param name The rendering pipeline name
  55839. * @param scene The scene linked to this pipeline
  55840. * @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)
  55841. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55842. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55843. */
  55844. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55845. private _buildPipeline;
  55846. private _createDownSampleX4PostProcess;
  55847. private _createBrightPassPostProcess;
  55848. private _createBlurPostProcesses;
  55849. private _createTextureAdderPostProcess;
  55850. private _createVolumetricLightPostProcess;
  55851. private _createLuminancePostProcesses;
  55852. private _createHdrPostProcess;
  55853. private _createLensFlarePostProcess;
  55854. private _createDepthOfFieldPostProcess;
  55855. private _createMotionBlurPostProcess;
  55856. private _getDepthTexture;
  55857. private _disposePostProcesses;
  55858. /**
  55859. * Dispose of the pipeline and stop all post processes
  55860. */
  55861. dispose(): void;
  55862. /**
  55863. * Serialize the rendering pipeline (Used when exporting)
  55864. * @returns the serialized object
  55865. */
  55866. serialize(): any;
  55867. /**
  55868. * Parse the serialized pipeline
  55869. * @param source Source pipeline.
  55870. * @param scene The scene to load the pipeline to.
  55871. * @param rootUrl The URL of the serialized pipeline.
  55872. * @returns An instantiated pipeline from the serialized object.
  55873. */
  55874. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55875. /**
  55876. * Luminance steps
  55877. */
  55878. static LuminanceSteps: number;
  55879. }
  55880. }
  55881. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55882. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55883. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55884. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55885. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55886. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55887. }
  55888. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55889. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55890. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55891. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55892. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55893. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55894. }
  55895. declare module "babylonjs/Shaders/tonemap.fragment" {
  55896. /** @hidden */
  55897. export var tonemapPixelShader: {
  55898. name: string;
  55899. shader: string;
  55900. };
  55901. }
  55902. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55903. import { Camera } from "babylonjs/Cameras/camera";
  55904. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55905. import "babylonjs/Shaders/tonemap.fragment";
  55906. import { Engine } from "babylonjs/Engines/engine";
  55907. /** Defines operator used for tonemapping */
  55908. export enum TonemappingOperator {
  55909. /** Hable */
  55910. Hable = 0,
  55911. /** Reinhard */
  55912. Reinhard = 1,
  55913. /** HejiDawson */
  55914. HejiDawson = 2,
  55915. /** Photographic */
  55916. Photographic = 3
  55917. }
  55918. /**
  55919. * Defines a post process to apply tone mapping
  55920. */
  55921. export class TonemapPostProcess extends PostProcess {
  55922. private _operator;
  55923. /** Defines the required exposure adjustement */
  55924. exposureAdjustment: number;
  55925. /**
  55926. * Creates a new TonemapPostProcess
  55927. * @param name defines the name of the postprocess
  55928. * @param _operator defines the operator to use
  55929. * @param exposureAdjustment defines the required exposure adjustement
  55930. * @param camera defines the camera to use (can be null)
  55931. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55932. * @param engine defines the hosting engine (can be ignore if camera is set)
  55933. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55934. */
  55935. constructor(name: string, _operator: TonemappingOperator,
  55936. /** Defines the required exposure adjustement */
  55937. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55938. }
  55939. }
  55940. declare module "babylonjs/Shaders/depth.vertex" {
  55941. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55942. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55943. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55944. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55945. /** @hidden */
  55946. export var depthVertexShader: {
  55947. name: string;
  55948. shader: string;
  55949. };
  55950. }
  55951. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55952. /** @hidden */
  55953. export var volumetricLightScatteringPixelShader: {
  55954. name: string;
  55955. shader: string;
  55956. };
  55957. }
  55958. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55959. /** @hidden */
  55960. export var volumetricLightScatteringPassPixelShader: {
  55961. name: string;
  55962. shader: string;
  55963. };
  55964. }
  55965. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55966. import { Vector3 } from "babylonjs/Maths/math";
  55967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55968. import { Mesh } from "babylonjs/Meshes/mesh";
  55969. import { Camera } from "babylonjs/Cameras/camera";
  55970. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55971. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55972. import { Scene } from "babylonjs/scene";
  55973. import "babylonjs/Meshes/Builders/planeBuilder";
  55974. import "babylonjs/Shaders/depth.vertex";
  55975. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55976. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55977. import { Engine } from "babylonjs/Engines/engine";
  55978. /**
  55979. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55980. */
  55981. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55982. private _volumetricLightScatteringPass;
  55983. private _volumetricLightScatteringRTT;
  55984. private _viewPort;
  55985. private _screenCoordinates;
  55986. private _cachedDefines;
  55987. /**
  55988. * If not undefined, the mesh position is computed from the attached node position
  55989. */
  55990. attachedNode: {
  55991. position: Vector3;
  55992. };
  55993. /**
  55994. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55995. */
  55996. customMeshPosition: Vector3;
  55997. /**
  55998. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55999. */
  56000. useCustomMeshPosition: boolean;
  56001. /**
  56002. * If the post-process should inverse the light scattering direction
  56003. */
  56004. invert: boolean;
  56005. /**
  56006. * The internal mesh used by the post-process
  56007. */
  56008. mesh: Mesh;
  56009. /**
  56010. * @hidden
  56011. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56012. */
  56013. useDiffuseColor: boolean;
  56014. /**
  56015. * Array containing the excluded meshes not rendered in the internal pass
  56016. */
  56017. excludedMeshes: AbstractMesh[];
  56018. /**
  56019. * Controls the overall intensity of the post-process
  56020. */
  56021. exposure: number;
  56022. /**
  56023. * Dissipates each sample's contribution in range [0, 1]
  56024. */
  56025. decay: number;
  56026. /**
  56027. * Controls the overall intensity of each sample
  56028. */
  56029. weight: number;
  56030. /**
  56031. * Controls the density of each sample
  56032. */
  56033. density: number;
  56034. /**
  56035. * @constructor
  56036. * @param name The post-process name
  56037. * @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)
  56038. * @param camera The camera that the post-process will be attached to
  56039. * @param mesh The mesh used to create the light scattering
  56040. * @param samples The post-process quality, default 100
  56041. * @param samplingModeThe post-process filtering mode
  56042. * @param engine The babylon engine
  56043. * @param reusable If the post-process is reusable
  56044. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56045. */
  56046. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56047. /**
  56048. * Returns the string "VolumetricLightScatteringPostProcess"
  56049. * @returns "VolumetricLightScatteringPostProcess"
  56050. */
  56051. getClassName(): string;
  56052. private _isReady;
  56053. /**
  56054. * Sets the new light position for light scattering effect
  56055. * @param position The new custom light position
  56056. */
  56057. setCustomMeshPosition(position: Vector3): void;
  56058. /**
  56059. * Returns the light position for light scattering effect
  56060. * @return Vector3 The custom light position
  56061. */
  56062. getCustomMeshPosition(): Vector3;
  56063. /**
  56064. * Disposes the internal assets and detaches the post-process from the camera
  56065. */
  56066. dispose(camera: Camera): void;
  56067. /**
  56068. * Returns the render target texture used by the post-process
  56069. * @return the render target texture used by the post-process
  56070. */
  56071. getPass(): RenderTargetTexture;
  56072. private _meshExcluded;
  56073. private _createPass;
  56074. private _updateMeshScreenCoordinates;
  56075. /**
  56076. * Creates a default mesh for the Volumeric Light Scattering post-process
  56077. * @param name The mesh name
  56078. * @param scene The scene where to create the mesh
  56079. * @return the default mesh
  56080. */
  56081. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56082. }
  56083. }
  56084. declare module "babylonjs/PostProcesses/index" {
  56085. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56086. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56087. export * from "babylonjs/PostProcesses/bloomEffect";
  56088. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56089. export * from "babylonjs/PostProcesses/blurPostProcess";
  56090. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56091. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56092. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56093. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56094. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56095. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56096. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56097. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56098. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56099. export * from "babylonjs/PostProcesses/filterPostProcess";
  56100. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56101. export * from "babylonjs/PostProcesses/grainPostProcess";
  56102. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56103. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56104. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56105. export * from "babylonjs/PostProcesses/passPostProcess";
  56106. export * from "babylonjs/PostProcesses/postProcess";
  56107. export * from "babylonjs/PostProcesses/postProcessManager";
  56108. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56109. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56110. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56111. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56112. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56113. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56114. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56115. }
  56116. declare module "babylonjs/Probes/index" {
  56117. export * from "babylonjs/Probes/reflectionProbe";
  56118. }
  56119. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56120. import { Scene } from "babylonjs/scene";
  56121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56122. import { Color3 } from "babylonjs/Maths/math";
  56123. import { SmartArray } from "babylonjs/Misc/smartArray";
  56124. import { ISceneComponent } from "babylonjs/sceneComponent";
  56125. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56126. import "babylonjs/Meshes/Builders/boxBuilder";
  56127. import "babylonjs/Shaders/color.fragment";
  56128. import "babylonjs/Shaders/color.vertex";
  56129. module "babylonjs/scene" {
  56130. interface Scene {
  56131. /** @hidden (Backing field) */
  56132. _boundingBoxRenderer: BoundingBoxRenderer;
  56133. /** @hidden (Backing field) */
  56134. _forceShowBoundingBoxes: boolean;
  56135. /**
  56136. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56137. */
  56138. forceShowBoundingBoxes: boolean;
  56139. /**
  56140. * Gets the bounding box renderer associated with the scene
  56141. * @returns a BoundingBoxRenderer
  56142. */
  56143. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56144. }
  56145. }
  56146. module "babylonjs/Meshes/abstractMesh" {
  56147. interface AbstractMesh {
  56148. /** @hidden (Backing field) */
  56149. _showBoundingBox: boolean;
  56150. /**
  56151. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56152. */
  56153. showBoundingBox: boolean;
  56154. }
  56155. }
  56156. /**
  56157. * Component responsible of rendering the bounding box of the meshes in a scene.
  56158. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56159. */
  56160. export class BoundingBoxRenderer implements ISceneComponent {
  56161. /**
  56162. * The component name helpfull to identify the component in the list of scene components.
  56163. */
  56164. readonly name: string;
  56165. /**
  56166. * The scene the component belongs to.
  56167. */
  56168. scene: Scene;
  56169. /**
  56170. * Color of the bounding box lines placed in front of an object
  56171. */
  56172. frontColor: Color3;
  56173. /**
  56174. * Color of the bounding box lines placed behind an object
  56175. */
  56176. backColor: Color3;
  56177. /**
  56178. * Defines if the renderer should show the back lines or not
  56179. */
  56180. showBackLines: boolean;
  56181. /**
  56182. * @hidden
  56183. */
  56184. renderList: SmartArray<BoundingBox>;
  56185. private _colorShader;
  56186. private _vertexBuffers;
  56187. private _indexBuffer;
  56188. /**
  56189. * Instantiates a new bounding box renderer in a scene.
  56190. * @param scene the scene the renderer renders in
  56191. */
  56192. constructor(scene: Scene);
  56193. /**
  56194. * Registers the component in a given scene
  56195. */
  56196. register(): void;
  56197. private _evaluateSubMesh;
  56198. private _activeMesh;
  56199. private _prepareRessources;
  56200. private _createIndexBuffer;
  56201. /**
  56202. * Rebuilds the elements related to this component in case of
  56203. * context lost for instance.
  56204. */
  56205. rebuild(): void;
  56206. /**
  56207. * @hidden
  56208. */
  56209. reset(): void;
  56210. /**
  56211. * Render the bounding boxes of a specific rendering group
  56212. * @param renderingGroupId defines the rendering group to render
  56213. */
  56214. render(renderingGroupId: number): void;
  56215. /**
  56216. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56217. * @param mesh Define the mesh to render the occlusion bounding box for
  56218. */
  56219. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56220. /**
  56221. * Dispose and release the resources attached to this renderer.
  56222. */
  56223. dispose(): void;
  56224. }
  56225. }
  56226. declare module "babylonjs/Shaders/depth.fragment" {
  56227. /** @hidden */
  56228. export var depthPixelShader: {
  56229. name: string;
  56230. shader: string;
  56231. };
  56232. }
  56233. declare module "babylonjs/Rendering/depthRenderer" {
  56234. import { Nullable } from "babylonjs/types";
  56235. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56236. import { Scene } from "babylonjs/scene";
  56237. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56238. import { Camera } from "babylonjs/Cameras/camera";
  56239. import "babylonjs/Shaders/depth.fragment";
  56240. import "babylonjs/Shaders/depth.vertex";
  56241. /**
  56242. * This represents a depth renderer in Babylon.
  56243. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56244. */
  56245. export class DepthRenderer {
  56246. private _scene;
  56247. private _depthMap;
  56248. private _effect;
  56249. private _cachedDefines;
  56250. private _camera;
  56251. /**
  56252. * Specifiess that the depth renderer will only be used within
  56253. * the camera it is created for.
  56254. * This can help forcing its rendering during the camera processing.
  56255. */
  56256. useOnlyInActiveCamera: boolean;
  56257. /** @hidden */
  56258. static _SceneComponentInitialization: (scene: Scene) => void;
  56259. /**
  56260. * Instantiates a depth renderer
  56261. * @param scene The scene the renderer belongs to
  56262. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56263. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56264. */
  56265. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56266. /**
  56267. * Creates the depth rendering effect and checks if the effect is ready.
  56268. * @param subMesh The submesh to be used to render the depth map of
  56269. * @param useInstances If multiple world instances should be used
  56270. * @returns if the depth renderer is ready to render the depth map
  56271. */
  56272. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56273. /**
  56274. * Gets the texture which the depth map will be written to.
  56275. * @returns The depth map texture
  56276. */
  56277. getDepthMap(): RenderTargetTexture;
  56278. /**
  56279. * Disposes of the depth renderer.
  56280. */
  56281. dispose(): void;
  56282. }
  56283. }
  56284. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56285. import { Nullable } from "babylonjs/types";
  56286. import { Scene } from "babylonjs/scene";
  56287. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56288. import { Camera } from "babylonjs/Cameras/camera";
  56289. import { ISceneComponent } from "babylonjs/sceneComponent";
  56290. module "babylonjs/scene" {
  56291. interface Scene {
  56292. /** @hidden (Backing field) */
  56293. _depthRenderer: {
  56294. [id: string]: DepthRenderer;
  56295. };
  56296. /**
  56297. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56298. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56299. * @returns the created depth renderer
  56300. */
  56301. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56302. /**
  56303. * Disables a depth renderer for a given camera
  56304. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56305. */
  56306. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56307. }
  56308. }
  56309. /**
  56310. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56311. * in several rendering techniques.
  56312. */
  56313. export class DepthRendererSceneComponent implements ISceneComponent {
  56314. /**
  56315. * The component name helpfull to identify the component in the list of scene components.
  56316. */
  56317. readonly name: string;
  56318. /**
  56319. * The scene the component belongs to.
  56320. */
  56321. scene: Scene;
  56322. /**
  56323. * Creates a new instance of the component for the given scene
  56324. * @param scene Defines the scene to register the component in
  56325. */
  56326. constructor(scene: Scene);
  56327. /**
  56328. * Registers the component in a given scene
  56329. */
  56330. register(): void;
  56331. /**
  56332. * Rebuilds the elements related to this component in case of
  56333. * context lost for instance.
  56334. */
  56335. rebuild(): void;
  56336. /**
  56337. * Disposes the component and the associated ressources
  56338. */
  56339. dispose(): void;
  56340. private _gatherRenderTargets;
  56341. private _gatherActiveCameraRenderTargets;
  56342. }
  56343. }
  56344. declare module "babylonjs/Shaders/outline.fragment" {
  56345. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56346. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56347. /** @hidden */
  56348. export var outlinePixelShader: {
  56349. name: string;
  56350. shader: string;
  56351. };
  56352. }
  56353. declare module "babylonjs/Shaders/outline.vertex" {
  56354. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56355. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56356. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56357. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56358. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56359. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56360. /** @hidden */
  56361. export var outlineVertexShader: {
  56362. name: string;
  56363. shader: string;
  56364. };
  56365. }
  56366. declare module "babylonjs/Rendering/outlineRenderer" {
  56367. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56368. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  56369. import { Scene } from "babylonjs/scene";
  56370. import { ISceneComponent } from "babylonjs/sceneComponent";
  56371. import "babylonjs/Shaders/outline.fragment";
  56372. import "babylonjs/Shaders/outline.vertex";
  56373. module "babylonjs/scene" {
  56374. interface Scene {
  56375. /** @hidden */
  56376. _outlineRenderer: OutlineRenderer;
  56377. /**
  56378. * Gets the outline renderer associated with the scene
  56379. * @returns a OutlineRenderer
  56380. */
  56381. getOutlineRenderer(): OutlineRenderer;
  56382. }
  56383. }
  56384. module "babylonjs/Meshes/abstractMesh" {
  56385. interface AbstractMesh {
  56386. /** @hidden (Backing field) */
  56387. _renderOutline: boolean;
  56388. /**
  56389. * Gets or sets a boolean indicating if the outline must be rendered as well
  56390. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56391. */
  56392. renderOutline: boolean;
  56393. /** @hidden (Backing field) */
  56394. _renderOverlay: boolean;
  56395. /**
  56396. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56397. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56398. */
  56399. renderOverlay: boolean;
  56400. }
  56401. }
  56402. /**
  56403. * This class is responsible to draw bothe outline/overlay of meshes.
  56404. * It should not be used directly but through the available method on mesh.
  56405. */
  56406. export class OutlineRenderer implements ISceneComponent {
  56407. /**
  56408. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56409. */
  56410. private static _StencilReference;
  56411. /**
  56412. * The name of the component. Each component must have a unique name.
  56413. */
  56414. name: string;
  56415. /**
  56416. * The scene the component belongs to.
  56417. */
  56418. scene: Scene;
  56419. /**
  56420. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56421. */
  56422. zOffset: number;
  56423. private _engine;
  56424. private _effect;
  56425. private _cachedDefines;
  56426. private _savedDepthWrite;
  56427. /**
  56428. * Instantiates a new outline renderer. (There could be only one per scene).
  56429. * @param scene Defines the scene it belongs to
  56430. */
  56431. constructor(scene: Scene);
  56432. /**
  56433. * Register the component to one instance of a scene.
  56434. */
  56435. register(): void;
  56436. /**
  56437. * Rebuilds the elements related to this component in case of
  56438. * context lost for instance.
  56439. */
  56440. rebuild(): void;
  56441. /**
  56442. * Disposes the component and the associated ressources.
  56443. */
  56444. dispose(): void;
  56445. /**
  56446. * Renders the outline in the canvas.
  56447. * @param subMesh Defines the sumesh to render
  56448. * @param batch Defines the batch of meshes in case of instances
  56449. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56450. */
  56451. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56452. /**
  56453. * Returns whether or not the outline renderer is ready for a given submesh.
  56454. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56455. * @param subMesh Defines the submesh to check readyness for
  56456. * @param useInstances Defines wheter wee are trying to render instances or not
  56457. * @returns true if ready otherwise false
  56458. */
  56459. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56460. private _beforeRenderingMesh;
  56461. private _afterRenderingMesh;
  56462. }
  56463. }
  56464. declare module "babylonjs/Rendering/index" {
  56465. export * from "babylonjs/Rendering/boundingBoxRenderer";
  56466. export * from "babylonjs/Rendering/depthRenderer";
  56467. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  56468. export * from "babylonjs/Rendering/edgesRenderer";
  56469. export * from "babylonjs/Rendering/geometryBufferRenderer";
  56470. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  56471. export * from "babylonjs/Rendering/outlineRenderer";
  56472. export * from "babylonjs/Rendering/renderingGroup";
  56473. export * from "babylonjs/Rendering/renderingManager";
  56474. export * from "babylonjs/Rendering/utilityLayerRenderer";
  56475. }
  56476. declare module "babylonjs/Sprites/index" {
  56477. export * from "babylonjs/Sprites/sprite";
  56478. export * from "babylonjs/Sprites/spriteManager";
  56479. export * from "babylonjs/Sprites/spriteSceneComponent";
  56480. }
  56481. declare module "babylonjs/Misc/assetsManager" {
  56482. import { Scene } from "babylonjs/scene";
  56483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56484. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56485. import { Skeleton } from "babylonjs/Bones/skeleton";
  56486. import { Observable } from "babylonjs/Misc/observable";
  56487. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56488. import { Texture } from "babylonjs/Materials/Textures/texture";
  56489. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56490. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  56491. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56492. /**
  56493. * Defines the list of states available for a task inside a AssetsManager
  56494. */
  56495. export enum AssetTaskState {
  56496. /**
  56497. * Initialization
  56498. */
  56499. INIT = 0,
  56500. /**
  56501. * Running
  56502. */
  56503. RUNNING = 1,
  56504. /**
  56505. * Done
  56506. */
  56507. DONE = 2,
  56508. /**
  56509. * Error
  56510. */
  56511. ERROR = 3
  56512. }
  56513. /**
  56514. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56515. */
  56516. export abstract class AbstractAssetTask {
  56517. /**
  56518. * Task name
  56519. */ name: string;
  56520. /**
  56521. * Callback called when the task is successful
  56522. */
  56523. onSuccess: (task: any) => void;
  56524. /**
  56525. * Callback called when the task is not successful
  56526. */
  56527. onError: (task: any, message?: string, exception?: any) => void;
  56528. /**
  56529. * Creates a new AssetsManager
  56530. * @param name defines the name of the task
  56531. */
  56532. constructor(
  56533. /**
  56534. * Task name
  56535. */ name: string);
  56536. private _isCompleted;
  56537. private _taskState;
  56538. private _errorObject;
  56539. /**
  56540. * Get if the task is completed
  56541. */
  56542. readonly isCompleted: boolean;
  56543. /**
  56544. * Gets the current state of the task
  56545. */
  56546. readonly taskState: AssetTaskState;
  56547. /**
  56548. * Gets the current error object (if task is in error)
  56549. */
  56550. readonly errorObject: {
  56551. message?: string;
  56552. exception?: any;
  56553. };
  56554. /**
  56555. * Internal only
  56556. * @hidden
  56557. */
  56558. _setErrorObject(message?: string, exception?: any): void;
  56559. /**
  56560. * Execute the current task
  56561. * @param scene defines the scene where you want your assets to be loaded
  56562. * @param onSuccess is a callback called when the task is successfully executed
  56563. * @param onError is a callback called if an error occurs
  56564. */
  56565. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56566. /**
  56567. * Execute the current task
  56568. * @param scene defines the scene where you want your assets to be loaded
  56569. * @param onSuccess is a callback called when the task is successfully executed
  56570. * @param onError is a callback called if an error occurs
  56571. */
  56572. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56573. /**
  56574. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56575. * This can be used with failed tasks that have the reason for failure fixed.
  56576. */
  56577. reset(): void;
  56578. private onErrorCallback;
  56579. private onDoneCallback;
  56580. }
  56581. /**
  56582. * Define the interface used by progress events raised during assets loading
  56583. */
  56584. export interface IAssetsProgressEvent {
  56585. /**
  56586. * Defines the number of remaining tasks to process
  56587. */
  56588. remainingCount: number;
  56589. /**
  56590. * Defines the total number of tasks
  56591. */
  56592. totalCount: number;
  56593. /**
  56594. * Defines the task that was just processed
  56595. */
  56596. task: AbstractAssetTask;
  56597. }
  56598. /**
  56599. * Class used to share progress information about assets loading
  56600. */
  56601. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56602. /**
  56603. * Defines the number of remaining tasks to process
  56604. */
  56605. remainingCount: number;
  56606. /**
  56607. * Defines the total number of tasks
  56608. */
  56609. totalCount: number;
  56610. /**
  56611. * Defines the task that was just processed
  56612. */
  56613. task: AbstractAssetTask;
  56614. /**
  56615. * Creates a AssetsProgressEvent
  56616. * @param remainingCount defines the number of remaining tasks to process
  56617. * @param totalCount defines the total number of tasks
  56618. * @param task defines the task that was just processed
  56619. */
  56620. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56621. }
  56622. /**
  56623. * Define a task used by AssetsManager to load meshes
  56624. */
  56625. export class MeshAssetTask extends AbstractAssetTask {
  56626. /**
  56627. * Defines the name of the task
  56628. */
  56629. name: string;
  56630. /**
  56631. * Defines the list of mesh's names you want to load
  56632. */
  56633. meshesNames: any;
  56634. /**
  56635. * Defines the root url to use as a base to load your meshes and associated resources
  56636. */
  56637. rootUrl: string;
  56638. /**
  56639. * Defines the filename of the scene to load from
  56640. */
  56641. sceneFilename: string;
  56642. /**
  56643. * Gets the list of loaded meshes
  56644. */
  56645. loadedMeshes: Array<AbstractMesh>;
  56646. /**
  56647. * Gets the list of loaded particle systems
  56648. */
  56649. loadedParticleSystems: Array<IParticleSystem>;
  56650. /**
  56651. * Gets the list of loaded skeletons
  56652. */
  56653. loadedSkeletons: Array<Skeleton>;
  56654. /**
  56655. * Gets the list of loaded animation groups
  56656. */
  56657. loadedAnimationGroups: Array<AnimationGroup>;
  56658. /**
  56659. * Callback called when the task is successful
  56660. */
  56661. onSuccess: (task: MeshAssetTask) => void;
  56662. /**
  56663. * Callback called when the task is successful
  56664. */
  56665. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  56666. /**
  56667. * Creates a new MeshAssetTask
  56668. * @param name defines the name of the task
  56669. * @param meshesNames defines the list of mesh's names you want to load
  56670. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  56671. * @param sceneFilename defines the filename of the scene to load from
  56672. */
  56673. constructor(
  56674. /**
  56675. * Defines the name of the task
  56676. */
  56677. name: string,
  56678. /**
  56679. * Defines the list of mesh's names you want to load
  56680. */
  56681. meshesNames: any,
  56682. /**
  56683. * Defines the root url to use as a base to load your meshes and associated resources
  56684. */
  56685. rootUrl: string,
  56686. /**
  56687. * Defines the filename of the scene to load from
  56688. */
  56689. sceneFilename: string);
  56690. /**
  56691. * Execute the current task
  56692. * @param scene defines the scene where you want your assets to be loaded
  56693. * @param onSuccess is a callback called when the task is successfully executed
  56694. * @param onError is a callback called if an error occurs
  56695. */
  56696. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56697. }
  56698. /**
  56699. * Define a task used by AssetsManager to load text content
  56700. */
  56701. export class TextFileAssetTask extends AbstractAssetTask {
  56702. /**
  56703. * Defines the name of the task
  56704. */
  56705. name: string;
  56706. /**
  56707. * Defines the location of the file to load
  56708. */
  56709. url: string;
  56710. /**
  56711. * Gets the loaded text string
  56712. */
  56713. text: string;
  56714. /**
  56715. * Callback called when the task is successful
  56716. */
  56717. onSuccess: (task: TextFileAssetTask) => void;
  56718. /**
  56719. * Callback called when the task is successful
  56720. */
  56721. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56722. /**
  56723. * Creates a new TextFileAssetTask object
  56724. * @param name defines the name of the task
  56725. * @param url defines the location of the file to load
  56726. */
  56727. constructor(
  56728. /**
  56729. * Defines the name of the task
  56730. */
  56731. name: string,
  56732. /**
  56733. * Defines the location of the file to load
  56734. */
  56735. url: string);
  56736. /**
  56737. * Execute the current task
  56738. * @param scene defines the scene where you want your assets to be loaded
  56739. * @param onSuccess is a callback called when the task is successfully executed
  56740. * @param onError is a callback called if an error occurs
  56741. */
  56742. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56743. }
  56744. /**
  56745. * Define a task used by AssetsManager to load binary data
  56746. */
  56747. export class BinaryFileAssetTask extends AbstractAssetTask {
  56748. /**
  56749. * Defines the name of the task
  56750. */
  56751. name: string;
  56752. /**
  56753. * Defines the location of the file to load
  56754. */
  56755. url: string;
  56756. /**
  56757. * Gets the lodaded data (as an array buffer)
  56758. */
  56759. data: ArrayBuffer;
  56760. /**
  56761. * Callback called when the task is successful
  56762. */
  56763. onSuccess: (task: BinaryFileAssetTask) => void;
  56764. /**
  56765. * Callback called when the task is successful
  56766. */
  56767. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56768. /**
  56769. * Creates a new BinaryFileAssetTask object
  56770. * @param name defines the name of the new task
  56771. * @param url defines the location of the file to load
  56772. */
  56773. constructor(
  56774. /**
  56775. * Defines the name of the task
  56776. */
  56777. name: string,
  56778. /**
  56779. * Defines the location of the file to load
  56780. */
  56781. url: string);
  56782. /**
  56783. * Execute the current task
  56784. * @param scene defines the scene where you want your assets to be loaded
  56785. * @param onSuccess is a callback called when the task is successfully executed
  56786. * @param onError is a callback called if an error occurs
  56787. */
  56788. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56789. }
  56790. /**
  56791. * Define a task used by AssetsManager to load images
  56792. */
  56793. export class ImageAssetTask extends AbstractAssetTask {
  56794. /**
  56795. * Defines the name of the task
  56796. */
  56797. name: string;
  56798. /**
  56799. * Defines the location of the image to load
  56800. */
  56801. url: string;
  56802. /**
  56803. * Gets the loaded images
  56804. */
  56805. image: HTMLImageElement;
  56806. /**
  56807. * Callback called when the task is successful
  56808. */
  56809. onSuccess: (task: ImageAssetTask) => void;
  56810. /**
  56811. * Callback called when the task is successful
  56812. */
  56813. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56814. /**
  56815. * Creates a new ImageAssetTask
  56816. * @param name defines the name of the task
  56817. * @param url defines the location of the image to load
  56818. */
  56819. constructor(
  56820. /**
  56821. * Defines the name of the task
  56822. */
  56823. name: string,
  56824. /**
  56825. * Defines the location of the image to load
  56826. */
  56827. url: string);
  56828. /**
  56829. * Execute the current task
  56830. * @param scene defines the scene where you want your assets to be loaded
  56831. * @param onSuccess is a callback called when the task is successfully executed
  56832. * @param onError is a callback called if an error occurs
  56833. */
  56834. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56835. }
  56836. /**
  56837. * Defines the interface used by texture loading tasks
  56838. */
  56839. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56840. /**
  56841. * Gets the loaded texture
  56842. */
  56843. texture: TEX;
  56844. }
  56845. /**
  56846. * Define a task used by AssetsManager to load 2D textures
  56847. */
  56848. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56849. /**
  56850. * Defines the name of the task
  56851. */
  56852. name: string;
  56853. /**
  56854. * Defines the location of the file to load
  56855. */
  56856. url: string;
  56857. /**
  56858. * Defines if mipmap should not be generated (default is false)
  56859. */
  56860. noMipmap?: boolean | undefined;
  56861. /**
  56862. * Defines if texture must be inverted on Y axis (default is false)
  56863. */
  56864. invertY?: boolean | undefined;
  56865. /**
  56866. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56867. */
  56868. samplingMode: number;
  56869. /**
  56870. * Gets the loaded texture
  56871. */
  56872. texture: Texture;
  56873. /**
  56874. * Callback called when the task is successful
  56875. */
  56876. onSuccess: (task: TextureAssetTask) => void;
  56877. /**
  56878. * Callback called when the task is successful
  56879. */
  56880. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56881. /**
  56882. * Creates a new TextureAssetTask object
  56883. * @param name defines the name of the task
  56884. * @param url defines the location of the file to load
  56885. * @param noMipmap defines if mipmap should not be generated (default is false)
  56886. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56887. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56888. */
  56889. constructor(
  56890. /**
  56891. * Defines the name of the task
  56892. */
  56893. name: string,
  56894. /**
  56895. * Defines the location of the file to load
  56896. */
  56897. url: string,
  56898. /**
  56899. * Defines if mipmap should not be generated (default is false)
  56900. */
  56901. noMipmap?: boolean | undefined,
  56902. /**
  56903. * Defines if texture must be inverted on Y axis (default is false)
  56904. */
  56905. invertY?: boolean | undefined,
  56906. /**
  56907. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56908. */
  56909. samplingMode?: number);
  56910. /**
  56911. * Execute the current task
  56912. * @param scene defines the scene where you want your assets to be loaded
  56913. * @param onSuccess is a callback called when the task is successfully executed
  56914. * @param onError is a callback called if an error occurs
  56915. */
  56916. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56917. }
  56918. /**
  56919. * Define a task used by AssetsManager to load cube textures
  56920. */
  56921. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56922. /**
  56923. * Defines the name of the task
  56924. */
  56925. name: string;
  56926. /**
  56927. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56928. */
  56929. url: string;
  56930. /**
  56931. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56932. */
  56933. extensions?: string[] | undefined;
  56934. /**
  56935. * Defines if mipmaps should not be generated (default is false)
  56936. */
  56937. noMipmap?: boolean | undefined;
  56938. /**
  56939. * Defines the explicit list of files (undefined by default)
  56940. */
  56941. files?: string[] | undefined;
  56942. /**
  56943. * Gets the loaded texture
  56944. */
  56945. texture: CubeTexture;
  56946. /**
  56947. * Callback called when the task is successful
  56948. */
  56949. onSuccess: (task: CubeTextureAssetTask) => void;
  56950. /**
  56951. * Callback called when the task is successful
  56952. */
  56953. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56954. /**
  56955. * Creates a new CubeTextureAssetTask
  56956. * @param name defines the name of the task
  56957. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56958. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56959. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56960. * @param files defines the explicit list of files (undefined by default)
  56961. */
  56962. constructor(
  56963. /**
  56964. * Defines the name of the task
  56965. */
  56966. name: string,
  56967. /**
  56968. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56969. */
  56970. url: string,
  56971. /**
  56972. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56973. */
  56974. extensions?: string[] | undefined,
  56975. /**
  56976. * Defines if mipmaps should not be generated (default is false)
  56977. */
  56978. noMipmap?: boolean | undefined,
  56979. /**
  56980. * Defines the explicit list of files (undefined by default)
  56981. */
  56982. files?: string[] | undefined);
  56983. /**
  56984. * Execute the current task
  56985. * @param scene defines the scene where you want your assets to be loaded
  56986. * @param onSuccess is a callback called when the task is successfully executed
  56987. * @param onError is a callback called if an error occurs
  56988. */
  56989. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56990. }
  56991. /**
  56992. * Define a task used by AssetsManager to load HDR cube textures
  56993. */
  56994. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56995. /**
  56996. * Defines the name of the task
  56997. */
  56998. name: string;
  56999. /**
  57000. * Defines the location of the file to load
  57001. */
  57002. url: string;
  57003. /**
  57004. * Defines the desired size (the more it increases the longer the generation will be)
  57005. */
  57006. size: number;
  57007. /**
  57008. * Defines if mipmaps should not be generated (default is false)
  57009. */
  57010. noMipmap: boolean;
  57011. /**
  57012. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57013. */
  57014. generateHarmonics: boolean;
  57015. /**
  57016. * 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)
  57017. */
  57018. gammaSpace: boolean;
  57019. /**
  57020. * Internal Use Only
  57021. */
  57022. reserved: boolean;
  57023. /**
  57024. * Gets the loaded texture
  57025. */
  57026. texture: HDRCubeTexture;
  57027. /**
  57028. * Callback called when the task is successful
  57029. */
  57030. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57031. /**
  57032. * Callback called when the task is successful
  57033. */
  57034. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57035. /**
  57036. * Creates a new HDRCubeTextureAssetTask object
  57037. * @param name defines the name of the task
  57038. * @param url defines the location of the file to load
  57039. * @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.
  57040. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57041. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57042. * @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)
  57043. * @param reserved Internal use only
  57044. */
  57045. constructor(
  57046. /**
  57047. * Defines the name of the task
  57048. */
  57049. name: string,
  57050. /**
  57051. * Defines the location of the file to load
  57052. */
  57053. url: string,
  57054. /**
  57055. * Defines the desired size (the more it increases the longer the generation will be)
  57056. */
  57057. size: number,
  57058. /**
  57059. * Defines if mipmaps should not be generated (default is false)
  57060. */
  57061. noMipmap?: boolean,
  57062. /**
  57063. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57064. */
  57065. generateHarmonics?: boolean,
  57066. /**
  57067. * 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)
  57068. */
  57069. gammaSpace?: boolean,
  57070. /**
  57071. * Internal Use Only
  57072. */
  57073. reserved?: boolean);
  57074. /**
  57075. * Execute the current task
  57076. * @param scene defines the scene where you want your assets to be loaded
  57077. * @param onSuccess is a callback called when the task is successfully executed
  57078. * @param onError is a callback called if an error occurs
  57079. */
  57080. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57081. }
  57082. /**
  57083. * This class can be used to easily import assets into a scene
  57084. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57085. */
  57086. export class AssetsManager {
  57087. private _scene;
  57088. private _isLoading;
  57089. protected _tasks: AbstractAssetTask[];
  57090. protected _waitingTasksCount: number;
  57091. protected _totalTasksCount: number;
  57092. /**
  57093. * Callback called when all tasks are processed
  57094. */
  57095. onFinish: (tasks: AbstractAssetTask[]) => void;
  57096. /**
  57097. * Callback called when a task is successful
  57098. */
  57099. onTaskSuccess: (task: AbstractAssetTask) => void;
  57100. /**
  57101. * Callback called when a task had an error
  57102. */
  57103. onTaskError: (task: AbstractAssetTask) => void;
  57104. /**
  57105. * Callback called when a task is done (whatever the result is)
  57106. */
  57107. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57108. /**
  57109. * Observable called when all tasks are processed
  57110. */
  57111. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57112. /**
  57113. * Observable called when a task had an error
  57114. */
  57115. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57116. /**
  57117. * Observable called when all tasks were executed
  57118. */
  57119. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57120. /**
  57121. * Observable called when a task is done (whatever the result is)
  57122. */
  57123. onProgressObservable: Observable<IAssetsProgressEvent>;
  57124. /**
  57125. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57126. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57127. */
  57128. useDefaultLoadingScreen: boolean;
  57129. /**
  57130. * Creates a new AssetsManager
  57131. * @param scene defines the scene to work on
  57132. */
  57133. constructor(scene: Scene);
  57134. /**
  57135. * Add a MeshAssetTask to the list of active tasks
  57136. * @param taskName defines the name of the new task
  57137. * @param meshesNames defines the name of meshes to load
  57138. * @param rootUrl defines the root url to use to locate files
  57139. * @param sceneFilename defines the filename of the scene file
  57140. * @returns a new MeshAssetTask object
  57141. */
  57142. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57143. /**
  57144. * Add a TextFileAssetTask to the list of active tasks
  57145. * @param taskName defines the name of the new task
  57146. * @param url defines the url of the file to load
  57147. * @returns a new TextFileAssetTask object
  57148. */
  57149. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57150. /**
  57151. * Add a BinaryFileAssetTask to the list of active tasks
  57152. * @param taskName defines the name of the new task
  57153. * @param url defines the url of the file to load
  57154. * @returns a new BinaryFileAssetTask object
  57155. */
  57156. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57157. /**
  57158. * Add a ImageAssetTask to the list of active tasks
  57159. * @param taskName defines the name of the new task
  57160. * @param url defines the url of the file to load
  57161. * @returns a new ImageAssetTask object
  57162. */
  57163. addImageTask(taskName: string, url: string): ImageAssetTask;
  57164. /**
  57165. * Add a TextureAssetTask to the list of active tasks
  57166. * @param taskName defines the name of the new task
  57167. * @param url defines the url of the file to load
  57168. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57169. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57170. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57171. * @returns a new TextureAssetTask object
  57172. */
  57173. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57174. /**
  57175. * Add a CubeTextureAssetTask to the list of active tasks
  57176. * @param taskName defines the name of the new task
  57177. * @param url defines the url of the file to load
  57178. * @param extensions defines the extension to use to load the cube map (can be null)
  57179. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57180. * @param files defines the list of files to load (can be null)
  57181. * @returns a new CubeTextureAssetTask object
  57182. */
  57183. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57184. /**
  57185. *
  57186. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57187. * @param taskName defines the name of the new task
  57188. * @param url defines the url of the file to load
  57189. * @param size defines the size you want for the cubemap (can be null)
  57190. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57191. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57192. * @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)
  57193. * @param reserved Internal use only
  57194. * @returns a new HDRCubeTextureAssetTask object
  57195. */
  57196. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57197. /**
  57198. * Remove a task from the assets manager.
  57199. * @param task the task to remove
  57200. */
  57201. removeTask(task: AbstractAssetTask): void;
  57202. private _decreaseWaitingTasksCount;
  57203. private _runTask;
  57204. /**
  57205. * Reset the AssetsManager and remove all tasks
  57206. * @return the current instance of the AssetsManager
  57207. */
  57208. reset(): AssetsManager;
  57209. /**
  57210. * Start the loading process
  57211. * @return the current instance of the AssetsManager
  57212. */
  57213. load(): AssetsManager;
  57214. /**
  57215. * Start the loading process as an async operation
  57216. * @return a promise returning the list of failed tasks
  57217. */
  57218. loadAsync(): Promise<void>;
  57219. }
  57220. }
  57221. declare module "babylonjs/Misc/deferred" {
  57222. /**
  57223. * Wrapper class for promise with external resolve and reject.
  57224. */
  57225. export class Deferred<T> {
  57226. /**
  57227. * The promise associated with this deferred object.
  57228. */
  57229. readonly promise: Promise<T>;
  57230. private _resolve;
  57231. private _reject;
  57232. /**
  57233. * The resolve method of the promise associated with this deferred object.
  57234. */
  57235. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57236. /**
  57237. * The reject method of the promise associated with this deferred object.
  57238. */
  57239. readonly reject: (reason?: any) => void;
  57240. /**
  57241. * Constructor for this deferred object.
  57242. */
  57243. constructor();
  57244. }
  57245. }
  57246. declare module "babylonjs/Misc/meshExploder" {
  57247. import { Mesh } from "babylonjs/Meshes/mesh";
  57248. /**
  57249. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57250. */
  57251. export class MeshExploder {
  57252. private _centerMesh;
  57253. private _meshes;
  57254. private _meshesOrigins;
  57255. private _toCenterVectors;
  57256. private _scaledDirection;
  57257. private _newPosition;
  57258. private _centerPosition;
  57259. /**
  57260. * Explodes meshes from a center mesh.
  57261. * @param meshes The meshes to explode.
  57262. * @param centerMesh The mesh to be center of explosion.
  57263. */
  57264. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57265. private _setCenterMesh;
  57266. /**
  57267. * Get class name
  57268. * @returns "MeshExploder"
  57269. */
  57270. getClassName(): string;
  57271. /**
  57272. * "Exploded meshes"
  57273. * @returns Array of meshes with the centerMesh at index 0.
  57274. */
  57275. getMeshes(): Array<Mesh>;
  57276. /**
  57277. * Explodes meshes giving a specific direction
  57278. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57279. */
  57280. explode(direction?: number): void;
  57281. }
  57282. }
  57283. declare module "babylonjs/Misc/filesInput" {
  57284. import { Engine } from "babylonjs/Engines/engine";
  57285. import { Scene } from "babylonjs/scene";
  57286. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  57287. /**
  57288. * Class used to help managing file picking and drag'n'drop
  57289. */
  57290. export class FilesInput {
  57291. /**
  57292. * List of files ready to be loaded
  57293. */
  57294. static readonly FilesToLoad: {
  57295. [key: string]: File;
  57296. };
  57297. /**
  57298. * Callback called when a file is processed
  57299. */
  57300. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57301. private _engine;
  57302. private _currentScene;
  57303. private _sceneLoadedCallback;
  57304. private _progressCallback;
  57305. private _additionalRenderLoopLogicCallback;
  57306. private _textureLoadingCallback;
  57307. private _startingProcessingFilesCallback;
  57308. private _onReloadCallback;
  57309. private _errorCallback;
  57310. private _elementToMonitor;
  57311. private _sceneFileToLoad;
  57312. private _filesToLoad;
  57313. /**
  57314. * Creates a new FilesInput
  57315. * @param engine defines the rendering engine
  57316. * @param scene defines the hosting scene
  57317. * @param sceneLoadedCallback callback called when scene is loaded
  57318. * @param progressCallback callback called to track progress
  57319. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57320. * @param textureLoadingCallback callback called when a texture is loading
  57321. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57322. * @param onReloadCallback callback called when a reload is requested
  57323. * @param errorCallback callback call if an error occurs
  57324. */
  57325. 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);
  57326. private _dragEnterHandler;
  57327. private _dragOverHandler;
  57328. private _dropHandler;
  57329. /**
  57330. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57331. * @param elementToMonitor defines the DOM element to track
  57332. */
  57333. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57334. /**
  57335. * Release all associated resources
  57336. */
  57337. dispose(): void;
  57338. private renderFunction;
  57339. private drag;
  57340. private drop;
  57341. private _traverseFolder;
  57342. private _processFiles;
  57343. /**
  57344. * Load files from a drop event
  57345. * @param event defines the drop event to use as source
  57346. */
  57347. loadFiles(event: any): void;
  57348. private _processReload;
  57349. /**
  57350. * Reload the current scene from the loaded files
  57351. */
  57352. reload(): void;
  57353. }
  57354. }
  57355. declare module "babylonjs/Misc/HighDynamicRange/index" {
  57356. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  57357. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  57358. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57359. }
  57360. declare module "babylonjs/Misc/sceneOptimizer" {
  57361. import { Scene, IDisposable } from "babylonjs/scene";
  57362. import { Observable } from "babylonjs/Misc/observable";
  57363. /**
  57364. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57365. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57366. */
  57367. export class SceneOptimization {
  57368. /**
  57369. * Defines the priority of this optimization (0 by default which means first in the list)
  57370. */
  57371. priority: number;
  57372. /**
  57373. * Gets a string describing the action executed by the current optimization
  57374. * @returns description string
  57375. */
  57376. getDescription(): string;
  57377. /**
  57378. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57379. * @param scene defines the current scene where to apply this optimization
  57380. * @param optimizer defines the current optimizer
  57381. * @returns true if everything that can be done was applied
  57382. */
  57383. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57384. /**
  57385. * Creates the SceneOptimization object
  57386. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57387. * @param desc defines the description associated with the optimization
  57388. */
  57389. constructor(
  57390. /**
  57391. * Defines the priority of this optimization (0 by default which means first in the list)
  57392. */
  57393. priority?: number);
  57394. }
  57395. /**
  57396. * Defines an optimization used to reduce the size of render target textures
  57397. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57398. */
  57399. export class TextureOptimization extends SceneOptimization {
  57400. /**
  57401. * Defines the priority of this optimization (0 by default which means first in the list)
  57402. */
  57403. priority: number;
  57404. /**
  57405. * 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
  57406. */
  57407. maximumSize: number;
  57408. /**
  57409. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57410. */
  57411. step: number;
  57412. /**
  57413. * Gets a string describing the action executed by the current optimization
  57414. * @returns description string
  57415. */
  57416. getDescription(): string;
  57417. /**
  57418. * Creates the TextureOptimization object
  57419. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57420. * @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
  57421. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57422. */
  57423. constructor(
  57424. /**
  57425. * Defines the priority of this optimization (0 by default which means first in the list)
  57426. */
  57427. priority?: number,
  57428. /**
  57429. * 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
  57430. */
  57431. maximumSize?: number,
  57432. /**
  57433. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57434. */
  57435. step?: number);
  57436. /**
  57437. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57438. * @param scene defines the current scene where to apply this optimization
  57439. * @param optimizer defines the current optimizer
  57440. * @returns true if everything that can be done was applied
  57441. */
  57442. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57443. }
  57444. /**
  57445. * Defines an optimization used to increase or decrease the rendering resolution
  57446. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57447. */
  57448. export class HardwareScalingOptimization extends SceneOptimization {
  57449. /**
  57450. * Defines the priority of this optimization (0 by default which means first in the list)
  57451. */
  57452. priority: number;
  57453. /**
  57454. * Defines the maximum scale to use (2 by default)
  57455. */
  57456. maximumScale: number;
  57457. /**
  57458. * Defines the step to use between two passes (0.5 by default)
  57459. */
  57460. step: number;
  57461. private _currentScale;
  57462. private _directionOffset;
  57463. /**
  57464. * Gets a string describing the action executed by the current optimization
  57465. * @return description string
  57466. */
  57467. getDescription(): string;
  57468. /**
  57469. * Creates the HardwareScalingOptimization object
  57470. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57471. * @param maximumScale defines the maximum scale to use (2 by default)
  57472. * @param step defines the step to use between two passes (0.5 by default)
  57473. */
  57474. constructor(
  57475. /**
  57476. * Defines the priority of this optimization (0 by default which means first in the list)
  57477. */
  57478. priority?: number,
  57479. /**
  57480. * Defines the maximum scale to use (2 by default)
  57481. */
  57482. maximumScale?: number,
  57483. /**
  57484. * Defines the step to use between two passes (0.5 by default)
  57485. */
  57486. step?: number);
  57487. /**
  57488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57489. * @param scene defines the current scene where to apply this optimization
  57490. * @param optimizer defines the current optimizer
  57491. * @returns true if everything that can be done was applied
  57492. */
  57493. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57494. }
  57495. /**
  57496. * Defines an optimization used to remove shadows
  57497. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57498. */
  57499. export class ShadowsOptimization extends SceneOptimization {
  57500. /**
  57501. * Gets a string describing the action executed by the current optimization
  57502. * @return description string
  57503. */
  57504. getDescription(): string;
  57505. /**
  57506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57507. * @param scene defines the current scene where to apply this optimization
  57508. * @param optimizer defines the current optimizer
  57509. * @returns true if everything that can be done was applied
  57510. */
  57511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57512. }
  57513. /**
  57514. * Defines an optimization used to turn post-processes off
  57515. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57516. */
  57517. export class PostProcessesOptimization extends SceneOptimization {
  57518. /**
  57519. * Gets a string describing the action executed by the current optimization
  57520. * @return description string
  57521. */
  57522. getDescription(): string;
  57523. /**
  57524. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57525. * @param scene defines the current scene where to apply this optimization
  57526. * @param optimizer defines the current optimizer
  57527. * @returns true if everything that can be done was applied
  57528. */
  57529. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57530. }
  57531. /**
  57532. * Defines an optimization used to turn lens flares off
  57533. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57534. */
  57535. export class LensFlaresOptimization extends SceneOptimization {
  57536. /**
  57537. * Gets a string describing the action executed by the current optimization
  57538. * @return description string
  57539. */
  57540. getDescription(): string;
  57541. /**
  57542. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57543. * @param scene defines the current scene where to apply this optimization
  57544. * @param optimizer defines the current optimizer
  57545. * @returns true if everything that can be done was applied
  57546. */
  57547. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57548. }
  57549. /**
  57550. * Defines an optimization based on user defined callback.
  57551. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57552. */
  57553. export class CustomOptimization extends SceneOptimization {
  57554. /**
  57555. * Callback called to apply the custom optimization.
  57556. */
  57557. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57558. /**
  57559. * Callback called to get custom description
  57560. */
  57561. onGetDescription: () => string;
  57562. /**
  57563. * Gets a string describing the action executed by the current optimization
  57564. * @returns description string
  57565. */
  57566. getDescription(): string;
  57567. /**
  57568. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57569. * @param scene defines the current scene where to apply this optimization
  57570. * @param optimizer defines the current optimizer
  57571. * @returns true if everything that can be done was applied
  57572. */
  57573. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57574. }
  57575. /**
  57576. * Defines an optimization used to turn particles off
  57577. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57578. */
  57579. export class ParticlesOptimization extends SceneOptimization {
  57580. /**
  57581. * Gets a string describing the action executed by the current optimization
  57582. * @return description string
  57583. */
  57584. getDescription(): string;
  57585. /**
  57586. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57587. * @param scene defines the current scene where to apply this optimization
  57588. * @param optimizer defines the current optimizer
  57589. * @returns true if everything that can be done was applied
  57590. */
  57591. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57592. }
  57593. /**
  57594. * Defines an optimization used to turn render targets off
  57595. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57596. */
  57597. export class RenderTargetsOptimization extends SceneOptimization {
  57598. /**
  57599. * Gets a string describing the action executed by the current optimization
  57600. * @return description string
  57601. */
  57602. getDescription(): string;
  57603. /**
  57604. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57605. * @param scene defines the current scene where to apply this optimization
  57606. * @param optimizer defines the current optimizer
  57607. * @returns true if everything that can be done was applied
  57608. */
  57609. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57610. }
  57611. /**
  57612. * Defines an optimization used to merge meshes with compatible materials
  57613. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57614. */
  57615. export class MergeMeshesOptimization extends SceneOptimization {
  57616. private static _UpdateSelectionTree;
  57617. /**
  57618. * Gets or sets a boolean which defines if optimization octree has to be updated
  57619. */
  57620. /**
  57621. * Gets or sets a boolean which defines if optimization octree has to be updated
  57622. */
  57623. static UpdateSelectionTree: boolean;
  57624. /**
  57625. * Gets a string describing the action executed by the current optimization
  57626. * @return description string
  57627. */
  57628. getDescription(): string;
  57629. private _canBeMerged;
  57630. /**
  57631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57632. * @param scene defines the current scene where to apply this optimization
  57633. * @param optimizer defines the current optimizer
  57634. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  57635. * @returns true if everything that can be done was applied
  57636. */
  57637. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  57638. }
  57639. /**
  57640. * Defines a list of options used by SceneOptimizer
  57641. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57642. */
  57643. export class SceneOptimizerOptions {
  57644. /**
  57645. * Defines the target frame rate to reach (60 by default)
  57646. */
  57647. targetFrameRate: number;
  57648. /**
  57649. * Defines the interval between two checkes (2000ms by default)
  57650. */
  57651. trackerDuration: number;
  57652. /**
  57653. * Gets the list of optimizations to apply
  57654. */
  57655. optimizations: SceneOptimization[];
  57656. /**
  57657. * Creates a new list of options used by SceneOptimizer
  57658. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  57659. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  57660. */
  57661. constructor(
  57662. /**
  57663. * Defines the target frame rate to reach (60 by default)
  57664. */
  57665. targetFrameRate?: number,
  57666. /**
  57667. * Defines the interval between two checkes (2000ms by default)
  57668. */
  57669. trackerDuration?: number);
  57670. /**
  57671. * Add a new optimization
  57672. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  57673. * @returns the current SceneOptimizerOptions
  57674. */
  57675. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  57676. /**
  57677. * Add a new custom optimization
  57678. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  57679. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  57680. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57681. * @returns the current SceneOptimizerOptions
  57682. */
  57683. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  57684. /**
  57685. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  57686. * @param targetFrameRate defines the target frame rate (60 by default)
  57687. * @returns a SceneOptimizerOptions object
  57688. */
  57689. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57690. /**
  57691. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  57692. * @param targetFrameRate defines the target frame rate (60 by default)
  57693. * @returns a SceneOptimizerOptions object
  57694. */
  57695. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57696. /**
  57697. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  57698. * @param targetFrameRate defines the target frame rate (60 by default)
  57699. * @returns a SceneOptimizerOptions object
  57700. */
  57701. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57702. }
  57703. /**
  57704. * Class used to run optimizations in order to reach a target frame rate
  57705. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57706. */
  57707. export class SceneOptimizer implements IDisposable {
  57708. private _isRunning;
  57709. private _options;
  57710. private _scene;
  57711. private _currentPriorityLevel;
  57712. private _targetFrameRate;
  57713. private _trackerDuration;
  57714. private _currentFrameRate;
  57715. private _sceneDisposeObserver;
  57716. private _improvementMode;
  57717. /**
  57718. * Defines an observable called when the optimizer reaches the target frame rate
  57719. */
  57720. onSuccessObservable: Observable<SceneOptimizer>;
  57721. /**
  57722. * Defines an observable called when the optimizer enables an optimization
  57723. */
  57724. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57725. /**
  57726. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57727. */
  57728. onFailureObservable: Observable<SceneOptimizer>;
  57729. /**
  57730. * Gets a boolean indicating if the optimizer is in improvement mode
  57731. */
  57732. readonly isInImprovementMode: boolean;
  57733. /**
  57734. * Gets the current priority level (0 at start)
  57735. */
  57736. readonly currentPriorityLevel: number;
  57737. /**
  57738. * Gets the current frame rate checked by the SceneOptimizer
  57739. */
  57740. readonly currentFrameRate: number;
  57741. /**
  57742. * Gets or sets the current target frame rate (60 by default)
  57743. */
  57744. /**
  57745. * Gets or sets the current target frame rate (60 by default)
  57746. */
  57747. targetFrameRate: number;
  57748. /**
  57749. * Gets or sets the current interval between two checks (every 2000ms by default)
  57750. */
  57751. /**
  57752. * Gets or sets the current interval between two checks (every 2000ms by default)
  57753. */
  57754. trackerDuration: number;
  57755. /**
  57756. * Gets the list of active optimizations
  57757. */
  57758. readonly optimizations: SceneOptimization[];
  57759. /**
  57760. * Creates a new SceneOptimizer
  57761. * @param scene defines the scene to work on
  57762. * @param options defines the options to use with the SceneOptimizer
  57763. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57764. * @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)
  57765. */
  57766. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57767. /**
  57768. * Stops the current optimizer
  57769. */
  57770. stop(): void;
  57771. /**
  57772. * Reset the optimizer to initial step (current priority level = 0)
  57773. */
  57774. reset(): void;
  57775. /**
  57776. * Start the optimizer. By default it will try to reach a specific framerate
  57777. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57778. */
  57779. start(): void;
  57780. private _checkCurrentState;
  57781. /**
  57782. * Release all resources
  57783. */
  57784. dispose(): void;
  57785. /**
  57786. * Helper function to create a SceneOptimizer with one single line of code
  57787. * @param scene defines the scene to work on
  57788. * @param options defines the options to use with the SceneOptimizer
  57789. * @param onSuccess defines a callback to call on success
  57790. * @param onFailure defines a callback to call on failure
  57791. * @returns the new SceneOptimizer object
  57792. */
  57793. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57794. }
  57795. }
  57796. declare module "babylonjs/Misc/sceneSerializer" {
  57797. import { Scene } from "babylonjs/scene";
  57798. /**
  57799. * Class used to serialize a scene into a string
  57800. */
  57801. export class SceneSerializer {
  57802. /**
  57803. * Clear cache used by a previous serialization
  57804. */
  57805. static ClearCache(): void;
  57806. /**
  57807. * Serialize a scene into a JSON compatible object
  57808. * @param scene defines the scene to serialize
  57809. * @returns a JSON compatible object
  57810. */
  57811. static Serialize(scene: Scene): any;
  57812. /**
  57813. * Serialize a mesh into a JSON compatible object
  57814. * @param toSerialize defines the mesh to serialize
  57815. * @param withParents defines if parents must be serialized as well
  57816. * @param withChildren defines if children must be serialized as well
  57817. * @returns a JSON compatible object
  57818. */
  57819. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57820. }
  57821. }
  57822. declare module "babylonjs/Misc/textureTools" {
  57823. import { Texture } from "babylonjs/Materials/Textures/texture";
  57824. /**
  57825. * Class used to host texture specific utilities
  57826. */
  57827. export class TextureTools {
  57828. /**
  57829. * Uses the GPU to create a copy texture rescaled at a given size
  57830. * @param texture Texture to copy from
  57831. * @param width defines the desired width
  57832. * @param height defines the desired height
  57833. * @param useBilinearMode defines if bilinear mode has to be used
  57834. * @return the generated texture
  57835. */
  57836. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  57837. }
  57838. }
  57839. declare module "babylonjs/Misc/videoRecorder" {
  57840. import { Nullable } from "babylonjs/types";
  57841. import { Engine } from "babylonjs/Engines/engine";
  57842. /**
  57843. * This represents the different options avilable for the video capture.
  57844. */
  57845. export interface VideoRecorderOptions {
  57846. /** Defines the mime type of the video */
  57847. mimeType: string;
  57848. /** Defines the video the video should be recorded at */
  57849. fps: number;
  57850. /** Defines the chunk size for the recording data */
  57851. recordChunckSize: number;
  57852. /** The audio tracks to attach to the record */
  57853. audioTracks?: MediaStreamTrack[];
  57854. }
  57855. /**
  57856. * This can helps recording videos from BabylonJS.
  57857. * This is based on the available WebRTC functionalities of the browser.
  57858. *
  57859. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57860. */
  57861. export class VideoRecorder {
  57862. private static readonly _defaultOptions;
  57863. /**
  57864. * Returns wehther or not the VideoRecorder is available in your browser.
  57865. * @param engine Defines the Babylon Engine to check the support for
  57866. * @returns true if supported otherwise false
  57867. */
  57868. static IsSupported(engine: Engine): boolean;
  57869. private readonly _options;
  57870. private _canvas;
  57871. private _mediaRecorder;
  57872. private _recordedChunks;
  57873. private _fileName;
  57874. private _resolve;
  57875. private _reject;
  57876. /**
  57877. * True wether a recording is already in progress.
  57878. */
  57879. readonly isRecording: boolean;
  57880. /**
  57881. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57882. * a video file.
  57883. * @param engine Defines the BabylonJS Engine you wish to record
  57884. * @param options Defines options that can be used to customized the capture
  57885. */
  57886. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57887. /**
  57888. * Stops the current recording before the default capture timeout passed in the startRecording
  57889. * functions.
  57890. */
  57891. stopRecording(): void;
  57892. /**
  57893. * Starts recording the canvas for a max duration specified in parameters.
  57894. * @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.
  57895. * @param maxDuration Defines the maximum recording time in seconds.
  57896. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57897. * @return a promise callback at the end of the recording with the video data in Blob.
  57898. */
  57899. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57900. /**
  57901. * Releases internal resources used during the recording.
  57902. */
  57903. dispose(): void;
  57904. private _handleDataAvailable;
  57905. private _handleError;
  57906. private _handleStop;
  57907. }
  57908. }
  57909. declare module "babylonjs/Misc/workerPool" {
  57910. import { IDisposable } from "babylonjs/scene";
  57911. /**
  57912. * Helper class to push actions to a pool of workers.
  57913. */
  57914. export class WorkerPool implements IDisposable {
  57915. private _workerInfos;
  57916. private _pendingActions;
  57917. /**
  57918. * Constructor
  57919. * @param workers Array of workers to use for actions
  57920. */
  57921. constructor(workers: Array<Worker>);
  57922. /**
  57923. * Terminates all workers and clears any pending actions.
  57924. */
  57925. dispose(): void;
  57926. /**
  57927. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57928. * pended until a worker has completed its action.
  57929. * @param action The action to perform. Call onComplete when the action is complete.
  57930. */
  57931. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57932. private _execute;
  57933. }
  57934. }
  57935. declare module "babylonjs/Misc/screenshotTools" {
  57936. import { Camera } from "babylonjs/Cameras/camera";
  57937. import { Engine } from "babylonjs/Engines/engine";
  57938. /**
  57939. * Class containing a set of static utilities functions for screenshots
  57940. */
  57941. export class ScreenshotTools {
  57942. /**
  57943. * Captures a screenshot of the current rendering
  57944. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57945. * @param engine defines the rendering engine
  57946. * @param camera defines the source camera
  57947. * @param size This parameter can be set to a single number or to an object with the
  57948. * following (optional) properties: precision, width, height. If a single number is passed,
  57949. * it will be used for both width and height. If an object is passed, the screenshot size
  57950. * will be derived from the parameters. The precision property is a multiplier allowing
  57951. * rendering at a higher or lower resolution
  57952. * @param successCallback defines the callback receives a single parameter which contains the
  57953. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57954. * src parameter of an <img> to display it
  57955. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57956. * Check your browser for supported MIME types
  57957. */
  57958. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57959. /**
  57960. * Generates an image screenshot from the specified camera.
  57961. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57962. * @param engine The engine to use for rendering
  57963. * @param camera The camera to use for rendering
  57964. * @param size This parameter can be set to a single number or to an object with the
  57965. * following (optional) properties: precision, width, height. If a single number is passed,
  57966. * it will be used for both width and height. If an object is passed, the screenshot size
  57967. * will be derived from the parameters. The precision property is a multiplier allowing
  57968. * rendering at a higher or lower resolution
  57969. * @param successCallback The callback receives a single parameter which contains the
  57970. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57971. * src parameter of an <img> to display it
  57972. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57973. * Check your browser for supported MIME types
  57974. * @param samples Texture samples (default: 1)
  57975. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57976. * @param fileName A name for for the downloaded file.
  57977. */
  57978. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57979. }
  57980. }
  57981. declare module "babylonjs/Misc/index" {
  57982. export * from "babylonjs/Misc/andOrNotEvaluator";
  57983. export * from "babylonjs/Misc/assetsManager";
  57984. export * from "babylonjs/Misc/dds";
  57985. export * from "babylonjs/Misc/decorators";
  57986. export * from "babylonjs/Misc/deferred";
  57987. export * from "babylonjs/Misc/environmentTextureTools";
  57988. export * from "babylonjs/Misc/meshExploder";
  57989. export * from "babylonjs/Misc/filesInput";
  57990. export * from "babylonjs/Misc/HighDynamicRange/index";
  57991. export * from "babylonjs/Misc/khronosTextureContainer";
  57992. export * from "babylonjs/Misc/observable";
  57993. export * from "babylonjs/Misc/performanceMonitor";
  57994. export * from "babylonjs/Misc/promise";
  57995. export * from "babylonjs/Misc/sceneOptimizer";
  57996. export * from "babylonjs/Misc/sceneSerializer";
  57997. export * from "babylonjs/Misc/smartArray";
  57998. export * from "babylonjs/Misc/stringDictionary";
  57999. export * from "babylonjs/Misc/tags";
  58000. export * from "babylonjs/Misc/textureTools";
  58001. export * from "babylonjs/Misc/tga";
  58002. export * from "babylonjs/Misc/tools";
  58003. export * from "babylonjs/Misc/videoRecorder";
  58004. export * from "babylonjs/Misc/virtualJoystick";
  58005. export * from "babylonjs/Misc/workerPool";
  58006. export * from "babylonjs/Misc/logger";
  58007. export * from "babylonjs/Misc/typeStore";
  58008. export * from "babylonjs/Misc/filesInputStore";
  58009. export * from "babylonjs/Misc/deepCopier";
  58010. export * from "babylonjs/Misc/pivotTools";
  58011. export * from "babylonjs/Misc/precisionDate";
  58012. export * from "babylonjs/Misc/screenshotTools";
  58013. export * from "babylonjs/Misc/typeStore";
  58014. export * from "babylonjs/Misc/webRequest";
  58015. export * from "babylonjs/Misc/iInspectable";
  58016. }
  58017. declare module "babylonjs/index" {
  58018. export * from "babylonjs/abstractScene";
  58019. export * from "babylonjs/Actions/index";
  58020. export * from "babylonjs/Animations/index";
  58021. export * from "babylonjs/assetContainer";
  58022. export * from "babylonjs/Audio/index";
  58023. export * from "babylonjs/Behaviors/index";
  58024. export * from "babylonjs/Bones/index";
  58025. export * from "babylonjs/Cameras/index";
  58026. export * from "babylonjs/Collisions/index";
  58027. export * from "babylonjs/Culling/index";
  58028. export * from "babylonjs/Debug/index";
  58029. export * from "babylonjs/Engines/index";
  58030. export * from "babylonjs/Events/index";
  58031. export * from "babylonjs/Gamepads/index";
  58032. export * from "babylonjs/Gizmos/index";
  58033. export * from "babylonjs/Helpers/index";
  58034. export * from "babylonjs/Instrumentation/index";
  58035. export * from "babylonjs/Layers/index";
  58036. export * from "babylonjs/LensFlares/index";
  58037. export * from "babylonjs/Lights/index";
  58038. export * from "babylonjs/Loading/index";
  58039. export * from "babylonjs/Materials/index";
  58040. export * from "babylonjs/Maths/index";
  58041. export * from "babylonjs/Meshes/index";
  58042. export * from "babylonjs/Morph/index";
  58043. export * from "babylonjs/node";
  58044. export * from "babylonjs/Offline/index";
  58045. export * from "babylonjs/Particles/index";
  58046. export * from "babylonjs/Physics/index";
  58047. export * from "babylonjs/PostProcesses/index";
  58048. export * from "babylonjs/Probes/index";
  58049. export * from "babylonjs/Rendering/index";
  58050. export * from "babylonjs/scene";
  58051. export * from "babylonjs/sceneComponent";
  58052. export * from "babylonjs/Sprites/index";
  58053. export * from "babylonjs/States/index";
  58054. export * from "babylonjs/Misc/index";
  58055. export * from "babylonjs/types";
  58056. }
  58057. declare module "babylonjs/Animations/pathCursor" {
  58058. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58059. /**
  58060. * A cursor which tracks a point on a path
  58061. */
  58062. export class PathCursor {
  58063. private path;
  58064. /**
  58065. * Stores path cursor callbacks for when an onchange event is triggered
  58066. */
  58067. private _onchange;
  58068. /**
  58069. * The value of the path cursor
  58070. */
  58071. value: number;
  58072. /**
  58073. * The animation array of the path cursor
  58074. */
  58075. animations: Animation[];
  58076. /**
  58077. * Initializes the path cursor
  58078. * @param path The path to track
  58079. */
  58080. constructor(path: Path2);
  58081. /**
  58082. * Gets the cursor point on the path
  58083. * @returns A point on the path cursor at the cursor location
  58084. */
  58085. getPoint(): Vector3;
  58086. /**
  58087. * Moves the cursor ahead by the step amount
  58088. * @param step The amount to move the cursor forward
  58089. * @returns This path cursor
  58090. */
  58091. moveAhead(step?: number): PathCursor;
  58092. /**
  58093. * Moves the cursor behind by the step amount
  58094. * @param step The amount to move the cursor back
  58095. * @returns This path cursor
  58096. */
  58097. moveBack(step?: number): PathCursor;
  58098. /**
  58099. * Moves the cursor by the step amount
  58100. * If the step amount is greater than one, an exception is thrown
  58101. * @param step The amount to move the cursor
  58102. * @returns This path cursor
  58103. */
  58104. move(step: number): PathCursor;
  58105. /**
  58106. * Ensures that the value is limited between zero and one
  58107. * @returns This path cursor
  58108. */
  58109. private ensureLimits;
  58110. /**
  58111. * Runs onchange callbacks on change (used by the animation engine)
  58112. * @returns This path cursor
  58113. */
  58114. private raiseOnChange;
  58115. /**
  58116. * Executes a function on change
  58117. * @param f A path cursor onchange callback
  58118. * @returns This path cursor
  58119. */
  58120. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58121. }
  58122. }
  58123. declare module "babylonjs/Legacy/legacy" {
  58124. import * as Babylon from "babylonjs/index";
  58125. export * from "babylonjs/index";
  58126. }
  58127. declare module "babylonjs/Shaders/blur.fragment" {
  58128. /** @hidden */
  58129. export var blurPixelShader: {
  58130. name: string;
  58131. shader: string;
  58132. };
  58133. }
  58134. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  58135. /** @hidden */
  58136. export var vrMultiviewToSingleviewPixelShader: {
  58137. name: string;
  58138. shader: string;
  58139. };
  58140. }
  58141. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58142. /** @hidden */
  58143. export var bones300Declaration: {
  58144. name: string;
  58145. shader: string;
  58146. };
  58147. }
  58148. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58149. /** @hidden */
  58150. export var instances300Declaration: {
  58151. name: string;
  58152. shader: string;
  58153. };
  58154. }
  58155. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58156. /** @hidden */
  58157. export var pointCloudVertexDeclaration: {
  58158. name: string;
  58159. shader: string;
  58160. };
  58161. }
  58162. // Mixins
  58163. interface Window {
  58164. mozIndexedDB: IDBFactory;
  58165. webkitIndexedDB: IDBFactory;
  58166. msIndexedDB: IDBFactory;
  58167. webkitURL: typeof URL;
  58168. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58169. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58170. WebGLRenderingContext: WebGLRenderingContext;
  58171. MSGesture: MSGesture;
  58172. CANNON: any;
  58173. AudioContext: AudioContext;
  58174. webkitAudioContext: AudioContext;
  58175. PointerEvent: any;
  58176. Math: Math;
  58177. Uint8Array: Uint8ArrayConstructor;
  58178. Float32Array: Float32ArrayConstructor;
  58179. mozURL: typeof URL;
  58180. msURL: typeof URL;
  58181. VRFrameData: any; // WebVR, from specs 1.1
  58182. DracoDecoderModule: any;
  58183. setImmediate(handler: (...args: any[]) => void): number;
  58184. }
  58185. interface HTMLCanvasElement {
  58186. requestPointerLock(): void;
  58187. msRequestPointerLock?(): void;
  58188. mozRequestPointerLock?(): void;
  58189. webkitRequestPointerLock?(): void;
  58190. /** Track wether a record is in progress */
  58191. isRecording: boolean;
  58192. /** Capture Stream method defined by some browsers */
  58193. captureStream(fps?: number): MediaStream;
  58194. }
  58195. interface CanvasRenderingContext2D {
  58196. msImageSmoothingEnabled: boolean;
  58197. }
  58198. interface MouseEvent {
  58199. mozMovementX: number;
  58200. mozMovementY: number;
  58201. webkitMovementX: number;
  58202. webkitMovementY: number;
  58203. msMovementX: number;
  58204. msMovementY: number;
  58205. }
  58206. interface Navigator {
  58207. mozGetVRDevices: (any: any) => any;
  58208. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58209. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58210. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58211. webkitGetGamepads(): Gamepad[];
  58212. msGetGamepads(): Gamepad[];
  58213. webkitGamepads(): Gamepad[];
  58214. }
  58215. interface HTMLVideoElement {
  58216. mozSrcObject: any;
  58217. }
  58218. interface Math {
  58219. fround(x: number): number;
  58220. imul(a: number, b: number): number;
  58221. }
  58222. interface WebGLProgram {
  58223. context?: WebGLRenderingContext;
  58224. vertexShader?: WebGLShader;
  58225. fragmentShader?: WebGLShader;
  58226. isParallelCompiled: boolean;
  58227. onCompiled?: () => void;
  58228. }
  58229. interface WebGLRenderingContext {
  58230. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58231. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58232. vertexAttribDivisor(index: number, divisor: number): void;
  58233. createVertexArray(): any;
  58234. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58235. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58236. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58237. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58238. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58239. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58240. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58241. // Queries
  58242. createQuery(): WebGLQuery;
  58243. deleteQuery(query: WebGLQuery): void;
  58244. beginQuery(target: number, query: WebGLQuery): void;
  58245. endQuery(target: number): void;
  58246. getQueryParameter(query: WebGLQuery, pname: number): any;
  58247. getQuery(target: number, pname: number): any;
  58248. MAX_SAMPLES: number;
  58249. RGBA8: number;
  58250. READ_FRAMEBUFFER: number;
  58251. DRAW_FRAMEBUFFER: number;
  58252. UNIFORM_BUFFER: number;
  58253. HALF_FLOAT_OES: number;
  58254. RGBA16F: number;
  58255. RGBA32F: number;
  58256. R32F: number;
  58257. RG32F: number;
  58258. RGB32F: number;
  58259. R16F: number;
  58260. RG16F: number;
  58261. RGB16F: number;
  58262. RED: number;
  58263. RG: number;
  58264. R8: number;
  58265. RG8: number;
  58266. UNSIGNED_INT_24_8: number;
  58267. DEPTH24_STENCIL8: number;
  58268. /* Multiple Render Targets */
  58269. drawBuffers(buffers: number[]): void;
  58270. readBuffer(src: number): void;
  58271. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58272. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58273. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58274. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58275. // Occlusion Query
  58276. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58277. ANY_SAMPLES_PASSED: number;
  58278. QUERY_RESULT_AVAILABLE: number;
  58279. QUERY_RESULT: number;
  58280. }
  58281. interface WebGLBuffer {
  58282. references: number;
  58283. capacity: number;
  58284. is32Bits: boolean;
  58285. }
  58286. interface WebGLProgram {
  58287. transformFeedback?: WebGLTransformFeedback | null;
  58288. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58289. }
  58290. interface EXT_disjoint_timer_query {
  58291. QUERY_COUNTER_BITS_EXT: number;
  58292. TIME_ELAPSED_EXT: number;
  58293. TIMESTAMP_EXT: number;
  58294. GPU_DISJOINT_EXT: number;
  58295. QUERY_RESULT_EXT: number;
  58296. QUERY_RESULT_AVAILABLE_EXT: number;
  58297. queryCounterEXT(query: WebGLQuery, target: number): void;
  58298. createQueryEXT(): WebGLQuery;
  58299. beginQueryEXT(target: number, query: WebGLQuery): void;
  58300. endQueryEXT(target: number): void;
  58301. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58302. deleteQueryEXT(query: WebGLQuery): void;
  58303. }
  58304. interface WebGLUniformLocation {
  58305. _currentState: any;
  58306. }
  58307. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58308. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58309. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58310. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58311. interface WebGLRenderingContext {
  58312. readonly RASTERIZER_DISCARD: number;
  58313. readonly DEPTH_COMPONENT24: number;
  58314. readonly TEXTURE_3D: number;
  58315. readonly TEXTURE_2D_ARRAY: number;
  58316. readonly TEXTURE_COMPARE_FUNC: number;
  58317. readonly TEXTURE_COMPARE_MODE: number;
  58318. readonly COMPARE_REF_TO_TEXTURE: number;
  58319. readonly TEXTURE_WRAP_R: number;
  58320. readonly HALF_FLOAT: number;
  58321. readonly RGB8: number;
  58322. readonly RED_INTEGER: number;
  58323. readonly RG_INTEGER: number;
  58324. readonly RGB_INTEGER: number;
  58325. readonly RGBA_INTEGER: number;
  58326. readonly R8_SNORM: number;
  58327. readonly RG8_SNORM: number;
  58328. readonly RGB8_SNORM: number;
  58329. readonly RGBA8_SNORM: number;
  58330. readonly R8I: number;
  58331. readonly RG8I: number;
  58332. readonly RGB8I: number;
  58333. readonly RGBA8I: number;
  58334. readonly R8UI: number;
  58335. readonly RG8UI: number;
  58336. readonly RGB8UI: number;
  58337. readonly RGBA8UI: number;
  58338. readonly R16I: number;
  58339. readonly RG16I: number;
  58340. readonly RGB16I: number;
  58341. readonly RGBA16I: number;
  58342. readonly R16UI: number;
  58343. readonly RG16UI: number;
  58344. readonly RGB16UI: number;
  58345. readonly RGBA16UI: number;
  58346. readonly R32I: number;
  58347. readonly RG32I: number;
  58348. readonly RGB32I: number;
  58349. readonly RGBA32I: number;
  58350. readonly R32UI: number;
  58351. readonly RG32UI: number;
  58352. readonly RGB32UI: number;
  58353. readonly RGBA32UI: number;
  58354. readonly RGB10_A2UI: number;
  58355. readonly R11F_G11F_B10F: number;
  58356. readonly RGB9_E5: number;
  58357. readonly RGB10_A2: number;
  58358. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58359. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58360. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58361. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58362. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58363. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58364. 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;
  58365. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58366. readonly TRANSFORM_FEEDBACK: number;
  58367. readonly INTERLEAVED_ATTRIBS: number;
  58368. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58369. createTransformFeedback(): WebGLTransformFeedback;
  58370. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58371. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58372. beginTransformFeedback(primitiveMode: number): void;
  58373. endTransformFeedback(): void;
  58374. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58375. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58376. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58377. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58378. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58379. }
  58380. interface ImageBitmap {
  58381. readonly width: number;
  58382. readonly height: number;
  58383. close(): void;
  58384. }
  58385. interface WebGLQuery extends WebGLObject {
  58386. }
  58387. declare var WebGLQuery: {
  58388. prototype: WebGLQuery;
  58389. new(): WebGLQuery;
  58390. };
  58391. interface WebGLSampler extends WebGLObject {
  58392. }
  58393. declare var WebGLSampler: {
  58394. prototype: WebGLSampler;
  58395. new(): WebGLSampler;
  58396. };
  58397. interface WebGLSync extends WebGLObject {
  58398. }
  58399. declare var WebGLSync: {
  58400. prototype: WebGLSync;
  58401. new(): WebGLSync;
  58402. };
  58403. interface WebGLTransformFeedback extends WebGLObject {
  58404. }
  58405. declare var WebGLTransformFeedback: {
  58406. prototype: WebGLTransformFeedback;
  58407. new(): WebGLTransformFeedback;
  58408. };
  58409. interface WebGLVertexArrayObject extends WebGLObject {
  58410. }
  58411. declare var WebGLVertexArrayObject: {
  58412. prototype: WebGLVertexArrayObject;
  58413. new(): WebGLVertexArrayObject;
  58414. };
  58415. // Type definitions for WebVR API
  58416. // Project: https://w3c.github.io/webvr/
  58417. // Definitions by: six a <https://github.com/lostfictions>
  58418. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58419. interface VRDisplay extends EventTarget {
  58420. /**
  58421. * Dictionary of capabilities describing the VRDisplay.
  58422. */
  58423. readonly capabilities: VRDisplayCapabilities;
  58424. /**
  58425. * z-depth defining the far plane of the eye view frustum
  58426. * enables mapping of values in the render target depth
  58427. * attachment to scene coordinates. Initially set to 10000.0.
  58428. */
  58429. depthFar: number;
  58430. /**
  58431. * z-depth defining the near plane of the eye view frustum
  58432. * enables mapping of values in the render target depth
  58433. * attachment to scene coordinates. Initially set to 0.01.
  58434. */
  58435. depthNear: number;
  58436. /**
  58437. * An identifier for this distinct VRDisplay. Used as an
  58438. * association point in the Gamepad API.
  58439. */
  58440. readonly displayId: number;
  58441. /**
  58442. * A display name, a user-readable name identifying it.
  58443. */
  58444. readonly displayName: string;
  58445. readonly isConnected: boolean;
  58446. readonly isPresenting: boolean;
  58447. /**
  58448. * If this VRDisplay supports room-scale experiences, the optional
  58449. * stage attribute contains details on the room-scale parameters.
  58450. */
  58451. readonly stageParameters: VRStageParameters | null;
  58452. /**
  58453. * Passing the value returned by `requestAnimationFrame` to
  58454. * `cancelAnimationFrame` will unregister the callback.
  58455. * @param handle Define the hanle of the request to cancel
  58456. */
  58457. cancelAnimationFrame(handle: number): void;
  58458. /**
  58459. * Stops presenting to the VRDisplay.
  58460. * @returns a promise to know when it stopped
  58461. */
  58462. exitPresent(): Promise<void>;
  58463. /**
  58464. * Return the current VREyeParameters for the given eye.
  58465. * @param whichEye Define the eye we want the parameter for
  58466. * @returns the eye parameters
  58467. */
  58468. getEyeParameters(whichEye: string): VREyeParameters;
  58469. /**
  58470. * Populates the passed VRFrameData with the information required to render
  58471. * the current frame.
  58472. * @param frameData Define the data structure to populate
  58473. * @returns true if ok otherwise false
  58474. */
  58475. getFrameData(frameData: VRFrameData): boolean;
  58476. /**
  58477. * Get the layers currently being presented.
  58478. * @returns the list of VR layers
  58479. */
  58480. getLayers(): VRLayer[];
  58481. /**
  58482. * Return a VRPose containing the future predicted pose of the VRDisplay
  58483. * when the current frame will be presented. The value returned will not
  58484. * change until JavaScript has returned control to the browser.
  58485. *
  58486. * The VRPose will contain the position, orientation, velocity,
  58487. * and acceleration of each of these properties.
  58488. * @returns the pose object
  58489. */
  58490. getPose(): VRPose;
  58491. /**
  58492. * Return the current instantaneous pose of the VRDisplay, with no
  58493. * prediction applied.
  58494. * @returns the current instantaneous pose
  58495. */
  58496. getImmediatePose(): VRPose;
  58497. /**
  58498. * The callback passed to `requestAnimationFrame` will be called
  58499. * any time a new frame should be rendered. When the VRDisplay is
  58500. * presenting the callback will be called at the native refresh
  58501. * rate of the HMD. When not presenting this function acts
  58502. * identically to how window.requestAnimationFrame acts. Content should
  58503. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58504. * asynchronously from other displays and at differing refresh rates.
  58505. * @param callback Define the eaction to run next frame
  58506. * @returns the request handle it
  58507. */
  58508. requestAnimationFrame(callback: FrameRequestCallback): number;
  58509. /**
  58510. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58511. * Repeat calls while already presenting will update the VRLayers being displayed.
  58512. * @param layers Define the list of layer to present
  58513. * @returns a promise to know when the request has been fulfilled
  58514. */
  58515. requestPresent(layers: VRLayer[]): Promise<void>;
  58516. /**
  58517. * Reset the pose for this display, treating its current position and
  58518. * orientation as the "origin/zero" values. VRPose.position,
  58519. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58520. * updated when calling resetPose(). This should be called in only
  58521. * sitting-space experiences.
  58522. */
  58523. resetPose(): void;
  58524. /**
  58525. * The VRLayer provided to the VRDisplay will be captured and presented
  58526. * in the HMD. Calling this function has the same effect on the source
  58527. * canvas as any other operation that uses its source image, and canvases
  58528. * created without preserveDrawingBuffer set to true will be cleared.
  58529. * @param pose Define the pose to submit
  58530. */
  58531. submitFrame(pose?: VRPose): void;
  58532. }
  58533. declare var VRDisplay: {
  58534. prototype: VRDisplay;
  58535. new(): VRDisplay;
  58536. };
  58537. interface VRLayer {
  58538. leftBounds?: number[] | Float32Array | null;
  58539. rightBounds?: number[] | Float32Array | null;
  58540. source?: HTMLCanvasElement | null;
  58541. }
  58542. interface VRDisplayCapabilities {
  58543. readonly canPresent: boolean;
  58544. readonly hasExternalDisplay: boolean;
  58545. readonly hasOrientation: boolean;
  58546. readonly hasPosition: boolean;
  58547. readonly maxLayers: number;
  58548. }
  58549. interface VREyeParameters {
  58550. /** @deprecated */
  58551. readonly fieldOfView: VRFieldOfView;
  58552. readonly offset: Float32Array;
  58553. readonly renderHeight: number;
  58554. readonly renderWidth: number;
  58555. }
  58556. interface VRFieldOfView {
  58557. readonly downDegrees: number;
  58558. readonly leftDegrees: number;
  58559. readonly rightDegrees: number;
  58560. readonly upDegrees: number;
  58561. }
  58562. interface VRFrameData {
  58563. readonly leftProjectionMatrix: Float32Array;
  58564. readonly leftViewMatrix: Float32Array;
  58565. readonly pose: VRPose;
  58566. readonly rightProjectionMatrix: Float32Array;
  58567. readonly rightViewMatrix: Float32Array;
  58568. readonly timestamp: number;
  58569. }
  58570. interface VRPose {
  58571. readonly angularAcceleration: Float32Array | null;
  58572. readonly angularVelocity: Float32Array | null;
  58573. readonly linearAcceleration: Float32Array | null;
  58574. readonly linearVelocity: Float32Array | null;
  58575. readonly orientation: Float32Array | null;
  58576. readonly position: Float32Array | null;
  58577. readonly timestamp: number;
  58578. }
  58579. interface VRStageParameters {
  58580. sittingToStandingTransform?: Float32Array;
  58581. sizeX?: number;
  58582. sizeY?: number;
  58583. }
  58584. interface Navigator {
  58585. getVRDisplays(): Promise<VRDisplay[]>;
  58586. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58587. }
  58588. interface Window {
  58589. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58590. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58591. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58592. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58593. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58594. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58595. }
  58596. interface Gamepad {
  58597. readonly displayId: number;
  58598. }
  58599. interface XRDevice {
  58600. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58601. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58602. }
  58603. interface XRSession {
  58604. getInputSources(): Array<any>;
  58605. baseLayer: XRWebGLLayer;
  58606. requestFrameOfReference(type: string): Promise<void>;
  58607. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58608. end(): Promise<void>;
  58609. requestAnimationFrame: Function;
  58610. addEventListener: Function;
  58611. }
  58612. interface XRSessionCreationOptions {
  58613. outputContext?: WebGLRenderingContext | null;
  58614. immersive?: boolean;
  58615. environmentIntegration?: boolean;
  58616. }
  58617. interface XRLayer {
  58618. getViewport: Function;
  58619. framebufferWidth: number;
  58620. framebufferHeight: number;
  58621. }
  58622. interface XRView {
  58623. projectionMatrix: Float32Array;
  58624. }
  58625. interface XRFrame {
  58626. getDevicePose: Function;
  58627. getInputPose: Function;
  58628. views: Array<XRView>;
  58629. baseLayer: XRLayer;
  58630. }
  58631. interface XRFrameOfReference {
  58632. }
  58633. interface XRWebGLLayer extends XRLayer {
  58634. framebuffer: WebGLFramebuffer;
  58635. }
  58636. declare var XRWebGLLayer: {
  58637. prototype: XRWebGLLayer;
  58638. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58639. };
  58640. declare module "babylonjs" {
  58641. export * from "babylonjs/Legacy/legacy";
  58642. }
  58643. declare module BABYLON {
  58644. /** Alias type for value that can be null */
  58645. export type Nullable<T> = T | null;
  58646. /**
  58647. * Alias type for number that are floats
  58648. * @ignorenaming
  58649. */
  58650. export type float = number;
  58651. /**
  58652. * Alias type for number that are doubles.
  58653. * @ignorenaming
  58654. */
  58655. export type double = number;
  58656. /**
  58657. * Alias type for number that are integer
  58658. * @ignorenaming
  58659. */
  58660. export type int = number;
  58661. /** Alias type for number array or Float32Array */
  58662. export type FloatArray = number[] | Float32Array;
  58663. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  58664. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  58665. /**
  58666. * Alias for types that can be used by a Buffer or VertexBuffer.
  58667. */
  58668. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  58669. /**
  58670. * Alias type for primitive types
  58671. * @ignorenaming
  58672. */
  58673. type Primitive = undefined | null | boolean | string | number | Function;
  58674. /**
  58675. * Type modifier to make all the properties of an object Readonly
  58676. */
  58677. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  58678. /**
  58679. * Type modifier to make all the properties of an object Readonly recursively
  58680. */
  58681. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  58682. /** @hidden */
  58683. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  58684. }
  58685. /** @hidden */
  58686. /** @hidden */
  58687. type DeepImmutableObject<T> = {
  58688. readonly [K in keyof T]: DeepImmutable<T[K]>;
  58689. };
  58690. }
  58691. declare module BABYLON {
  58692. /**
  58693. * Class containing a set of static utilities functions for arrays.
  58694. */
  58695. export class ArrayTools {
  58696. /**
  58697. * Returns an array of the given size filled with element built from the given constructor and the paramters
  58698. * @param size the number of element to construct and put in the array
  58699. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58700. * @returns a new array filled with new objects
  58701. */
  58702. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  58703. }
  58704. }
  58705. declare module BABYLON {
  58706. /**
  58707. * Scalar computation library
  58708. */
  58709. export class Scalar {
  58710. /**
  58711. * Two pi constants convenient for computation.
  58712. */
  58713. static TwoPi: number;
  58714. /**
  58715. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58716. * @param a number
  58717. * @param b number
  58718. * @param epsilon (default = 1.401298E-45)
  58719. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58720. */
  58721. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  58722. /**
  58723. * Returns a string : the upper case translation of the number i to hexadecimal.
  58724. * @param i number
  58725. * @returns the upper case translation of the number i to hexadecimal.
  58726. */
  58727. static ToHex(i: number): string;
  58728. /**
  58729. * Returns -1 if value is negative and +1 is value is positive.
  58730. * @param value the value
  58731. * @returns the value itself if it's equal to zero.
  58732. */
  58733. static Sign(value: number): number;
  58734. /**
  58735. * Returns the value itself if it's between min and max.
  58736. * Returns min if the value is lower than min.
  58737. * Returns max if the value is greater than max.
  58738. * @param value the value to clmap
  58739. * @param min the min value to clamp to (default: 0)
  58740. * @param max the max value to clamp to (default: 1)
  58741. * @returns the clamped value
  58742. */
  58743. static Clamp(value: number, min?: number, max?: number): number;
  58744. /**
  58745. * the log2 of value.
  58746. * @param value the value to compute log2 of
  58747. * @returns the log2 of value.
  58748. */
  58749. static Log2(value: number): number;
  58750. /**
  58751. * Loops the value, so that it is never larger than length and never smaller than 0.
  58752. *
  58753. * This is similar to the modulo operator but it works with floating point numbers.
  58754. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  58755. * With t = 5 and length = 2.5, the result would be 0.0.
  58756. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  58757. * @param value the value
  58758. * @param length the length
  58759. * @returns the looped value
  58760. */
  58761. static Repeat(value: number, length: number): number;
  58762. /**
  58763. * Normalize the value between 0.0 and 1.0 using min and max values
  58764. * @param value value to normalize
  58765. * @param min max to normalize between
  58766. * @param max min to normalize between
  58767. * @returns the normalized value
  58768. */
  58769. static Normalize(value: number, min: number, max: number): number;
  58770. /**
  58771. * Denormalize the value from 0.0 and 1.0 using min and max values
  58772. * @param normalized value to denormalize
  58773. * @param min max to denormalize between
  58774. * @param max min to denormalize between
  58775. * @returns the denormalized value
  58776. */
  58777. static Denormalize(normalized: number, min: number, max: number): number;
  58778. /**
  58779. * Calculates the shortest difference between two given angles given in degrees.
  58780. * @param current current angle in degrees
  58781. * @param target target angle in degrees
  58782. * @returns the delta
  58783. */
  58784. static DeltaAngle(current: number, target: number): number;
  58785. /**
  58786. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  58787. * @param tx value
  58788. * @param length length
  58789. * @returns The returned value will move back and forth between 0 and length
  58790. */
  58791. static PingPong(tx: number, length: number): number;
  58792. /**
  58793. * Interpolates between min and max with smoothing at the limits.
  58794. *
  58795. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  58796. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  58797. * @param from from
  58798. * @param to to
  58799. * @param tx value
  58800. * @returns the smooth stepped value
  58801. */
  58802. static SmoothStep(from: number, to: number, tx: number): number;
  58803. /**
  58804. * Moves a value current towards target.
  58805. *
  58806. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  58807. * Negative values of maxDelta pushes the value away from target.
  58808. * @param current current value
  58809. * @param target target value
  58810. * @param maxDelta max distance to move
  58811. * @returns resulting value
  58812. */
  58813. static MoveTowards(current: number, target: number, maxDelta: number): number;
  58814. /**
  58815. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58816. *
  58817. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  58818. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  58819. * @param current current value
  58820. * @param target target value
  58821. * @param maxDelta max distance to move
  58822. * @returns resulting angle
  58823. */
  58824. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  58825. /**
  58826. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  58827. * @param start start value
  58828. * @param end target value
  58829. * @param amount amount to lerp between
  58830. * @returns the lerped value
  58831. */
  58832. static Lerp(start: number, end: number, amount: number): number;
  58833. /**
  58834. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58835. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  58836. * @param start start value
  58837. * @param end target value
  58838. * @param amount amount to lerp between
  58839. * @returns the lerped value
  58840. */
  58841. static LerpAngle(start: number, end: number, amount: number): number;
  58842. /**
  58843. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  58844. * @param a start value
  58845. * @param b target value
  58846. * @param value value between a and b
  58847. * @returns the inverseLerp value
  58848. */
  58849. static InverseLerp(a: number, b: number, value: number): number;
  58850. /**
  58851. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  58852. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  58853. * @param value1 spline value
  58854. * @param tangent1 spline value
  58855. * @param value2 spline value
  58856. * @param tangent2 spline value
  58857. * @param amount input value
  58858. * @returns hermite result
  58859. */
  58860. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  58861. /**
  58862. * Returns a random float number between and min and max values
  58863. * @param min min value of random
  58864. * @param max max value of random
  58865. * @returns random value
  58866. */
  58867. static RandomRange(min: number, max: number): number;
  58868. /**
  58869. * This function returns percentage of a number in a given range.
  58870. *
  58871. * RangeToPercent(40,20,60) will return 0.5 (50%)
  58872. * RangeToPercent(34,0,100) will return 0.34 (34%)
  58873. * @param number to convert to percentage
  58874. * @param min min range
  58875. * @param max max range
  58876. * @returns the percentage
  58877. */
  58878. static RangeToPercent(number: number, min: number, max: number): number;
  58879. /**
  58880. * This function returns number that corresponds to the percentage in a given range.
  58881. *
  58882. * PercentToRange(0.34,0,100) will return 34.
  58883. * @param percent to convert to number
  58884. * @param min min range
  58885. * @param max max range
  58886. * @returns the number
  58887. */
  58888. static PercentToRange(percent: number, min: number, max: number): number;
  58889. /**
  58890. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58891. * @param angle The angle to normalize in radian.
  58892. * @return The converted angle.
  58893. */
  58894. static NormalizeRadians(angle: number): number;
  58895. }
  58896. }
  58897. declare module BABYLON {
  58898. /**
  58899. * Constant used to convert a value to gamma space
  58900. * @ignorenaming
  58901. */
  58902. export const ToGammaSpace: number;
  58903. /**
  58904. * Constant used to convert a value to linear space
  58905. * @ignorenaming
  58906. */
  58907. export const ToLinearSpace = 2.2;
  58908. /**
  58909. * Constant used to define the minimal number value in Babylon.js
  58910. * @ignorenaming
  58911. */
  58912. export const Epsilon = 0.001;
  58913. /**
  58914. * Class used to hold a RBG color
  58915. */
  58916. export class Color3 {
  58917. /**
  58918. * Defines the red component (between 0 and 1, default is 0)
  58919. */
  58920. r: number;
  58921. /**
  58922. * Defines the green component (between 0 and 1, default is 0)
  58923. */
  58924. g: number;
  58925. /**
  58926. * Defines the blue component (between 0 and 1, default is 0)
  58927. */
  58928. b: number;
  58929. /**
  58930. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58931. * @param r defines the red component (between 0 and 1, default is 0)
  58932. * @param g defines the green component (between 0 and 1, default is 0)
  58933. * @param b defines the blue component (between 0 and 1, default is 0)
  58934. */
  58935. constructor(
  58936. /**
  58937. * Defines the red component (between 0 and 1, default is 0)
  58938. */
  58939. r?: number,
  58940. /**
  58941. * Defines the green component (between 0 and 1, default is 0)
  58942. */
  58943. g?: number,
  58944. /**
  58945. * Defines the blue component (between 0 and 1, default is 0)
  58946. */
  58947. b?: number);
  58948. /**
  58949. * Creates a string with the Color3 current values
  58950. * @returns the string representation of the Color3 object
  58951. */
  58952. toString(): string;
  58953. /**
  58954. * Returns the string "Color3"
  58955. * @returns "Color3"
  58956. */
  58957. getClassName(): string;
  58958. /**
  58959. * Compute the Color3 hash code
  58960. * @returns an unique number that can be used to hash Color3 objects
  58961. */
  58962. getHashCode(): number;
  58963. /**
  58964. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58965. * @param array defines the array where to store the r,g,b components
  58966. * @param index defines an optional index in the target array to define where to start storing values
  58967. * @returns the current Color3 object
  58968. */
  58969. toArray(array: FloatArray, index?: number): Color3;
  58970. /**
  58971. * Returns a new Color4 object from the current Color3 and the given alpha
  58972. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58973. * @returns a new Color4 object
  58974. */
  58975. toColor4(alpha?: number): Color4;
  58976. /**
  58977. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58978. * @returns the new array
  58979. */
  58980. asArray(): number[];
  58981. /**
  58982. * Returns the luminance value
  58983. * @returns a float value
  58984. */
  58985. toLuminance(): number;
  58986. /**
  58987. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58988. * @param otherColor defines the second operand
  58989. * @returns the new Color3 object
  58990. */
  58991. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58992. /**
  58993. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58994. * @param otherColor defines the second operand
  58995. * @param result defines the Color3 object where to store the result
  58996. * @returns the current Color3
  58997. */
  58998. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58999. /**
  59000. * Determines equality between Color3 objects
  59001. * @param otherColor defines the second operand
  59002. * @returns true if the rgb values are equal to the given ones
  59003. */
  59004. equals(otherColor: DeepImmutable<Color3>): boolean;
  59005. /**
  59006. * Determines equality between the current Color3 object and a set of r,b,g values
  59007. * @param r defines the red component to check
  59008. * @param g defines the green component to check
  59009. * @param b defines the blue component to check
  59010. * @returns true if the rgb values are equal to the given ones
  59011. */
  59012. equalsFloats(r: number, g: number, b: number): boolean;
  59013. /**
  59014. * Multiplies in place each rgb value by scale
  59015. * @param scale defines the scaling factor
  59016. * @returns the updated Color3
  59017. */
  59018. scale(scale: number): Color3;
  59019. /**
  59020. * Multiplies the rgb values by scale and stores the result into "result"
  59021. * @param scale defines the scaling factor
  59022. * @param result defines the Color3 object where to store the result
  59023. * @returns the unmodified current Color3
  59024. */
  59025. scaleToRef(scale: number, result: Color3): Color3;
  59026. /**
  59027. * Scale the current Color3 values by a factor and add the result to a given Color3
  59028. * @param scale defines the scale factor
  59029. * @param result defines color to store the result into
  59030. * @returns the unmodified current Color3
  59031. */
  59032. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59033. /**
  59034. * Clamps the rgb values by the min and max values and stores the result into "result"
  59035. * @param min defines minimum clamping value (default is 0)
  59036. * @param max defines maximum clamping value (default is 1)
  59037. * @param result defines color to store the result into
  59038. * @returns the original Color3
  59039. */
  59040. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59041. /**
  59042. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59043. * @param otherColor defines the second operand
  59044. * @returns the new Color3
  59045. */
  59046. add(otherColor: DeepImmutable<Color3>): Color3;
  59047. /**
  59048. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59049. * @param otherColor defines the second operand
  59050. * @param result defines Color3 object to store the result into
  59051. * @returns the unmodified current Color3
  59052. */
  59053. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59054. /**
  59055. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59056. * @param otherColor defines the second operand
  59057. * @returns the new Color3
  59058. */
  59059. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59060. /**
  59061. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59062. * @param otherColor defines the second operand
  59063. * @param result defines Color3 object to store the result into
  59064. * @returns the unmodified current Color3
  59065. */
  59066. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59067. /**
  59068. * Copy the current object
  59069. * @returns a new Color3 copied the current one
  59070. */
  59071. clone(): Color3;
  59072. /**
  59073. * Copies the rgb values from the source in the current Color3
  59074. * @param source defines the source Color3 object
  59075. * @returns the updated Color3 object
  59076. */
  59077. copyFrom(source: DeepImmutable<Color3>): Color3;
  59078. /**
  59079. * Updates the Color3 rgb values from the given floats
  59080. * @param r defines the red component to read from
  59081. * @param g defines the green component to read from
  59082. * @param b defines the blue component to read from
  59083. * @returns the current Color3 object
  59084. */
  59085. copyFromFloats(r: number, g: number, b: number): Color3;
  59086. /**
  59087. * Updates the Color3 rgb values from the given floats
  59088. * @param r defines the red component to read from
  59089. * @param g defines the green component to read from
  59090. * @param b defines the blue component to read from
  59091. * @returns the current Color3 object
  59092. */
  59093. set(r: number, g: number, b: number): Color3;
  59094. /**
  59095. * Compute the Color3 hexadecimal code as a string
  59096. * @returns a string containing the hexadecimal representation of the Color3 object
  59097. */
  59098. toHexString(): string;
  59099. /**
  59100. * Computes a new Color3 converted from the current one to linear space
  59101. * @returns a new Color3 object
  59102. */
  59103. toLinearSpace(): Color3;
  59104. /**
  59105. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59106. * @param convertedColor defines the Color3 object where to store the linear space version
  59107. * @returns the unmodified Color3
  59108. */
  59109. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59110. /**
  59111. * Computes a new Color3 converted from the current one to gamma space
  59112. * @returns a new Color3 object
  59113. */
  59114. toGammaSpace(): Color3;
  59115. /**
  59116. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59117. * @param convertedColor defines the Color3 object where to store the gamma space version
  59118. * @returns the unmodified Color3
  59119. */
  59120. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59121. private static _BlackReadOnly;
  59122. /**
  59123. * Creates a new Color3 from the string containing valid hexadecimal values
  59124. * @param hex defines a string containing valid hexadecimal values
  59125. * @returns a new Color3 object
  59126. */
  59127. static FromHexString(hex: string): Color3;
  59128. /**
  59129. * Creates a new Vector3 from the starting index of the given array
  59130. * @param array defines the source array
  59131. * @param offset defines an offset in the source array
  59132. * @returns a new Color3 object
  59133. */
  59134. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59135. /**
  59136. * Creates a new Color3 from integer values (< 256)
  59137. * @param r defines the red component to read from (value between 0 and 255)
  59138. * @param g defines the green component to read from (value between 0 and 255)
  59139. * @param b defines the blue component to read from (value between 0 and 255)
  59140. * @returns a new Color3 object
  59141. */
  59142. static FromInts(r: number, g: number, b: number): Color3;
  59143. /**
  59144. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59145. * @param start defines the start Color3 value
  59146. * @param end defines the end Color3 value
  59147. * @param amount defines the gradient value between start and end
  59148. * @returns a new Color3 object
  59149. */
  59150. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59151. /**
  59152. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59153. * @param left defines the start value
  59154. * @param right defines the end value
  59155. * @param amount defines the gradient factor
  59156. * @param result defines the Color3 object where to store the result
  59157. */
  59158. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59159. /**
  59160. * Returns a Color3 value containing a red color
  59161. * @returns a new Color3 object
  59162. */
  59163. static Red(): Color3;
  59164. /**
  59165. * Returns a Color3 value containing a green color
  59166. * @returns a new Color3 object
  59167. */
  59168. static Green(): Color3;
  59169. /**
  59170. * Returns a Color3 value containing a blue color
  59171. * @returns a new Color3 object
  59172. */
  59173. static Blue(): Color3;
  59174. /**
  59175. * Returns a Color3 value containing a black color
  59176. * @returns a new Color3 object
  59177. */
  59178. static Black(): Color3;
  59179. /**
  59180. * Gets a Color3 value containing a black color that must not be updated
  59181. */
  59182. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59183. /**
  59184. * Returns a Color3 value containing a white color
  59185. * @returns a new Color3 object
  59186. */
  59187. static White(): Color3;
  59188. /**
  59189. * Returns a Color3 value containing a purple color
  59190. * @returns a new Color3 object
  59191. */
  59192. static Purple(): Color3;
  59193. /**
  59194. * Returns a Color3 value containing a magenta color
  59195. * @returns a new Color3 object
  59196. */
  59197. static Magenta(): Color3;
  59198. /**
  59199. * Returns a Color3 value containing a yellow color
  59200. * @returns a new Color3 object
  59201. */
  59202. static Yellow(): Color3;
  59203. /**
  59204. * Returns a Color3 value containing a gray color
  59205. * @returns a new Color3 object
  59206. */
  59207. static Gray(): Color3;
  59208. /**
  59209. * Returns a Color3 value containing a teal color
  59210. * @returns a new Color3 object
  59211. */
  59212. static Teal(): Color3;
  59213. /**
  59214. * Returns a Color3 value containing a random color
  59215. * @returns a new Color3 object
  59216. */
  59217. static Random(): Color3;
  59218. }
  59219. /**
  59220. * Class used to hold a RBGA color
  59221. */
  59222. export class Color4 {
  59223. /**
  59224. * Defines the red component (between 0 and 1, default is 0)
  59225. */
  59226. r: number;
  59227. /**
  59228. * Defines the green component (between 0 and 1, default is 0)
  59229. */
  59230. g: number;
  59231. /**
  59232. * Defines the blue component (between 0 and 1, default is 0)
  59233. */
  59234. b: number;
  59235. /**
  59236. * Defines the alpha component (between 0 and 1, default is 1)
  59237. */
  59238. a: number;
  59239. /**
  59240. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59241. * @param r defines the red component (between 0 and 1, default is 0)
  59242. * @param g defines the green component (between 0 and 1, default is 0)
  59243. * @param b defines the blue component (between 0 and 1, default is 0)
  59244. * @param a defines the alpha component (between 0 and 1, default is 1)
  59245. */
  59246. constructor(
  59247. /**
  59248. * Defines the red component (between 0 and 1, default is 0)
  59249. */
  59250. r?: number,
  59251. /**
  59252. * Defines the green component (between 0 and 1, default is 0)
  59253. */
  59254. g?: number,
  59255. /**
  59256. * Defines the blue component (between 0 and 1, default is 0)
  59257. */
  59258. b?: number,
  59259. /**
  59260. * Defines the alpha component (between 0 and 1, default is 1)
  59261. */
  59262. a?: number);
  59263. /**
  59264. * Adds in place the given Color4 values to the current Color4 object
  59265. * @param right defines the second operand
  59266. * @returns the current updated Color4 object
  59267. */
  59268. addInPlace(right: DeepImmutable<Color4>): Color4;
  59269. /**
  59270. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59271. * @returns the new array
  59272. */
  59273. asArray(): number[];
  59274. /**
  59275. * Stores from the starting index in the given array the Color4 successive values
  59276. * @param array defines the array where to store the r,g,b components
  59277. * @param index defines an optional index in the target array to define where to start storing values
  59278. * @returns the current Color4 object
  59279. */
  59280. toArray(array: number[], index?: number): Color4;
  59281. /**
  59282. * Determines equality between Color4 objects
  59283. * @param otherColor defines the second operand
  59284. * @returns true if the rgba values are equal to the given ones
  59285. */
  59286. equals(otherColor: DeepImmutable<Color4>): boolean;
  59287. /**
  59288. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  59289. * @param right defines the second operand
  59290. * @returns a new Color4 object
  59291. */
  59292. add(right: DeepImmutable<Color4>): Color4;
  59293. /**
  59294. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  59295. * @param right defines the second operand
  59296. * @returns a new Color4 object
  59297. */
  59298. subtract(right: DeepImmutable<Color4>): Color4;
  59299. /**
  59300. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  59301. * @param right defines the second operand
  59302. * @param result defines the Color4 object where to store the result
  59303. * @returns the current Color4 object
  59304. */
  59305. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  59306. /**
  59307. * Creates a new Color4 with the current Color4 values multiplied by scale
  59308. * @param scale defines the scaling factor to apply
  59309. * @returns a new Color4 object
  59310. */
  59311. scale(scale: number): Color4;
  59312. /**
  59313. * Multiplies the current Color4 values by scale and stores the result in "result"
  59314. * @param scale defines the scaling factor to apply
  59315. * @param result defines the Color4 object where to store the result
  59316. * @returns the current unmodified Color4
  59317. */
  59318. scaleToRef(scale: number, result: Color4): Color4;
  59319. /**
  59320. * Scale the current Color4 values by a factor and add the result to a given Color4
  59321. * @param scale defines the scale factor
  59322. * @param result defines the Color4 object where to store the result
  59323. * @returns the unmodified current Color4
  59324. */
  59325. scaleAndAddToRef(scale: number, result: Color4): Color4;
  59326. /**
  59327. * Clamps the rgb values by the min and max values and stores the result into "result"
  59328. * @param min defines minimum clamping value (default is 0)
  59329. * @param max defines maximum clamping value (default is 1)
  59330. * @param result defines color to store the result into.
  59331. * @returns the cuurent Color4
  59332. */
  59333. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  59334. /**
  59335. * Multipy an Color4 value by another and return a new Color4 object
  59336. * @param color defines the Color4 value to multiply by
  59337. * @returns a new Color4 object
  59338. */
  59339. multiply(color: Color4): Color4;
  59340. /**
  59341. * Multipy a Color4 value by another and push the result in a reference value
  59342. * @param color defines the Color4 value to multiply by
  59343. * @param result defines the Color4 to fill the result in
  59344. * @returns the result Color4
  59345. */
  59346. multiplyToRef(color: Color4, result: Color4): Color4;
  59347. /**
  59348. * Creates a string with the Color4 current values
  59349. * @returns the string representation of the Color4 object
  59350. */
  59351. toString(): string;
  59352. /**
  59353. * Returns the string "Color4"
  59354. * @returns "Color4"
  59355. */
  59356. getClassName(): string;
  59357. /**
  59358. * Compute the Color4 hash code
  59359. * @returns an unique number that can be used to hash Color4 objects
  59360. */
  59361. getHashCode(): number;
  59362. /**
  59363. * Creates a new Color4 copied from the current one
  59364. * @returns a new Color4 object
  59365. */
  59366. clone(): Color4;
  59367. /**
  59368. * Copies the given Color4 values into the current one
  59369. * @param source defines the source Color4 object
  59370. * @returns the current updated Color4 object
  59371. */
  59372. copyFrom(source: Color4): Color4;
  59373. /**
  59374. * Copies the given float values into the current one
  59375. * @param r defines the red component to read from
  59376. * @param g defines the green component to read from
  59377. * @param b defines the blue component to read from
  59378. * @param a defines the alpha component to read from
  59379. * @returns the current updated Color4 object
  59380. */
  59381. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  59382. /**
  59383. * Copies the given float values into the current one
  59384. * @param r defines the red component to read from
  59385. * @param g defines the green component to read from
  59386. * @param b defines the blue component to read from
  59387. * @param a defines the alpha component to read from
  59388. * @returns the current updated Color4 object
  59389. */
  59390. set(r: number, g: number, b: number, a: number): Color4;
  59391. /**
  59392. * Compute the Color4 hexadecimal code as a string
  59393. * @returns a string containing the hexadecimal representation of the Color4 object
  59394. */
  59395. toHexString(): string;
  59396. /**
  59397. * Computes a new Color4 converted from the current one to linear space
  59398. * @returns a new Color4 object
  59399. */
  59400. toLinearSpace(): Color4;
  59401. /**
  59402. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  59403. * @param convertedColor defines the Color4 object where to store the linear space version
  59404. * @returns the unmodified Color4
  59405. */
  59406. toLinearSpaceToRef(convertedColor: Color4): Color4;
  59407. /**
  59408. * Computes a new Color4 converted from the current one to gamma space
  59409. * @returns a new Color4 object
  59410. */
  59411. toGammaSpace(): Color4;
  59412. /**
  59413. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  59414. * @param convertedColor defines the Color4 object where to store the gamma space version
  59415. * @returns the unmodified Color4
  59416. */
  59417. toGammaSpaceToRef(convertedColor: Color4): Color4;
  59418. /**
  59419. * Creates a new Color4 from the string containing valid hexadecimal values
  59420. * @param hex defines a string containing valid hexadecimal values
  59421. * @returns a new Color4 object
  59422. */
  59423. static FromHexString(hex: string): Color4;
  59424. /**
  59425. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59426. * @param left defines the start value
  59427. * @param right defines the end value
  59428. * @param amount defines the gradient factor
  59429. * @returns a new Color4 object
  59430. */
  59431. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  59432. /**
  59433. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59434. * @param left defines the start value
  59435. * @param right defines the end value
  59436. * @param amount defines the gradient factor
  59437. * @param result defines the Color4 object where to store data
  59438. */
  59439. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  59440. /**
  59441. * Creates a new Color4 from a Color3 and an alpha value
  59442. * @param color3 defines the source Color3 to read from
  59443. * @param alpha defines the alpha component (1.0 by default)
  59444. * @returns a new Color4 object
  59445. */
  59446. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  59447. /**
  59448. * Creates a new Color4 from the starting index element of the given array
  59449. * @param array defines the source array to read from
  59450. * @param offset defines the offset in the source array
  59451. * @returns a new Color4 object
  59452. */
  59453. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  59454. /**
  59455. * Creates a new Color3 from integer values (< 256)
  59456. * @param r defines the red component to read from (value between 0 and 255)
  59457. * @param g defines the green component to read from (value between 0 and 255)
  59458. * @param b defines the blue component to read from (value between 0 and 255)
  59459. * @param a defines the alpha component to read from (value between 0 and 255)
  59460. * @returns a new Color3 object
  59461. */
  59462. static FromInts(r: number, g: number, b: number, a: number): Color4;
  59463. /**
  59464. * Check the content of a given array and convert it to an array containing RGBA data
  59465. * If the original array was already containing count * 4 values then it is returned directly
  59466. * @param colors defines the array to check
  59467. * @param count defines the number of RGBA data to expect
  59468. * @returns an array containing count * 4 values (RGBA)
  59469. */
  59470. static CheckColors4(colors: number[], count: number): number[];
  59471. }
  59472. /**
  59473. * Class representing a vector containing 2 coordinates
  59474. */
  59475. export class Vector2 {
  59476. /** defines the first coordinate */
  59477. x: number;
  59478. /** defines the second coordinate */
  59479. y: number;
  59480. /**
  59481. * Creates a new Vector2 from the given x and y coordinates
  59482. * @param x defines the first coordinate
  59483. * @param y defines the second coordinate
  59484. */
  59485. constructor(
  59486. /** defines the first coordinate */
  59487. x?: number,
  59488. /** defines the second coordinate */
  59489. y?: number);
  59490. /**
  59491. * Gets a string with the Vector2 coordinates
  59492. * @returns a string with the Vector2 coordinates
  59493. */
  59494. toString(): string;
  59495. /**
  59496. * Gets class name
  59497. * @returns the string "Vector2"
  59498. */
  59499. getClassName(): string;
  59500. /**
  59501. * Gets current vector hash code
  59502. * @returns the Vector2 hash code as a number
  59503. */
  59504. getHashCode(): number;
  59505. /**
  59506. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  59507. * @param array defines the source array
  59508. * @param index defines the offset in source array
  59509. * @returns the current Vector2
  59510. */
  59511. toArray(array: FloatArray, index?: number): Vector2;
  59512. /**
  59513. * Copy the current vector to an array
  59514. * @returns a new array with 2 elements: the Vector2 coordinates.
  59515. */
  59516. asArray(): number[];
  59517. /**
  59518. * Sets the Vector2 coordinates with the given Vector2 coordinates
  59519. * @param source defines the source Vector2
  59520. * @returns the current updated Vector2
  59521. */
  59522. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  59523. /**
  59524. * Sets the Vector2 coordinates with the given floats
  59525. * @param x defines the first coordinate
  59526. * @param y defines the second coordinate
  59527. * @returns the current updated Vector2
  59528. */
  59529. copyFromFloats(x: number, y: number): Vector2;
  59530. /**
  59531. * Sets the Vector2 coordinates with the given floats
  59532. * @param x defines the first coordinate
  59533. * @param y defines the second coordinate
  59534. * @returns the current updated Vector2
  59535. */
  59536. set(x: number, y: number): Vector2;
  59537. /**
  59538. * Add another vector with the current one
  59539. * @param otherVector defines the other vector
  59540. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  59541. */
  59542. add(otherVector: DeepImmutable<Vector2>): Vector2;
  59543. /**
  59544. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  59545. * @param otherVector defines the other vector
  59546. * @param result defines the target vector
  59547. * @returns the unmodified current Vector2
  59548. */
  59549. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59550. /**
  59551. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  59552. * @param otherVector defines the other vector
  59553. * @returns the current updated Vector2
  59554. */
  59555. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59556. /**
  59557. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  59558. * @param otherVector defines the other vector
  59559. * @returns a new Vector2
  59560. */
  59561. addVector3(otherVector: Vector3): Vector2;
  59562. /**
  59563. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  59564. * @param otherVector defines the other vector
  59565. * @returns a new Vector2
  59566. */
  59567. subtract(otherVector: Vector2): Vector2;
  59568. /**
  59569. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  59570. * @param otherVector defines the other vector
  59571. * @param result defines the target vector
  59572. * @returns the unmodified current Vector2
  59573. */
  59574. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59575. /**
  59576. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  59577. * @param otherVector defines the other vector
  59578. * @returns the current updated Vector2
  59579. */
  59580. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59581. /**
  59582. * Multiplies in place the current Vector2 coordinates by the given ones
  59583. * @param otherVector defines the other vector
  59584. * @returns the current updated Vector2
  59585. */
  59586. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59587. /**
  59588. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  59589. * @param otherVector defines the other vector
  59590. * @returns a new Vector2
  59591. */
  59592. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  59593. /**
  59594. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  59595. * @param otherVector defines the other vector
  59596. * @param result defines the target vector
  59597. * @returns the unmodified current Vector2
  59598. */
  59599. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59600. /**
  59601. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  59602. * @param x defines the first coordinate
  59603. * @param y defines the second coordinate
  59604. * @returns a new Vector2
  59605. */
  59606. multiplyByFloats(x: number, y: number): Vector2;
  59607. /**
  59608. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  59609. * @param otherVector defines the other vector
  59610. * @returns a new Vector2
  59611. */
  59612. divide(otherVector: Vector2): Vector2;
  59613. /**
  59614. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  59615. * @param otherVector defines the other vector
  59616. * @param result defines the target vector
  59617. * @returns the unmodified current Vector2
  59618. */
  59619. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59620. /**
  59621. * Divides the current Vector2 coordinates by the given ones
  59622. * @param otherVector defines the other vector
  59623. * @returns the current updated Vector2
  59624. */
  59625. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59626. /**
  59627. * Gets a new Vector2 with current Vector2 negated coordinates
  59628. * @returns a new Vector2
  59629. */
  59630. negate(): Vector2;
  59631. /**
  59632. * Multiply the Vector2 coordinates by scale
  59633. * @param scale defines the scaling factor
  59634. * @returns the current updated Vector2
  59635. */
  59636. scaleInPlace(scale: number): Vector2;
  59637. /**
  59638. * Returns a new Vector2 scaled by "scale" from the current Vector2
  59639. * @param scale defines the scaling factor
  59640. * @returns a new Vector2
  59641. */
  59642. scale(scale: number): Vector2;
  59643. /**
  59644. * Scale the current Vector2 values by a factor to a given Vector2
  59645. * @param scale defines the scale factor
  59646. * @param result defines the Vector2 object where to store the result
  59647. * @returns the unmodified current Vector2
  59648. */
  59649. scaleToRef(scale: number, result: Vector2): Vector2;
  59650. /**
  59651. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  59652. * @param scale defines the scale factor
  59653. * @param result defines the Vector2 object where to store the result
  59654. * @returns the unmodified current Vector2
  59655. */
  59656. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  59657. /**
  59658. * Gets a boolean if two vectors are equals
  59659. * @param otherVector defines the other vector
  59660. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  59661. */
  59662. equals(otherVector: DeepImmutable<Vector2>): boolean;
  59663. /**
  59664. * Gets a boolean if two vectors are equals (using an epsilon value)
  59665. * @param otherVector defines the other vector
  59666. * @param epsilon defines the minimal distance to consider equality
  59667. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  59668. */
  59669. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  59670. /**
  59671. * Gets a new Vector2 from current Vector2 floored values
  59672. * @returns a new Vector2
  59673. */
  59674. floor(): Vector2;
  59675. /**
  59676. * Gets a new Vector2 from current Vector2 floored values
  59677. * @returns a new Vector2
  59678. */
  59679. fract(): Vector2;
  59680. /**
  59681. * Gets the length of the vector
  59682. * @returns the vector length (float)
  59683. */
  59684. length(): number;
  59685. /**
  59686. * Gets the vector squared length
  59687. * @returns the vector squared length (float)
  59688. */
  59689. lengthSquared(): number;
  59690. /**
  59691. * Normalize the vector
  59692. * @returns the current updated Vector2
  59693. */
  59694. normalize(): Vector2;
  59695. /**
  59696. * Gets a new Vector2 copied from the Vector2
  59697. * @returns a new Vector2
  59698. */
  59699. clone(): Vector2;
  59700. /**
  59701. * Gets a new Vector2(0, 0)
  59702. * @returns a new Vector2
  59703. */
  59704. static Zero(): Vector2;
  59705. /**
  59706. * Gets a new Vector2(1, 1)
  59707. * @returns a new Vector2
  59708. */
  59709. static One(): Vector2;
  59710. /**
  59711. * Gets a new Vector2 set from the given index element of the given array
  59712. * @param array defines the data source
  59713. * @param offset defines the offset in the data source
  59714. * @returns a new Vector2
  59715. */
  59716. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  59717. /**
  59718. * Sets "result" from the given index element of the given array
  59719. * @param array defines the data source
  59720. * @param offset defines the offset in the data source
  59721. * @param result defines the target vector
  59722. */
  59723. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  59724. /**
  59725. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  59726. * @param value1 defines 1st point of control
  59727. * @param value2 defines 2nd point of control
  59728. * @param value3 defines 3rd point of control
  59729. * @param value4 defines 4th point of control
  59730. * @param amount defines the interpolation factor
  59731. * @returns a new Vector2
  59732. */
  59733. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  59734. /**
  59735. * 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".
  59736. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  59737. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  59738. * @param value defines the value to clamp
  59739. * @param min defines the lower limit
  59740. * @param max defines the upper limit
  59741. * @returns a new Vector2
  59742. */
  59743. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  59744. /**
  59745. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  59746. * @param value1 defines the 1st control point
  59747. * @param tangent1 defines the outgoing tangent
  59748. * @param value2 defines the 2nd control point
  59749. * @param tangent2 defines the incoming tangent
  59750. * @param amount defines the interpolation factor
  59751. * @returns a new Vector2
  59752. */
  59753. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  59754. /**
  59755. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  59756. * @param start defines the start vector
  59757. * @param end defines the end vector
  59758. * @param amount defines the interpolation factor
  59759. * @returns a new Vector2
  59760. */
  59761. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  59762. /**
  59763. * Gets the dot product of the vector "left" and the vector "right"
  59764. * @param left defines first vector
  59765. * @param right defines second vector
  59766. * @returns the dot product (float)
  59767. */
  59768. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  59769. /**
  59770. * Returns a new Vector2 equal to the normalized given vector
  59771. * @param vector defines the vector to normalize
  59772. * @returns a new Vector2
  59773. */
  59774. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  59775. /**
  59776. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  59777. * @param left defines 1st vector
  59778. * @param right defines 2nd vector
  59779. * @returns a new Vector2
  59780. */
  59781. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59782. /**
  59783. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  59784. * @param left defines 1st vector
  59785. * @param right defines 2nd vector
  59786. * @returns a new Vector2
  59787. */
  59788. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59789. /**
  59790. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  59791. * @param vector defines the vector to transform
  59792. * @param transformation defines the matrix to apply
  59793. * @returns a new Vector2
  59794. */
  59795. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  59796. /**
  59797. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  59798. * @param vector defines the vector to transform
  59799. * @param transformation defines the matrix to apply
  59800. * @param result defines the target vector
  59801. */
  59802. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  59803. /**
  59804. * Determines if a given vector is included in a triangle
  59805. * @param p defines the vector to test
  59806. * @param p0 defines 1st triangle point
  59807. * @param p1 defines 2nd triangle point
  59808. * @param p2 defines 3rd triangle point
  59809. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  59810. */
  59811. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  59812. /**
  59813. * Gets the distance between the vectors "value1" and "value2"
  59814. * @param value1 defines first vector
  59815. * @param value2 defines second vector
  59816. * @returns the distance between vectors
  59817. */
  59818. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59819. /**
  59820. * Returns the squared distance between the vectors "value1" and "value2"
  59821. * @param value1 defines first vector
  59822. * @param value2 defines second vector
  59823. * @returns the squared distance between vectors
  59824. */
  59825. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59826. /**
  59827. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  59828. * @param value1 defines first vector
  59829. * @param value2 defines second vector
  59830. * @returns a new Vector2
  59831. */
  59832. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  59833. /**
  59834. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  59835. * @param p defines the middle point
  59836. * @param segA defines one point of the segment
  59837. * @param segB defines the other point of the segment
  59838. * @returns the shortest distance
  59839. */
  59840. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  59841. }
  59842. /**
  59843. * Classed used to store (x,y,z) vector representation
  59844. * A Vector3 is the main object used in 3D geometry
  59845. * It can represent etiher the coordinates of a point the space, either a direction
  59846. * Reminder: js uses a left handed forward facing system
  59847. */
  59848. export class Vector3 {
  59849. /**
  59850. * Defines the first coordinates (on X axis)
  59851. */
  59852. x: number;
  59853. /**
  59854. * Defines the second coordinates (on Y axis)
  59855. */
  59856. y: number;
  59857. /**
  59858. * Defines the third coordinates (on Z axis)
  59859. */
  59860. z: number;
  59861. private static _UpReadOnly;
  59862. /**
  59863. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  59864. * @param x defines the first coordinates (on X axis)
  59865. * @param y defines the second coordinates (on Y axis)
  59866. * @param z defines the third coordinates (on Z axis)
  59867. */
  59868. constructor(
  59869. /**
  59870. * Defines the first coordinates (on X axis)
  59871. */
  59872. x?: number,
  59873. /**
  59874. * Defines the second coordinates (on Y axis)
  59875. */
  59876. y?: number,
  59877. /**
  59878. * Defines the third coordinates (on Z axis)
  59879. */
  59880. z?: number);
  59881. /**
  59882. * Creates a string representation of the Vector3
  59883. * @returns a string with the Vector3 coordinates.
  59884. */
  59885. toString(): string;
  59886. /**
  59887. * Gets the class name
  59888. * @returns the string "Vector3"
  59889. */
  59890. getClassName(): string;
  59891. /**
  59892. * Creates the Vector3 hash code
  59893. * @returns a number which tends to be unique between Vector3 instances
  59894. */
  59895. getHashCode(): number;
  59896. /**
  59897. * Creates an array containing three elements : the coordinates of the Vector3
  59898. * @returns a new array of numbers
  59899. */
  59900. asArray(): number[];
  59901. /**
  59902. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59903. * @param array defines the destination array
  59904. * @param index defines the offset in the destination array
  59905. * @returns the current Vector3
  59906. */
  59907. toArray(array: FloatArray, index?: number): Vector3;
  59908. /**
  59909. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59910. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59911. */
  59912. toQuaternion(): Quaternion;
  59913. /**
  59914. * Adds the given vector to the current Vector3
  59915. * @param otherVector defines the second operand
  59916. * @returns the current updated Vector3
  59917. */
  59918. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59919. /**
  59920. * Adds the given coordinates to the current Vector3
  59921. * @param x defines the x coordinate of the operand
  59922. * @param y defines the y coordinate of the operand
  59923. * @param z defines the z coordinate of the operand
  59924. * @returns the current updated Vector3
  59925. */
  59926. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59927. /**
  59928. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59929. * @param otherVector defines the second operand
  59930. * @returns the resulting Vector3
  59931. */
  59932. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59933. /**
  59934. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59935. * @param otherVector defines the second operand
  59936. * @param result defines the Vector3 object where to store the result
  59937. * @returns the current Vector3
  59938. */
  59939. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59940. /**
  59941. * Subtract the given vector from the current Vector3
  59942. * @param otherVector defines the second operand
  59943. * @returns the current updated Vector3
  59944. */
  59945. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59946. /**
  59947. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59948. * @param otherVector defines the second operand
  59949. * @returns the resulting Vector3
  59950. */
  59951. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59952. /**
  59953. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59954. * @param otherVector defines the second operand
  59955. * @param result defines the Vector3 object where to store the result
  59956. * @returns the current Vector3
  59957. */
  59958. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59959. /**
  59960. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  59961. * @param x defines the x coordinate of the operand
  59962. * @param y defines the y coordinate of the operand
  59963. * @param z defines the z coordinate of the operand
  59964. * @returns the resulting Vector3
  59965. */
  59966. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59967. /**
  59968. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59969. * @param x defines the x coordinate of the operand
  59970. * @param y defines the y coordinate of the operand
  59971. * @param z defines the z coordinate of the operand
  59972. * @param result defines the Vector3 object where to store the result
  59973. * @returns the current Vector3
  59974. */
  59975. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59976. /**
  59977. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59978. * @returns a new Vector3
  59979. */
  59980. negate(): Vector3;
  59981. /**
  59982. * Multiplies the Vector3 coordinates by the float "scale"
  59983. * @param scale defines the multiplier factor
  59984. * @returns the current updated Vector3
  59985. */
  59986. scaleInPlace(scale: number): Vector3;
  59987. /**
  59988. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59989. * @param scale defines the multiplier factor
  59990. * @returns a new Vector3
  59991. */
  59992. scale(scale: number): Vector3;
  59993. /**
  59994. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59995. * @param scale defines the multiplier factor
  59996. * @param result defines the Vector3 object where to store the result
  59997. * @returns the current Vector3
  59998. */
  59999. scaleToRef(scale: number, result: Vector3): Vector3;
  60000. /**
  60001. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60002. * @param scale defines the scale factor
  60003. * @param result defines the Vector3 object where to store the result
  60004. * @returns the unmodified current Vector3
  60005. */
  60006. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60007. /**
  60008. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60009. * @param otherVector defines the second operand
  60010. * @returns true if both vectors are equals
  60011. */
  60012. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60013. /**
  60014. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60015. * @param otherVector defines the second operand
  60016. * @param epsilon defines the minimal distance to define values as equals
  60017. * @returns true if both vectors are distant less than epsilon
  60018. */
  60019. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60020. /**
  60021. * Returns true if the current Vector3 coordinates equals the given floats
  60022. * @param x defines the x coordinate of the operand
  60023. * @param y defines the y coordinate of the operand
  60024. * @param z defines the z coordinate of the operand
  60025. * @returns true if both vectors are equals
  60026. */
  60027. equalsToFloats(x: number, y: number, z: number): boolean;
  60028. /**
  60029. * Multiplies the current Vector3 coordinates by the given ones
  60030. * @param otherVector defines the second operand
  60031. * @returns the current updated Vector3
  60032. */
  60033. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60034. /**
  60035. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60036. * @param otherVector defines the second operand
  60037. * @returns the new Vector3
  60038. */
  60039. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60040. /**
  60041. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60042. * @param otherVector defines the second operand
  60043. * @param result defines the Vector3 object where to store the result
  60044. * @returns the current Vector3
  60045. */
  60046. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60047. /**
  60048. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60049. * @param x defines the x coordinate of the operand
  60050. * @param y defines the y coordinate of the operand
  60051. * @param z defines the z coordinate of the operand
  60052. * @returns the new Vector3
  60053. */
  60054. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60055. /**
  60056. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60057. * @param otherVector defines the second operand
  60058. * @returns the new Vector3
  60059. */
  60060. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60061. /**
  60062. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60063. * @param otherVector defines the second operand
  60064. * @param result defines the Vector3 object where to store the result
  60065. * @returns the current Vector3
  60066. */
  60067. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60068. /**
  60069. * Divides the current Vector3 coordinates by the given ones.
  60070. * @param otherVector defines the second operand
  60071. * @returns the current updated Vector3
  60072. */
  60073. divideInPlace(otherVector: Vector3): Vector3;
  60074. /**
  60075. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60076. * @param other defines the second operand
  60077. * @returns the current updated Vector3
  60078. */
  60079. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60080. /**
  60081. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60082. * @param other defines the second operand
  60083. * @returns the current updated Vector3
  60084. */
  60085. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60086. /**
  60087. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60088. * @param x defines the x coordinate of the operand
  60089. * @param y defines the y coordinate of the operand
  60090. * @param z defines the z coordinate of the operand
  60091. * @returns the current updated Vector3
  60092. */
  60093. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60094. /**
  60095. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60096. * @param x defines the x coordinate of the operand
  60097. * @param y defines the y coordinate of the operand
  60098. * @param z defines the z coordinate of the operand
  60099. * @returns the current updated Vector3
  60100. */
  60101. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60102. /**
  60103. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60104. * Check if is non uniform within a certain amount of decimal places to account for this
  60105. * @param epsilon the amount the values can differ
  60106. * @returns if the the vector is non uniform to a certain number of decimal places
  60107. */
  60108. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60109. /**
  60110. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60111. */
  60112. readonly isNonUniform: boolean;
  60113. /**
  60114. * Gets a new Vector3 from current Vector3 floored values
  60115. * @returns a new Vector3
  60116. */
  60117. floor(): Vector3;
  60118. /**
  60119. * Gets a new Vector3 from current Vector3 floored values
  60120. * @returns a new Vector3
  60121. */
  60122. fract(): Vector3;
  60123. /**
  60124. * Gets the length of the Vector3
  60125. * @returns the length of the Vecto3
  60126. */
  60127. length(): number;
  60128. /**
  60129. * Gets the squared length of the Vector3
  60130. * @returns squared length of the Vector3
  60131. */
  60132. lengthSquared(): number;
  60133. /**
  60134. * Normalize the current Vector3.
  60135. * Please note that this is an in place operation.
  60136. * @returns the current updated Vector3
  60137. */
  60138. normalize(): Vector3;
  60139. /**
  60140. * Reorders the x y z properties of the vector in place
  60141. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60142. * @returns the current updated vector
  60143. */
  60144. reorderInPlace(order: string): this;
  60145. /**
  60146. * Rotates the vector around 0,0,0 by a quaternion
  60147. * @param quaternion the rotation quaternion
  60148. * @param result vector to store the result
  60149. * @returns the resulting vector
  60150. */
  60151. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60152. /**
  60153. * Rotates a vector around a given point
  60154. * @param quaternion the rotation quaternion
  60155. * @param point the point to rotate around
  60156. * @param result vector to store the result
  60157. * @returns the resulting vector
  60158. */
  60159. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60160. /**
  60161. * Normalize the current Vector3 with the given input length.
  60162. * Please note that this is an in place operation.
  60163. * @param len the length of the vector
  60164. * @returns the current updated Vector3
  60165. */
  60166. normalizeFromLength(len: number): Vector3;
  60167. /**
  60168. * Normalize the current Vector3 to a new vector
  60169. * @returns the new Vector3
  60170. */
  60171. normalizeToNew(): Vector3;
  60172. /**
  60173. * Normalize the current Vector3 to the reference
  60174. * @param reference define the Vector3 to update
  60175. * @returns the updated Vector3
  60176. */
  60177. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60178. /**
  60179. * Creates a new Vector3 copied from the current Vector3
  60180. * @returns the new Vector3
  60181. */
  60182. clone(): Vector3;
  60183. /**
  60184. * Copies the given vector coordinates to the current Vector3 ones
  60185. * @param source defines the source Vector3
  60186. * @returns the current updated Vector3
  60187. */
  60188. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60189. /**
  60190. * Copies the given floats to the current Vector3 coordinates
  60191. * @param x defines the x coordinate of the operand
  60192. * @param y defines the y coordinate of the operand
  60193. * @param z defines the z coordinate of the operand
  60194. * @returns the current updated Vector3
  60195. */
  60196. copyFromFloats(x: number, y: number, z: number): Vector3;
  60197. /**
  60198. * Copies the given floats to the current Vector3 coordinates
  60199. * @param x defines the x coordinate of the operand
  60200. * @param y defines the y coordinate of the operand
  60201. * @param z defines the z coordinate of the operand
  60202. * @returns the current updated Vector3
  60203. */
  60204. set(x: number, y: number, z: number): Vector3;
  60205. /**
  60206. * Copies the given float to the current Vector3 coordinates
  60207. * @param v defines the x, y and z coordinates of the operand
  60208. * @returns the current updated Vector3
  60209. */
  60210. setAll(v: number): Vector3;
  60211. /**
  60212. * Get the clip factor between two vectors
  60213. * @param vector0 defines the first operand
  60214. * @param vector1 defines the second operand
  60215. * @param axis defines the axis to use
  60216. * @param size defines the size along the axis
  60217. * @returns the clip factor
  60218. */
  60219. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60220. /**
  60221. * Get angle between two vectors
  60222. * @param vector0 angle between vector0 and vector1
  60223. * @param vector1 angle between vector0 and vector1
  60224. * @param normal direction of the normal
  60225. * @return the angle between vector0 and vector1
  60226. */
  60227. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60228. /**
  60229. * Returns a new Vector3 set from the index "offset" of the given array
  60230. * @param array defines the source array
  60231. * @param offset defines the offset in the source array
  60232. * @returns the new Vector3
  60233. */
  60234. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60235. /**
  60236. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60237. * This function is deprecated. Use FromArray instead
  60238. * @param array defines the source array
  60239. * @param offset defines the offset in the source array
  60240. * @returns the new Vector3
  60241. */
  60242. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60243. /**
  60244. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60245. * @param array defines the source array
  60246. * @param offset defines the offset in the source array
  60247. * @param result defines the Vector3 where to store the result
  60248. */
  60249. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60250. /**
  60251. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60252. * This function is deprecated. Use FromArrayToRef instead.
  60253. * @param array defines the source array
  60254. * @param offset defines the offset in the source array
  60255. * @param result defines the Vector3 where to store the result
  60256. */
  60257. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60258. /**
  60259. * Sets the given vector "result" with the given floats.
  60260. * @param x defines the x coordinate of the source
  60261. * @param y defines the y coordinate of the source
  60262. * @param z defines the z coordinate of the source
  60263. * @param result defines the Vector3 where to store the result
  60264. */
  60265. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60266. /**
  60267. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60268. * @returns a new empty Vector3
  60269. */
  60270. static Zero(): Vector3;
  60271. /**
  60272. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60273. * @returns a new unit Vector3
  60274. */
  60275. static One(): Vector3;
  60276. /**
  60277. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  60278. * @returns a new up Vector3
  60279. */
  60280. static Up(): Vector3;
  60281. /**
  60282. * Gets a up Vector3 that must not be updated
  60283. */
  60284. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60285. /**
  60286. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60287. * @returns a new down Vector3
  60288. */
  60289. static Down(): Vector3;
  60290. /**
  60291. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  60292. * @returns a new forward Vector3
  60293. */
  60294. static Forward(): Vector3;
  60295. /**
  60296. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  60297. * @returns a new forward Vector3
  60298. */
  60299. static Backward(): Vector3;
  60300. /**
  60301. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  60302. * @returns a new right Vector3
  60303. */
  60304. static Right(): Vector3;
  60305. /**
  60306. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  60307. * @returns a new left Vector3
  60308. */
  60309. static Left(): Vector3;
  60310. /**
  60311. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  60312. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60313. * @param vector defines the Vector3 to transform
  60314. * @param transformation defines the transformation matrix
  60315. * @returns the transformed Vector3
  60316. */
  60317. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60318. /**
  60319. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  60320. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60321. * @param vector defines the Vector3 to transform
  60322. * @param transformation defines the transformation matrix
  60323. * @param result defines the Vector3 where to store the result
  60324. */
  60325. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60326. /**
  60327. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  60328. * This method computes tranformed coordinates only, not transformed direction vectors
  60329. * @param x define the x coordinate of the source vector
  60330. * @param y define the y coordinate of the source vector
  60331. * @param z define the z coordinate of the source vector
  60332. * @param transformation defines the transformation matrix
  60333. * @param result defines the Vector3 where to store the result
  60334. */
  60335. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60336. /**
  60337. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  60338. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60339. * @param vector defines the Vector3 to transform
  60340. * @param transformation defines the transformation matrix
  60341. * @returns the new Vector3
  60342. */
  60343. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60344. /**
  60345. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  60346. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60347. * @param vector defines the Vector3 to transform
  60348. * @param transformation defines the transformation matrix
  60349. * @param result defines the Vector3 where to store the result
  60350. */
  60351. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60352. /**
  60353. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  60354. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60355. * @param x define the x coordinate of the source vector
  60356. * @param y define the y coordinate of the source vector
  60357. * @param z define the z coordinate of the source vector
  60358. * @param transformation defines the transformation matrix
  60359. * @param result defines the Vector3 where to store the result
  60360. */
  60361. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60362. /**
  60363. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  60364. * @param value1 defines the first control point
  60365. * @param value2 defines the second control point
  60366. * @param value3 defines the third control point
  60367. * @param value4 defines the fourth control point
  60368. * @param amount defines the amount on the spline to use
  60369. * @returns the new Vector3
  60370. */
  60371. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  60372. /**
  60373. * 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"
  60374. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60375. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60376. * @param value defines the current value
  60377. * @param min defines the lower range value
  60378. * @param max defines the upper range value
  60379. * @returns the new Vector3
  60380. */
  60381. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  60382. /**
  60383. * 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"
  60384. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60385. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60386. * @param value defines the current value
  60387. * @param min defines the lower range value
  60388. * @param max defines the upper range value
  60389. * @param result defines the Vector3 where to store the result
  60390. */
  60391. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  60392. /**
  60393. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  60394. * @param value1 defines the first control point
  60395. * @param tangent1 defines the first tangent vector
  60396. * @param value2 defines the second control point
  60397. * @param tangent2 defines the second tangent vector
  60398. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  60399. * @returns the new Vector3
  60400. */
  60401. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  60402. /**
  60403. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  60404. * @param start defines the start value
  60405. * @param end defines the end value
  60406. * @param amount max defines amount between both (between 0 and 1)
  60407. * @returns the new Vector3
  60408. */
  60409. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  60410. /**
  60411. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  60412. * @param start defines the start value
  60413. * @param end defines the end value
  60414. * @param amount max defines amount between both (between 0 and 1)
  60415. * @param result defines the Vector3 where to store the result
  60416. */
  60417. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  60418. /**
  60419. * Returns the dot product (float) between the vectors "left" and "right"
  60420. * @param left defines the left operand
  60421. * @param right defines the right operand
  60422. * @returns the dot product
  60423. */
  60424. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  60425. /**
  60426. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  60427. * The cross product is then orthogonal to both "left" and "right"
  60428. * @param left defines the left operand
  60429. * @param right defines the right operand
  60430. * @returns the cross product
  60431. */
  60432. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60433. /**
  60434. * Sets the given vector "result" with the cross product of "left" and "right"
  60435. * The cross product is then orthogonal to both "left" and "right"
  60436. * @param left defines the left operand
  60437. * @param right defines the right operand
  60438. * @param result defines the Vector3 where to store the result
  60439. */
  60440. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  60441. /**
  60442. * Returns a new Vector3 as the normalization of the given vector
  60443. * @param vector defines the Vector3 to normalize
  60444. * @returns the new Vector3
  60445. */
  60446. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  60447. /**
  60448. * Sets the given vector "result" with the normalization of the given first vector
  60449. * @param vector defines the Vector3 to normalize
  60450. * @param result defines the Vector3 where to store the result
  60451. */
  60452. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  60453. /**
  60454. * Project a Vector3 onto screen space
  60455. * @param vector defines the Vector3 to project
  60456. * @param world defines the world matrix to use
  60457. * @param transform defines the transform (view x projection) matrix to use
  60458. * @param viewport defines the screen viewport to use
  60459. * @returns the new Vector3
  60460. */
  60461. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  60462. /** @hidden */
  60463. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  60464. /**
  60465. * Unproject from screen space to object space
  60466. * @param source defines the screen space Vector3 to use
  60467. * @param viewportWidth defines the current width of the viewport
  60468. * @param viewportHeight defines the current height of the viewport
  60469. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60470. * @param transform defines the transform (view x projection) matrix to use
  60471. * @returns the new Vector3
  60472. */
  60473. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  60474. /**
  60475. * Unproject from screen space to object space
  60476. * @param source defines the screen space Vector3 to use
  60477. * @param viewportWidth defines the current width of the viewport
  60478. * @param viewportHeight defines the current height of the viewport
  60479. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60480. * @param view defines the view matrix to use
  60481. * @param projection defines the projection matrix to use
  60482. * @returns the new Vector3
  60483. */
  60484. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  60485. /**
  60486. * Unproject from screen space to object space
  60487. * @param source defines the screen space Vector3 to use
  60488. * @param viewportWidth defines the current width of the viewport
  60489. * @param viewportHeight defines the current height of the viewport
  60490. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60491. * @param view defines the view matrix to use
  60492. * @param projection defines the projection matrix to use
  60493. * @param result defines the Vector3 where to store the result
  60494. */
  60495. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60496. /**
  60497. * Unproject from screen space to object space
  60498. * @param sourceX defines the screen space x coordinate to use
  60499. * @param sourceY defines the screen space y coordinate to use
  60500. * @param sourceZ defines the screen space z coordinate to use
  60501. * @param viewportWidth defines the current width of the viewport
  60502. * @param viewportHeight defines the current height of the viewport
  60503. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60504. * @param view defines the view matrix to use
  60505. * @param projection defines the projection matrix to use
  60506. * @param result defines the Vector3 where to store the result
  60507. */
  60508. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60509. /**
  60510. * Gets the minimal coordinate values between two Vector3
  60511. * @param left defines the first operand
  60512. * @param right defines the second operand
  60513. * @returns the new Vector3
  60514. */
  60515. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60516. /**
  60517. * Gets the maximal coordinate values between two Vector3
  60518. * @param left defines the first operand
  60519. * @param right defines the second operand
  60520. * @returns the new Vector3
  60521. */
  60522. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60523. /**
  60524. * Returns the distance between the vectors "value1" and "value2"
  60525. * @param value1 defines the first operand
  60526. * @param value2 defines the second operand
  60527. * @returns the distance
  60528. */
  60529. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60530. /**
  60531. * Returns the squared distance between the vectors "value1" and "value2"
  60532. * @param value1 defines the first operand
  60533. * @param value2 defines the second operand
  60534. * @returns the squared distance
  60535. */
  60536. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60537. /**
  60538. * Returns a new Vector3 located at the center between "value1" and "value2"
  60539. * @param value1 defines the first operand
  60540. * @param value2 defines the second operand
  60541. * @returns the new Vector3
  60542. */
  60543. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  60544. /**
  60545. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  60546. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  60547. * to something in order to rotate it from its local system to the given target system
  60548. * Note: axis1, axis2 and axis3 are normalized during this operation
  60549. * @param axis1 defines the first axis
  60550. * @param axis2 defines the second axis
  60551. * @param axis3 defines the third axis
  60552. * @returns a new Vector3
  60553. */
  60554. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  60555. /**
  60556. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  60557. * @param axis1 defines the first axis
  60558. * @param axis2 defines the second axis
  60559. * @param axis3 defines the third axis
  60560. * @param ref defines the Vector3 where to store the result
  60561. */
  60562. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  60563. }
  60564. /**
  60565. * Vector4 class created for EulerAngle class conversion to Quaternion
  60566. */
  60567. export class Vector4 {
  60568. /** x value of the vector */
  60569. x: number;
  60570. /** y value of the vector */
  60571. y: number;
  60572. /** z value of the vector */
  60573. z: number;
  60574. /** w value of the vector */
  60575. w: number;
  60576. /**
  60577. * Creates a Vector4 object from the given floats.
  60578. * @param x x value of the vector
  60579. * @param y y value of the vector
  60580. * @param z z value of the vector
  60581. * @param w w value of the vector
  60582. */
  60583. constructor(
  60584. /** x value of the vector */
  60585. x: number,
  60586. /** y value of the vector */
  60587. y: number,
  60588. /** z value of the vector */
  60589. z: number,
  60590. /** w value of the vector */
  60591. w: number);
  60592. /**
  60593. * Returns the string with the Vector4 coordinates.
  60594. * @returns a string containing all the vector values
  60595. */
  60596. toString(): string;
  60597. /**
  60598. * Returns the string "Vector4".
  60599. * @returns "Vector4"
  60600. */
  60601. getClassName(): string;
  60602. /**
  60603. * Returns the Vector4 hash code.
  60604. * @returns a unique hash code
  60605. */
  60606. getHashCode(): number;
  60607. /**
  60608. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  60609. * @returns the resulting array
  60610. */
  60611. asArray(): number[];
  60612. /**
  60613. * Populates the given array from the given index with the Vector4 coordinates.
  60614. * @param array array to populate
  60615. * @param index index of the array to start at (default: 0)
  60616. * @returns the Vector4.
  60617. */
  60618. toArray(array: FloatArray, index?: number): Vector4;
  60619. /**
  60620. * Adds the given vector to the current Vector4.
  60621. * @param otherVector the vector to add
  60622. * @returns the updated Vector4.
  60623. */
  60624. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60625. /**
  60626. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  60627. * @param otherVector the vector to add
  60628. * @returns the resulting vector
  60629. */
  60630. add(otherVector: DeepImmutable<Vector4>): Vector4;
  60631. /**
  60632. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  60633. * @param otherVector the vector to add
  60634. * @param result the vector to store the result
  60635. * @returns the current Vector4.
  60636. */
  60637. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60638. /**
  60639. * Subtract in place the given vector from the current Vector4.
  60640. * @param otherVector the vector to subtract
  60641. * @returns the updated Vector4.
  60642. */
  60643. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60644. /**
  60645. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  60646. * @param otherVector the vector to add
  60647. * @returns the new vector with the result
  60648. */
  60649. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  60650. /**
  60651. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  60652. * @param otherVector the vector to subtract
  60653. * @param result the vector to store the result
  60654. * @returns the current Vector4.
  60655. */
  60656. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60657. /**
  60658. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60659. */
  60660. /**
  60661. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60662. * @param x value to subtract
  60663. * @param y value to subtract
  60664. * @param z value to subtract
  60665. * @param w value to subtract
  60666. * @returns new vector containing the result
  60667. */
  60668. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60669. /**
  60670. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60671. * @param x value to subtract
  60672. * @param y value to subtract
  60673. * @param z value to subtract
  60674. * @param w value to subtract
  60675. * @param result the vector to store the result in
  60676. * @returns the current Vector4.
  60677. */
  60678. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  60679. /**
  60680. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  60681. * @returns a new vector with the negated values
  60682. */
  60683. negate(): Vector4;
  60684. /**
  60685. * Multiplies the current Vector4 coordinates by scale (float).
  60686. * @param scale the number to scale with
  60687. * @returns the updated Vector4.
  60688. */
  60689. scaleInPlace(scale: number): Vector4;
  60690. /**
  60691. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  60692. * @param scale the number to scale with
  60693. * @returns a new vector with the result
  60694. */
  60695. scale(scale: number): Vector4;
  60696. /**
  60697. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  60698. * @param scale the number to scale with
  60699. * @param result a vector to store the result in
  60700. * @returns the current Vector4.
  60701. */
  60702. scaleToRef(scale: number, result: Vector4): Vector4;
  60703. /**
  60704. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  60705. * @param scale defines the scale factor
  60706. * @param result defines the Vector4 object where to store the result
  60707. * @returns the unmodified current Vector4
  60708. */
  60709. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  60710. /**
  60711. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  60712. * @param otherVector the vector to compare against
  60713. * @returns true if they are equal
  60714. */
  60715. equals(otherVector: DeepImmutable<Vector4>): boolean;
  60716. /**
  60717. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  60718. * @param otherVector vector to compare against
  60719. * @param epsilon (Default: very small number)
  60720. * @returns true if they are equal
  60721. */
  60722. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  60723. /**
  60724. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  60725. * @param x x value to compare against
  60726. * @param y y value to compare against
  60727. * @param z z value to compare against
  60728. * @param w w value to compare against
  60729. * @returns true if equal
  60730. */
  60731. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  60732. /**
  60733. * Multiplies in place the current Vector4 by the given one.
  60734. * @param otherVector vector to multiple with
  60735. * @returns the updated Vector4.
  60736. */
  60737. multiplyInPlace(otherVector: Vector4): Vector4;
  60738. /**
  60739. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  60740. * @param otherVector vector to multiple with
  60741. * @returns resulting new vector
  60742. */
  60743. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  60744. /**
  60745. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  60746. * @param otherVector vector to multiple with
  60747. * @param result vector to store the result
  60748. * @returns the current Vector4.
  60749. */
  60750. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60751. /**
  60752. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  60753. * @param x x value multiply with
  60754. * @param y y value multiply with
  60755. * @param z z value multiply with
  60756. * @param w w value multiply with
  60757. * @returns resulting new vector
  60758. */
  60759. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  60760. /**
  60761. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  60762. * @param otherVector vector to devide with
  60763. * @returns resulting new vector
  60764. */
  60765. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  60766. /**
  60767. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  60768. * @param otherVector vector to devide with
  60769. * @param result vector to store the result
  60770. * @returns the current Vector4.
  60771. */
  60772. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60773. /**
  60774. * Divides the current Vector3 coordinates by the given ones.
  60775. * @param otherVector vector to devide with
  60776. * @returns the updated Vector3.
  60777. */
  60778. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60779. /**
  60780. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  60781. * @param other defines the second operand
  60782. * @returns the current updated Vector4
  60783. */
  60784. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60785. /**
  60786. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  60787. * @param other defines the second operand
  60788. * @returns the current updated Vector4
  60789. */
  60790. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60791. /**
  60792. * Gets a new Vector4 from current Vector4 floored values
  60793. * @returns a new Vector4
  60794. */
  60795. floor(): Vector4;
  60796. /**
  60797. * Gets a new Vector4 from current Vector3 floored values
  60798. * @returns a new Vector4
  60799. */
  60800. fract(): Vector4;
  60801. /**
  60802. * Returns the Vector4 length (float).
  60803. * @returns the length
  60804. */
  60805. length(): number;
  60806. /**
  60807. * Returns the Vector4 squared length (float).
  60808. * @returns the length squared
  60809. */
  60810. lengthSquared(): number;
  60811. /**
  60812. * Normalizes in place the Vector4.
  60813. * @returns the updated Vector4.
  60814. */
  60815. normalize(): Vector4;
  60816. /**
  60817. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  60818. * @returns this converted to a new vector3
  60819. */
  60820. toVector3(): Vector3;
  60821. /**
  60822. * Returns a new Vector4 copied from the current one.
  60823. * @returns the new cloned vector
  60824. */
  60825. clone(): Vector4;
  60826. /**
  60827. * Updates the current Vector4 with the given one coordinates.
  60828. * @param source the source vector to copy from
  60829. * @returns the updated Vector4.
  60830. */
  60831. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  60832. /**
  60833. * Updates the current Vector4 coordinates with the given floats.
  60834. * @param x float to copy from
  60835. * @param y float to copy from
  60836. * @param z float to copy from
  60837. * @param w float to copy from
  60838. * @returns the updated Vector4.
  60839. */
  60840. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60841. /**
  60842. * Updates the current Vector4 coordinates with the given floats.
  60843. * @param x float to set from
  60844. * @param y float to set from
  60845. * @param z float to set from
  60846. * @param w float to set from
  60847. * @returns the updated Vector4.
  60848. */
  60849. set(x: number, y: number, z: number, w: number): Vector4;
  60850. /**
  60851. * Copies the given float to the current Vector3 coordinates
  60852. * @param v defines the x, y, z and w coordinates of the operand
  60853. * @returns the current updated Vector3
  60854. */
  60855. setAll(v: number): Vector4;
  60856. /**
  60857. * Returns a new Vector4 set from the starting index of the given array.
  60858. * @param array the array to pull values from
  60859. * @param offset the offset into the array to start at
  60860. * @returns the new vector
  60861. */
  60862. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  60863. /**
  60864. * Updates the given vector "result" from the starting index of the given array.
  60865. * @param array the array to pull values from
  60866. * @param offset the offset into the array to start at
  60867. * @param result the vector to store the result in
  60868. */
  60869. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  60870. /**
  60871. * Updates the given vector "result" from the starting index of the given Float32Array.
  60872. * @param array the array to pull values from
  60873. * @param offset the offset into the array to start at
  60874. * @param result the vector to store the result in
  60875. */
  60876. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  60877. /**
  60878. * Updates the given vector "result" coordinates from the given floats.
  60879. * @param x float to set from
  60880. * @param y float to set from
  60881. * @param z float to set from
  60882. * @param w float to set from
  60883. * @param result the vector to the floats in
  60884. */
  60885. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60886. /**
  60887. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60888. * @returns the new vector
  60889. */
  60890. static Zero(): Vector4;
  60891. /**
  60892. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60893. * @returns the new vector
  60894. */
  60895. static One(): Vector4;
  60896. /**
  60897. * Returns a new normalized Vector4 from the given one.
  60898. * @param vector the vector to normalize
  60899. * @returns the vector
  60900. */
  60901. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60902. /**
  60903. * Updates the given vector "result" from the normalization of the given one.
  60904. * @param vector the vector to normalize
  60905. * @param result the vector to store the result in
  60906. */
  60907. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60908. /**
  60909. * Returns a vector with the minimum values from the left and right vectors
  60910. * @param left left vector to minimize
  60911. * @param right right vector to minimize
  60912. * @returns a new vector with the minimum of the left and right vector values
  60913. */
  60914. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60915. /**
  60916. * Returns a vector with the maximum values from the left and right vectors
  60917. * @param left left vector to maximize
  60918. * @param right right vector to maximize
  60919. * @returns a new vector with the maximum of the left and right vector values
  60920. */
  60921. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60922. /**
  60923. * Returns the distance (float) between the vectors "value1" and "value2".
  60924. * @param value1 value to calulate the distance between
  60925. * @param value2 value to calulate the distance between
  60926. * @return the distance between the two vectors
  60927. */
  60928. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60929. /**
  60930. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60931. * @param value1 value to calulate the distance between
  60932. * @param value2 value to calulate the distance between
  60933. * @return the distance between the two vectors squared
  60934. */
  60935. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60936. /**
  60937. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60938. * @param value1 value to calulate the center between
  60939. * @param value2 value to calulate the center between
  60940. * @return the center between the two vectors
  60941. */
  60942. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60943. /**
  60944. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60945. * This methods computes transformed normalized direction vectors only.
  60946. * @param vector the vector to transform
  60947. * @param transformation the transformation matrix to apply
  60948. * @returns the new vector
  60949. */
  60950. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60951. /**
  60952. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60953. * This methods computes transformed normalized direction vectors only.
  60954. * @param vector the vector to transform
  60955. * @param transformation the transformation matrix to apply
  60956. * @param result the vector to store the result in
  60957. */
  60958. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60959. /**
  60960. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60961. * This methods computes transformed normalized direction vectors only.
  60962. * @param x value to transform
  60963. * @param y value to transform
  60964. * @param z value to transform
  60965. * @param w value to transform
  60966. * @param transformation the transformation matrix to apply
  60967. * @param result the vector to store the results in
  60968. */
  60969. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60970. /**
  60971. * Creates a new Vector4 from a Vector3
  60972. * @param source defines the source data
  60973. * @param w defines the 4th component (default is 0)
  60974. * @returns a new Vector4
  60975. */
  60976. static FromVector3(source: Vector3, w?: number): Vector4;
  60977. }
  60978. /**
  60979. * Interface for the size containing width and height
  60980. */
  60981. export interface ISize {
  60982. /**
  60983. * Width
  60984. */
  60985. width: number;
  60986. /**
  60987. * Heighht
  60988. */
  60989. height: number;
  60990. }
  60991. /**
  60992. * Size containing widht and height
  60993. */
  60994. export class Size implements ISize {
  60995. /**
  60996. * Width
  60997. */
  60998. width: number;
  60999. /**
  61000. * Height
  61001. */
  61002. height: number;
  61003. /**
  61004. * Creates a Size object from the given width and height (floats).
  61005. * @param width width of the new size
  61006. * @param height height of the new size
  61007. */
  61008. constructor(width: number, height: number);
  61009. /**
  61010. * Returns a string with the Size width and height
  61011. * @returns a string with the Size width and height
  61012. */
  61013. toString(): string;
  61014. /**
  61015. * "Size"
  61016. * @returns the string "Size"
  61017. */
  61018. getClassName(): string;
  61019. /**
  61020. * Returns the Size hash code.
  61021. * @returns a hash code for a unique width and height
  61022. */
  61023. getHashCode(): number;
  61024. /**
  61025. * Updates the current size from the given one.
  61026. * @param src the given size
  61027. */
  61028. copyFrom(src: Size): void;
  61029. /**
  61030. * Updates in place the current Size from the given floats.
  61031. * @param width width of the new size
  61032. * @param height height of the new size
  61033. * @returns the updated Size.
  61034. */
  61035. copyFromFloats(width: number, height: number): Size;
  61036. /**
  61037. * Updates in place the current Size from the given floats.
  61038. * @param width width to set
  61039. * @param height height to set
  61040. * @returns the updated Size.
  61041. */
  61042. set(width: number, height: number): Size;
  61043. /**
  61044. * Multiplies the width and height by numbers
  61045. * @param w factor to multiple the width by
  61046. * @param h factor to multiple the height by
  61047. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61048. */
  61049. multiplyByFloats(w: number, h: number): Size;
  61050. /**
  61051. * Clones the size
  61052. * @returns a new Size copied from the given one.
  61053. */
  61054. clone(): Size;
  61055. /**
  61056. * True if the current Size and the given one width and height are strictly equal.
  61057. * @param other the other size to compare against
  61058. * @returns True if the current Size and the given one width and height are strictly equal.
  61059. */
  61060. equals(other: Size): boolean;
  61061. /**
  61062. * The surface of the Size : width * height (float).
  61063. */
  61064. readonly surface: number;
  61065. /**
  61066. * Create a new size of zero
  61067. * @returns a new Size set to (0.0, 0.0)
  61068. */
  61069. static Zero(): Size;
  61070. /**
  61071. * Sums the width and height of two sizes
  61072. * @param otherSize size to add to this size
  61073. * @returns a new Size set as the addition result of the current Size and the given one.
  61074. */
  61075. add(otherSize: Size): Size;
  61076. /**
  61077. * Subtracts the width and height of two
  61078. * @param otherSize size to subtract to this size
  61079. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61080. */
  61081. subtract(otherSize: Size): Size;
  61082. /**
  61083. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61084. * @param start starting size to lerp between
  61085. * @param end end size to lerp between
  61086. * @param amount amount to lerp between the start and end values
  61087. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61088. */
  61089. static Lerp(start: Size, end: Size, amount: number): Size;
  61090. }
  61091. /**
  61092. * Class used to store quaternion data
  61093. * @see https://en.wikipedia.org/wiki/Quaternion
  61094. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61095. */
  61096. export class Quaternion {
  61097. /** defines the first component (0 by default) */
  61098. x: number;
  61099. /** defines the second component (0 by default) */
  61100. y: number;
  61101. /** defines the third component (0 by default) */
  61102. z: number;
  61103. /** defines the fourth component (1.0 by default) */
  61104. w: number;
  61105. /**
  61106. * Creates a new Quaternion from the given floats
  61107. * @param x defines the first component (0 by default)
  61108. * @param y defines the second component (0 by default)
  61109. * @param z defines the third component (0 by default)
  61110. * @param w defines the fourth component (1.0 by default)
  61111. */
  61112. constructor(
  61113. /** defines the first component (0 by default) */
  61114. x?: number,
  61115. /** defines the second component (0 by default) */
  61116. y?: number,
  61117. /** defines the third component (0 by default) */
  61118. z?: number,
  61119. /** defines the fourth component (1.0 by default) */
  61120. w?: number);
  61121. /**
  61122. * Gets a string representation for the current quaternion
  61123. * @returns a string with the Quaternion coordinates
  61124. */
  61125. toString(): string;
  61126. /**
  61127. * Gets the class name of the quaternion
  61128. * @returns the string "Quaternion"
  61129. */
  61130. getClassName(): string;
  61131. /**
  61132. * Gets a hash code for this quaternion
  61133. * @returns the quaternion hash code
  61134. */
  61135. getHashCode(): number;
  61136. /**
  61137. * Copy the quaternion to an array
  61138. * @returns a new array populated with 4 elements from the quaternion coordinates
  61139. */
  61140. asArray(): number[];
  61141. /**
  61142. * Check if two quaternions are equals
  61143. * @param otherQuaternion defines the second operand
  61144. * @return true if the current quaternion and the given one coordinates are strictly equals
  61145. */
  61146. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61147. /**
  61148. * Clone the current quaternion
  61149. * @returns a new quaternion copied from the current one
  61150. */
  61151. clone(): Quaternion;
  61152. /**
  61153. * Copy a quaternion to the current one
  61154. * @param other defines the other quaternion
  61155. * @returns the updated current quaternion
  61156. */
  61157. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61158. /**
  61159. * Updates the current quaternion with the given float coordinates
  61160. * @param x defines the x coordinate
  61161. * @param y defines the y coordinate
  61162. * @param z defines the z coordinate
  61163. * @param w defines the w coordinate
  61164. * @returns the updated current quaternion
  61165. */
  61166. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61167. /**
  61168. * Updates the current quaternion from the given float coordinates
  61169. * @param x defines the x coordinate
  61170. * @param y defines the y coordinate
  61171. * @param z defines the z coordinate
  61172. * @param w defines the w coordinate
  61173. * @returns the updated current quaternion
  61174. */
  61175. set(x: number, y: number, z: number, w: number): Quaternion;
  61176. /**
  61177. * Adds two quaternions
  61178. * @param other defines the second operand
  61179. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61180. */
  61181. add(other: DeepImmutable<Quaternion>): Quaternion;
  61182. /**
  61183. * Add a quaternion to the current one
  61184. * @param other defines the quaternion to add
  61185. * @returns the current quaternion
  61186. */
  61187. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61188. /**
  61189. * Subtract two quaternions
  61190. * @param other defines the second operand
  61191. * @returns a new quaternion as the subtraction result of the given one from the current one
  61192. */
  61193. subtract(other: Quaternion): Quaternion;
  61194. /**
  61195. * Multiplies the current quaternion by a scale factor
  61196. * @param value defines the scale factor
  61197. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61198. */
  61199. scale(value: number): Quaternion;
  61200. /**
  61201. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61202. * @param scale defines the scale factor
  61203. * @param result defines the Quaternion object where to store the result
  61204. * @returns the unmodified current quaternion
  61205. */
  61206. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61207. /**
  61208. * Multiplies in place the current quaternion by a scale factor
  61209. * @param value defines the scale factor
  61210. * @returns the current modified quaternion
  61211. */
  61212. scaleInPlace(value: number): Quaternion;
  61213. /**
  61214. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61215. * @param scale defines the scale factor
  61216. * @param result defines the Quaternion object where to store the result
  61217. * @returns the unmodified current quaternion
  61218. */
  61219. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61220. /**
  61221. * Multiplies two quaternions
  61222. * @param q1 defines the second operand
  61223. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61224. */
  61225. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61226. /**
  61227. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61228. * @param q1 defines the second operand
  61229. * @param result defines the target quaternion
  61230. * @returns the current quaternion
  61231. */
  61232. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61233. /**
  61234. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61235. * @param q1 defines the second operand
  61236. * @returns the currentupdated quaternion
  61237. */
  61238. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61239. /**
  61240. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61241. * @param ref defines the target quaternion
  61242. * @returns the current quaternion
  61243. */
  61244. conjugateToRef(ref: Quaternion): Quaternion;
  61245. /**
  61246. * Conjugates in place (1-q) the current quaternion
  61247. * @returns the current updated quaternion
  61248. */
  61249. conjugateInPlace(): Quaternion;
  61250. /**
  61251. * Conjugates in place (1-q) the current quaternion
  61252. * @returns a new quaternion
  61253. */
  61254. conjugate(): Quaternion;
  61255. /**
  61256. * Gets length of current quaternion
  61257. * @returns the quaternion length (float)
  61258. */
  61259. length(): number;
  61260. /**
  61261. * Normalize in place the current quaternion
  61262. * @returns the current updated quaternion
  61263. */
  61264. normalize(): Quaternion;
  61265. /**
  61266. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61267. * @param order is a reserved parameter and is ignore for now
  61268. * @returns a new Vector3 containing the Euler angles
  61269. */
  61270. toEulerAngles(order?: string): Vector3;
  61271. /**
  61272. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61273. * @param result defines the vector which will be filled with the Euler angles
  61274. * @param order is a reserved parameter and is ignore for now
  61275. * @returns the current unchanged quaternion
  61276. */
  61277. toEulerAnglesToRef(result: Vector3): Quaternion;
  61278. /**
  61279. * Updates the given rotation matrix with the current quaternion values
  61280. * @param result defines the target matrix
  61281. * @returns the current unchanged quaternion
  61282. */
  61283. toRotationMatrix(result: Matrix): Quaternion;
  61284. /**
  61285. * Updates the current quaternion from the given rotation matrix values
  61286. * @param matrix defines the source matrix
  61287. * @returns the current updated quaternion
  61288. */
  61289. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61290. /**
  61291. * Creates a new quaternion from a rotation matrix
  61292. * @param matrix defines the source matrix
  61293. * @returns a new quaternion created from the given rotation matrix values
  61294. */
  61295. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61296. /**
  61297. * Updates the given quaternion with the given rotation matrix values
  61298. * @param matrix defines the source matrix
  61299. * @param result defines the target quaternion
  61300. */
  61301. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  61302. /**
  61303. * Returns the dot product (float) between the quaternions "left" and "right"
  61304. * @param left defines the left operand
  61305. * @param right defines the right operand
  61306. * @returns the dot product
  61307. */
  61308. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  61309. /**
  61310. * Checks if the two quaternions are close to each other
  61311. * @param quat0 defines the first quaternion to check
  61312. * @param quat1 defines the second quaternion to check
  61313. * @returns true if the two quaternions are close to each other
  61314. */
  61315. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  61316. /**
  61317. * Creates an empty quaternion
  61318. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  61319. */
  61320. static Zero(): Quaternion;
  61321. /**
  61322. * Inverse a given quaternion
  61323. * @param q defines the source quaternion
  61324. * @returns a new quaternion as the inverted current quaternion
  61325. */
  61326. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  61327. /**
  61328. * Inverse a given quaternion
  61329. * @param q defines the source quaternion
  61330. * @param result the quaternion the result will be stored in
  61331. * @returns the result quaternion
  61332. */
  61333. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  61334. /**
  61335. * Creates an identity quaternion
  61336. * @returns the identity quaternion
  61337. */
  61338. static Identity(): Quaternion;
  61339. /**
  61340. * Gets a boolean indicating if the given quaternion is identity
  61341. * @param quaternion defines the quaternion to check
  61342. * @returns true if the quaternion is identity
  61343. */
  61344. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  61345. /**
  61346. * Creates a quaternion from a rotation around an axis
  61347. * @param axis defines the axis to use
  61348. * @param angle defines the angle to use
  61349. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  61350. */
  61351. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  61352. /**
  61353. * Creates a rotation around an axis and stores it into the given quaternion
  61354. * @param axis defines the axis to use
  61355. * @param angle defines the angle to use
  61356. * @param result defines the target quaternion
  61357. * @returns the target quaternion
  61358. */
  61359. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  61360. /**
  61361. * Creates a new quaternion from data stored into an array
  61362. * @param array defines the data source
  61363. * @param offset defines the offset in the source array where the data starts
  61364. * @returns a new quaternion
  61365. */
  61366. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  61367. /**
  61368. * Create a quaternion from Euler rotation angles
  61369. * @param x Pitch
  61370. * @param y Yaw
  61371. * @param z Roll
  61372. * @returns the new Quaternion
  61373. */
  61374. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  61375. /**
  61376. * Updates a quaternion from Euler rotation angles
  61377. * @param x Pitch
  61378. * @param y Yaw
  61379. * @param z Roll
  61380. * @param result the quaternion to store the result
  61381. * @returns the updated quaternion
  61382. */
  61383. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  61384. /**
  61385. * Create a quaternion from Euler rotation vector
  61386. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61387. * @returns the new Quaternion
  61388. */
  61389. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  61390. /**
  61391. * Updates a quaternion from Euler rotation vector
  61392. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61393. * @param result the quaternion to store the result
  61394. * @returns the updated quaternion
  61395. */
  61396. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  61397. /**
  61398. * Creates a new quaternion from the given Euler float angles (y, x, z)
  61399. * @param yaw defines the rotation around Y axis
  61400. * @param pitch defines the rotation around X axis
  61401. * @param roll defines the rotation around Z axis
  61402. * @returns the new quaternion
  61403. */
  61404. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  61405. /**
  61406. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  61407. * @param yaw defines the rotation around Y axis
  61408. * @param pitch defines the rotation around X axis
  61409. * @param roll defines the rotation around Z axis
  61410. * @param result defines the target quaternion
  61411. */
  61412. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  61413. /**
  61414. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  61415. * @param alpha defines the rotation around first axis
  61416. * @param beta defines the rotation around second axis
  61417. * @param gamma defines the rotation around third axis
  61418. * @returns the new quaternion
  61419. */
  61420. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  61421. /**
  61422. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  61423. * @param alpha defines the rotation around first axis
  61424. * @param beta defines the rotation around second axis
  61425. * @param gamma defines the rotation around third axis
  61426. * @param result defines the target quaternion
  61427. */
  61428. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  61429. /**
  61430. * 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)
  61431. * @param axis1 defines the first axis
  61432. * @param axis2 defines the second axis
  61433. * @param axis3 defines the third axis
  61434. * @returns the new quaternion
  61435. */
  61436. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  61437. /**
  61438. * 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
  61439. * @param axis1 defines the first axis
  61440. * @param axis2 defines the second axis
  61441. * @param axis3 defines the third axis
  61442. * @param ref defines the target quaternion
  61443. */
  61444. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  61445. /**
  61446. * Interpolates between two quaternions
  61447. * @param left defines first quaternion
  61448. * @param right defines second quaternion
  61449. * @param amount defines the gradient to use
  61450. * @returns the new interpolated quaternion
  61451. */
  61452. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61453. /**
  61454. * Interpolates between two quaternions and stores it into a target quaternion
  61455. * @param left defines first quaternion
  61456. * @param right defines second quaternion
  61457. * @param amount defines the gradient to use
  61458. * @param result defines the target quaternion
  61459. */
  61460. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  61461. /**
  61462. * Interpolate between two quaternions using Hermite interpolation
  61463. * @param value1 defines first quaternion
  61464. * @param tangent1 defines the incoming tangent
  61465. * @param value2 defines second quaternion
  61466. * @param tangent2 defines the outgoing tangent
  61467. * @param amount defines the target quaternion
  61468. * @returns the new interpolated quaternion
  61469. */
  61470. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61471. }
  61472. /**
  61473. * Class used to store matrix data (4x4)
  61474. */
  61475. export class Matrix {
  61476. private static _updateFlagSeed;
  61477. private static _identityReadOnly;
  61478. private _isIdentity;
  61479. private _isIdentityDirty;
  61480. private _isIdentity3x2;
  61481. private _isIdentity3x2Dirty;
  61482. /**
  61483. * Gets the update flag of the matrix which is an unique number for the matrix.
  61484. * It will be incremented every time the matrix data change.
  61485. * You can use it to speed the comparison between two versions of the same matrix.
  61486. */
  61487. updateFlag: number;
  61488. private readonly _m;
  61489. /**
  61490. * Gets the internal data of the matrix
  61491. */
  61492. readonly m: DeepImmutable<Float32Array>;
  61493. /** @hidden */
  61494. _markAsUpdated(): void;
  61495. /** @hidden */
  61496. private _updateIdentityStatus;
  61497. /**
  61498. * Creates an empty matrix (filled with zeros)
  61499. */
  61500. constructor();
  61501. /**
  61502. * Check if the current matrix is identity
  61503. * @returns true is the matrix is the identity matrix
  61504. */
  61505. isIdentity(): boolean;
  61506. /**
  61507. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  61508. * @returns true is the matrix is the identity matrix
  61509. */
  61510. isIdentityAs3x2(): boolean;
  61511. /**
  61512. * Gets the determinant of the matrix
  61513. * @returns the matrix determinant
  61514. */
  61515. determinant(): number;
  61516. /**
  61517. * Returns the matrix as a Float32Array
  61518. * @returns the matrix underlying array
  61519. */
  61520. toArray(): DeepImmutable<Float32Array>;
  61521. /**
  61522. * Returns the matrix as a Float32Array
  61523. * @returns the matrix underlying array.
  61524. */
  61525. asArray(): DeepImmutable<Float32Array>;
  61526. /**
  61527. * Inverts the current matrix in place
  61528. * @returns the current inverted matrix
  61529. */
  61530. invert(): Matrix;
  61531. /**
  61532. * Sets all the matrix elements to zero
  61533. * @returns the current matrix
  61534. */
  61535. reset(): Matrix;
  61536. /**
  61537. * Adds the current matrix with a second one
  61538. * @param other defines the matrix to add
  61539. * @returns a new matrix as the addition of the current matrix and the given one
  61540. */
  61541. add(other: DeepImmutable<Matrix>): Matrix;
  61542. /**
  61543. * Sets the given matrix "result" to the addition of the current matrix and the given one
  61544. * @param other defines the matrix to add
  61545. * @param result defines the target matrix
  61546. * @returns the current matrix
  61547. */
  61548. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61549. /**
  61550. * Adds in place the given matrix to the current matrix
  61551. * @param other defines the second operand
  61552. * @returns the current updated matrix
  61553. */
  61554. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  61555. /**
  61556. * Sets the given matrix to the current inverted Matrix
  61557. * @param other defines the target matrix
  61558. * @returns the unmodified current matrix
  61559. */
  61560. invertToRef(other: Matrix): Matrix;
  61561. /**
  61562. * add a value at the specified position in the current Matrix
  61563. * @param index the index of the value within the matrix. between 0 and 15.
  61564. * @param value the value to be added
  61565. * @returns the current updated matrix
  61566. */
  61567. addAtIndex(index: number, value: number): Matrix;
  61568. /**
  61569. * mutiply the specified position in the current Matrix by a value
  61570. * @param index the index of the value within the matrix. between 0 and 15.
  61571. * @param value the value to be added
  61572. * @returns the current updated matrix
  61573. */
  61574. multiplyAtIndex(index: number, value: number): Matrix;
  61575. /**
  61576. * Inserts the translation vector (using 3 floats) in the current matrix
  61577. * @param x defines the 1st component of the translation
  61578. * @param y defines the 2nd component of the translation
  61579. * @param z defines the 3rd component of the translation
  61580. * @returns the current updated matrix
  61581. */
  61582. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  61583. /**
  61584. * Inserts the translation vector in the current matrix
  61585. * @param vector3 defines the translation to insert
  61586. * @returns the current updated matrix
  61587. */
  61588. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  61589. /**
  61590. * Gets the translation value of the current matrix
  61591. * @returns a new Vector3 as the extracted translation from the matrix
  61592. */
  61593. getTranslation(): Vector3;
  61594. /**
  61595. * Fill a Vector3 with the extracted translation from the matrix
  61596. * @param result defines the Vector3 where to store the translation
  61597. * @returns the current matrix
  61598. */
  61599. getTranslationToRef(result: Vector3): Matrix;
  61600. /**
  61601. * Remove rotation and scaling part from the matrix
  61602. * @returns the updated matrix
  61603. */
  61604. removeRotationAndScaling(): Matrix;
  61605. /**
  61606. * Multiply two matrices
  61607. * @param other defines the second operand
  61608. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  61609. */
  61610. multiply(other: DeepImmutable<Matrix>): Matrix;
  61611. /**
  61612. * Copy the current matrix from the given one
  61613. * @param other defines the source matrix
  61614. * @returns the current updated matrix
  61615. */
  61616. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  61617. /**
  61618. * Populates the given array from the starting index with the current matrix values
  61619. * @param array defines the target array
  61620. * @param offset defines the offset in the target array where to start storing values
  61621. * @returns the current matrix
  61622. */
  61623. copyToArray(array: Float32Array, offset?: number): Matrix;
  61624. /**
  61625. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  61626. * @param other defines the second operand
  61627. * @param result defines the matrix where to store the multiplication
  61628. * @returns the current matrix
  61629. */
  61630. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61631. /**
  61632. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  61633. * @param other defines the second operand
  61634. * @param result defines the array where to store the multiplication
  61635. * @param offset defines the offset in the target array where to start storing values
  61636. * @returns the current matrix
  61637. */
  61638. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  61639. /**
  61640. * Check equality between this matrix and a second one
  61641. * @param value defines the second matrix to compare
  61642. * @returns true is the current matrix and the given one values are strictly equal
  61643. */
  61644. equals(value: DeepImmutable<Matrix>): boolean;
  61645. /**
  61646. * Clone the current matrix
  61647. * @returns a new matrix from the current matrix
  61648. */
  61649. clone(): Matrix;
  61650. /**
  61651. * Returns the name of the current matrix class
  61652. * @returns the string "Matrix"
  61653. */
  61654. getClassName(): string;
  61655. /**
  61656. * Gets the hash code of the current matrix
  61657. * @returns the hash code
  61658. */
  61659. getHashCode(): number;
  61660. /**
  61661. * Decomposes the current Matrix into a translation, rotation and scaling components
  61662. * @param scale defines the scale vector3 given as a reference to update
  61663. * @param rotation defines the rotation quaternion given as a reference to update
  61664. * @param translation defines the translation vector3 given as a reference to update
  61665. * @returns true if operation was successful
  61666. */
  61667. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  61668. /**
  61669. * Gets specific row of the matrix
  61670. * @param index defines the number of the row to get
  61671. * @returns the index-th row of the current matrix as a new Vector4
  61672. */
  61673. getRow(index: number): Nullable<Vector4>;
  61674. /**
  61675. * Sets the index-th row of the current matrix to the vector4 values
  61676. * @param index defines the number of the row to set
  61677. * @param row defines the target vector4
  61678. * @returns the updated current matrix
  61679. */
  61680. setRow(index: number, row: Vector4): Matrix;
  61681. /**
  61682. * Compute the transpose of the matrix
  61683. * @returns the new transposed matrix
  61684. */
  61685. transpose(): Matrix;
  61686. /**
  61687. * Compute the transpose of the matrix and store it in a given matrix
  61688. * @param result defines the target matrix
  61689. * @returns the current matrix
  61690. */
  61691. transposeToRef(result: Matrix): Matrix;
  61692. /**
  61693. * Sets the index-th row of the current matrix with the given 4 x float values
  61694. * @param index defines the row index
  61695. * @param x defines the x component to set
  61696. * @param y defines the y component to set
  61697. * @param z defines the z component to set
  61698. * @param w defines the w component to set
  61699. * @returns the updated current matrix
  61700. */
  61701. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  61702. /**
  61703. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  61704. * @param scale defines the scale factor
  61705. * @returns a new matrix
  61706. */
  61707. scale(scale: number): Matrix;
  61708. /**
  61709. * Scale the current matrix values by a factor to a given result matrix
  61710. * @param scale defines the scale factor
  61711. * @param result defines the matrix to store the result
  61712. * @returns the current matrix
  61713. */
  61714. scaleToRef(scale: number, result: Matrix): Matrix;
  61715. /**
  61716. * Scale the current matrix values by a factor and add the result to a given matrix
  61717. * @param scale defines the scale factor
  61718. * @param result defines the Matrix to store the result
  61719. * @returns the current matrix
  61720. */
  61721. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  61722. /**
  61723. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  61724. * @param ref matrix to store the result
  61725. */
  61726. toNormalMatrix(ref: Matrix): void;
  61727. /**
  61728. * Gets only rotation part of the current matrix
  61729. * @returns a new matrix sets to the extracted rotation matrix from the current one
  61730. */
  61731. getRotationMatrix(): Matrix;
  61732. /**
  61733. * Extracts the rotation matrix from the current one and sets it as the given "result"
  61734. * @param result defines the target matrix to store data to
  61735. * @returns the current matrix
  61736. */
  61737. getRotationMatrixToRef(result: Matrix): Matrix;
  61738. /**
  61739. * Toggles model matrix from being right handed to left handed in place and vice versa
  61740. */
  61741. toggleModelMatrixHandInPlace(): void;
  61742. /**
  61743. * Toggles projection matrix from being right handed to left handed in place and vice versa
  61744. */
  61745. toggleProjectionMatrixHandInPlace(): void;
  61746. /**
  61747. * Creates a matrix from an array
  61748. * @param array defines the source array
  61749. * @param offset defines an offset in the source array
  61750. * @returns a new Matrix set from the starting index of the given array
  61751. */
  61752. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  61753. /**
  61754. * Copy the content of an array into a given matrix
  61755. * @param array defines the source array
  61756. * @param offset defines an offset in the source array
  61757. * @param result defines the target matrix
  61758. */
  61759. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  61760. /**
  61761. * Stores an array into a matrix after having multiplied each component by a given factor
  61762. * @param array defines the source array
  61763. * @param offset defines the offset in the source array
  61764. * @param scale defines the scaling factor
  61765. * @param result defines the target matrix
  61766. */
  61767. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  61768. /**
  61769. * Gets an identity matrix that must not be updated
  61770. */
  61771. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  61772. /**
  61773. * Stores a list of values (16) inside a given matrix
  61774. * @param initialM11 defines 1st value of 1st row
  61775. * @param initialM12 defines 2nd value of 1st row
  61776. * @param initialM13 defines 3rd value of 1st row
  61777. * @param initialM14 defines 4th value of 1st row
  61778. * @param initialM21 defines 1st value of 2nd row
  61779. * @param initialM22 defines 2nd value of 2nd row
  61780. * @param initialM23 defines 3rd value of 2nd row
  61781. * @param initialM24 defines 4th value of 2nd row
  61782. * @param initialM31 defines 1st value of 3rd row
  61783. * @param initialM32 defines 2nd value of 3rd row
  61784. * @param initialM33 defines 3rd value of 3rd row
  61785. * @param initialM34 defines 4th value of 3rd row
  61786. * @param initialM41 defines 1st value of 4th row
  61787. * @param initialM42 defines 2nd value of 4th row
  61788. * @param initialM43 defines 3rd value of 4th row
  61789. * @param initialM44 defines 4th value of 4th row
  61790. * @param result defines the target matrix
  61791. */
  61792. 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;
  61793. /**
  61794. * Creates new matrix from a list of values (16)
  61795. * @param initialM11 defines 1st value of 1st row
  61796. * @param initialM12 defines 2nd value of 1st row
  61797. * @param initialM13 defines 3rd value of 1st row
  61798. * @param initialM14 defines 4th value of 1st row
  61799. * @param initialM21 defines 1st value of 2nd row
  61800. * @param initialM22 defines 2nd value of 2nd row
  61801. * @param initialM23 defines 3rd value of 2nd row
  61802. * @param initialM24 defines 4th value of 2nd row
  61803. * @param initialM31 defines 1st value of 3rd row
  61804. * @param initialM32 defines 2nd value of 3rd row
  61805. * @param initialM33 defines 3rd value of 3rd row
  61806. * @param initialM34 defines 4th value of 3rd row
  61807. * @param initialM41 defines 1st value of 4th row
  61808. * @param initialM42 defines 2nd value of 4th row
  61809. * @param initialM43 defines 3rd value of 4th row
  61810. * @param initialM44 defines 4th value of 4th row
  61811. * @returns the new matrix
  61812. */
  61813. 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;
  61814. /**
  61815. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61816. * @param scale defines the scale vector3
  61817. * @param rotation defines the rotation quaternion
  61818. * @param translation defines the translation vector3
  61819. * @returns a new matrix
  61820. */
  61821. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  61822. /**
  61823. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61824. * @param scale defines the scale vector3
  61825. * @param rotation defines the rotation quaternion
  61826. * @param translation defines the translation vector3
  61827. * @param result defines the target matrix
  61828. */
  61829. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  61830. /**
  61831. * Creates a new identity matrix
  61832. * @returns a new identity matrix
  61833. */
  61834. static Identity(): Matrix;
  61835. /**
  61836. * Creates a new identity matrix and stores the result in a given matrix
  61837. * @param result defines the target matrix
  61838. */
  61839. static IdentityToRef(result: Matrix): void;
  61840. /**
  61841. * Creates a new zero matrix
  61842. * @returns a new zero matrix
  61843. */
  61844. static Zero(): Matrix;
  61845. /**
  61846. * Creates a new rotation matrix for "angle" radians around the X axis
  61847. * @param angle defines the angle (in radians) to use
  61848. * @return the new matrix
  61849. */
  61850. static RotationX(angle: number): Matrix;
  61851. /**
  61852. * Creates a new matrix as the invert of a given matrix
  61853. * @param source defines the source matrix
  61854. * @returns the new matrix
  61855. */
  61856. static Invert(source: DeepImmutable<Matrix>): Matrix;
  61857. /**
  61858. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  61859. * @param angle defines the angle (in radians) to use
  61860. * @param result defines the target matrix
  61861. */
  61862. static RotationXToRef(angle: number, result: Matrix): void;
  61863. /**
  61864. * Creates a new rotation matrix for "angle" radians around the Y axis
  61865. * @param angle defines the angle (in radians) to use
  61866. * @return the new matrix
  61867. */
  61868. static RotationY(angle: number): Matrix;
  61869. /**
  61870. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  61871. * @param angle defines the angle (in radians) to use
  61872. * @param result defines the target matrix
  61873. */
  61874. static RotationYToRef(angle: number, result: Matrix): void;
  61875. /**
  61876. * Creates a new rotation matrix for "angle" radians around the Z axis
  61877. * @param angle defines the angle (in radians) to use
  61878. * @return the new matrix
  61879. */
  61880. static RotationZ(angle: number): Matrix;
  61881. /**
  61882. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61883. * @param angle defines the angle (in radians) to use
  61884. * @param result defines the target matrix
  61885. */
  61886. static RotationZToRef(angle: number, result: Matrix): void;
  61887. /**
  61888. * Creates a new rotation matrix for "angle" radians around the given axis
  61889. * @param axis defines the axis to use
  61890. * @param angle defines the angle (in radians) to use
  61891. * @return the new matrix
  61892. */
  61893. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61894. /**
  61895. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61896. * @param axis defines the axis to use
  61897. * @param angle defines the angle (in radians) to use
  61898. * @param result defines the target matrix
  61899. */
  61900. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61901. /**
  61902. * Creates a rotation matrix
  61903. * @param yaw defines the yaw angle in radians (Y axis)
  61904. * @param pitch defines the pitch angle in radians (X axis)
  61905. * @param roll defines the roll angle in radians (X axis)
  61906. * @returns the new rotation matrix
  61907. */
  61908. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61909. /**
  61910. * Creates a rotation matrix and stores it in a given matrix
  61911. * @param yaw defines the yaw angle in radians (Y axis)
  61912. * @param pitch defines the pitch angle in radians (X axis)
  61913. * @param roll defines the roll angle in radians (X axis)
  61914. * @param result defines the target matrix
  61915. */
  61916. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61917. /**
  61918. * Creates a scaling matrix
  61919. * @param x defines the scale factor on X axis
  61920. * @param y defines the scale factor on Y axis
  61921. * @param z defines the scale factor on Z axis
  61922. * @returns the new matrix
  61923. */
  61924. static Scaling(x: number, y: number, z: number): Matrix;
  61925. /**
  61926. * Creates a scaling matrix and stores it in a given matrix
  61927. * @param x defines the scale factor on X axis
  61928. * @param y defines the scale factor on Y axis
  61929. * @param z defines the scale factor on Z axis
  61930. * @param result defines the target matrix
  61931. */
  61932. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61933. /**
  61934. * Creates a translation matrix
  61935. * @param x defines the translation on X axis
  61936. * @param y defines the translation on Y axis
  61937. * @param z defines the translationon Z axis
  61938. * @returns the new matrix
  61939. */
  61940. static Translation(x: number, y: number, z: number): Matrix;
  61941. /**
  61942. * Creates a translation matrix and stores it in a given matrix
  61943. * @param x defines the translation on X axis
  61944. * @param y defines the translation on Y axis
  61945. * @param z defines the translationon Z axis
  61946. * @param result defines the target matrix
  61947. */
  61948. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61949. /**
  61950. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61951. * @param startValue defines the start value
  61952. * @param endValue defines the end value
  61953. * @param gradient defines the gradient factor
  61954. * @returns the new matrix
  61955. */
  61956. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61957. /**
  61958. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61959. * @param startValue defines the start value
  61960. * @param endValue defines the end value
  61961. * @param gradient defines the gradient factor
  61962. * @param result defines the Matrix object where to store data
  61963. */
  61964. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61965. /**
  61966. * Builds a new matrix whose values are computed by:
  61967. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61968. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61969. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61970. * @param startValue defines the first matrix
  61971. * @param endValue defines the second matrix
  61972. * @param gradient defines the gradient between the two matrices
  61973. * @returns the new matrix
  61974. */
  61975. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61976. /**
  61977. * Update a matrix to values which are computed by:
  61978. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61979. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61980. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61981. * @param startValue defines the first matrix
  61982. * @param endValue defines the second matrix
  61983. * @param gradient defines the gradient between the two matrices
  61984. * @param result defines the target matrix
  61985. */
  61986. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61987. /**
  61988. * 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"
  61989. * This function works in left handed mode
  61990. * @param eye defines the final position of the entity
  61991. * @param target defines where the entity should look at
  61992. * @param up defines the up vector for the entity
  61993. * @returns the new matrix
  61994. */
  61995. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61996. /**
  61997. * 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".
  61998. * This function works in left handed mode
  61999. * @param eye defines the final position of the entity
  62000. * @param target defines where the entity should look at
  62001. * @param up defines the up vector for the entity
  62002. * @param result defines the target matrix
  62003. */
  62004. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62005. /**
  62006. * 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"
  62007. * This function works in right handed mode
  62008. * @param eye defines the final position of the entity
  62009. * @param target defines where the entity should look at
  62010. * @param up defines the up vector for the entity
  62011. * @returns the new matrix
  62012. */
  62013. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62014. /**
  62015. * 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".
  62016. * This function works in right handed mode
  62017. * @param eye defines the final position of the entity
  62018. * @param target defines where the entity should look at
  62019. * @param up defines the up vector for the entity
  62020. * @param result defines the target matrix
  62021. */
  62022. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62023. /**
  62024. * Create a left-handed orthographic projection matrix
  62025. * @param width defines the viewport width
  62026. * @param height defines the viewport height
  62027. * @param znear defines the near clip plane
  62028. * @param zfar defines the far clip plane
  62029. * @returns a new matrix as a left-handed orthographic projection matrix
  62030. */
  62031. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62032. /**
  62033. * Store a left-handed orthographic projection to a given matrix
  62034. * @param width defines the viewport width
  62035. * @param height defines the viewport height
  62036. * @param znear defines the near clip plane
  62037. * @param zfar defines the far clip plane
  62038. * @param result defines the target matrix
  62039. */
  62040. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62041. /**
  62042. * Create a left-handed orthographic projection matrix
  62043. * @param left defines the viewport left coordinate
  62044. * @param right defines the viewport right coordinate
  62045. * @param bottom defines the viewport bottom coordinate
  62046. * @param top defines the viewport top coordinate
  62047. * @param znear defines the near clip plane
  62048. * @param zfar defines the far clip plane
  62049. * @returns a new matrix as a left-handed orthographic projection matrix
  62050. */
  62051. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62052. /**
  62053. * Stores a left-handed orthographic projection into a given matrix
  62054. * @param left defines the viewport left coordinate
  62055. * @param right defines the viewport right coordinate
  62056. * @param bottom defines the viewport bottom coordinate
  62057. * @param top defines the viewport top coordinate
  62058. * @param znear defines the near clip plane
  62059. * @param zfar defines the far clip plane
  62060. * @param result defines the target matrix
  62061. */
  62062. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62063. /**
  62064. * Creates a right-handed orthographic projection matrix
  62065. * @param left defines the viewport left coordinate
  62066. * @param right defines the viewport right coordinate
  62067. * @param bottom defines the viewport bottom coordinate
  62068. * @param top defines the viewport top coordinate
  62069. * @param znear defines the near clip plane
  62070. * @param zfar defines the far clip plane
  62071. * @returns a new matrix as a right-handed orthographic projection matrix
  62072. */
  62073. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62074. /**
  62075. * Stores a right-handed orthographic projection into a given matrix
  62076. * @param left defines the viewport left coordinate
  62077. * @param right defines the viewport right coordinate
  62078. * @param bottom defines the viewport bottom coordinate
  62079. * @param top defines the viewport top coordinate
  62080. * @param znear defines the near clip plane
  62081. * @param zfar defines the far clip plane
  62082. * @param result defines the target matrix
  62083. */
  62084. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62085. /**
  62086. * Creates a left-handed perspective projection matrix
  62087. * @param width defines the viewport width
  62088. * @param height defines the viewport height
  62089. * @param znear defines the near clip plane
  62090. * @param zfar defines the far clip plane
  62091. * @returns a new matrix as a left-handed perspective projection matrix
  62092. */
  62093. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62094. /**
  62095. * Creates a left-handed perspective projection matrix
  62096. * @param fov defines the horizontal field of view
  62097. * @param aspect defines the aspect ratio
  62098. * @param znear defines the near clip plane
  62099. * @param zfar defines the far clip plane
  62100. * @returns a new matrix as a left-handed perspective projection matrix
  62101. */
  62102. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62103. /**
  62104. * Stores a left-handed perspective projection into a given matrix
  62105. * @param fov defines the horizontal field of view
  62106. * @param aspect defines the aspect ratio
  62107. * @param znear defines the near clip plane
  62108. * @param zfar defines the far clip plane
  62109. * @param result defines the target matrix
  62110. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62111. */
  62112. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62113. /**
  62114. * Creates a right-handed perspective projection matrix
  62115. * @param fov defines the horizontal field of view
  62116. * @param aspect defines the aspect ratio
  62117. * @param znear defines the near clip plane
  62118. * @param zfar defines the far clip plane
  62119. * @returns a new matrix as a right-handed perspective projection matrix
  62120. */
  62121. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62122. /**
  62123. * Stores a right-handed perspective projection into a given matrix
  62124. * @param fov defines the horizontal field of view
  62125. * @param aspect defines the aspect ratio
  62126. * @param znear defines the near clip plane
  62127. * @param zfar defines the far clip plane
  62128. * @param result defines the target matrix
  62129. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62130. */
  62131. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62132. /**
  62133. * Stores a perspective projection for WebVR info a given matrix
  62134. * @param fov defines the field of view
  62135. * @param znear defines the near clip plane
  62136. * @param zfar defines the far clip plane
  62137. * @param result defines the target matrix
  62138. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62139. */
  62140. static PerspectiveFovWebVRToRef(fov: {
  62141. upDegrees: number;
  62142. downDegrees: number;
  62143. leftDegrees: number;
  62144. rightDegrees: number;
  62145. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62146. /**
  62147. * Computes a complete transformation matrix
  62148. * @param viewport defines the viewport to use
  62149. * @param world defines the world matrix
  62150. * @param view defines the view matrix
  62151. * @param projection defines the projection matrix
  62152. * @param zmin defines the near clip plane
  62153. * @param zmax defines the far clip plane
  62154. * @returns the transformation matrix
  62155. */
  62156. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62157. /**
  62158. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62159. * @param matrix defines the matrix to use
  62160. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62161. */
  62162. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62163. /**
  62164. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62165. * @param matrix defines the matrix to use
  62166. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62167. */
  62168. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62169. /**
  62170. * Compute the transpose of a given matrix
  62171. * @param matrix defines the matrix to transpose
  62172. * @returns the new matrix
  62173. */
  62174. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62175. /**
  62176. * Compute the transpose of a matrix and store it in a target matrix
  62177. * @param matrix defines the matrix to transpose
  62178. * @param result defines the target matrix
  62179. */
  62180. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62181. /**
  62182. * Computes a reflection matrix from a plane
  62183. * @param plane defines the reflection plane
  62184. * @returns a new matrix
  62185. */
  62186. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62187. /**
  62188. * Computes a reflection matrix from a plane
  62189. * @param plane defines the reflection plane
  62190. * @param result defines the target matrix
  62191. */
  62192. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62193. /**
  62194. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62195. * @param xaxis defines the value of the 1st axis
  62196. * @param yaxis defines the value of the 2nd axis
  62197. * @param zaxis defines the value of the 3rd axis
  62198. * @param result defines the target matrix
  62199. */
  62200. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62201. /**
  62202. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62203. * @param quat defines the quaternion to use
  62204. * @param result defines the target matrix
  62205. */
  62206. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62207. }
  62208. /**
  62209. * Represens a plane by the equation ax + by + cz + d = 0
  62210. */
  62211. export class Plane {
  62212. /**
  62213. * Normal of the plane (a,b,c)
  62214. */
  62215. normal: Vector3;
  62216. /**
  62217. * d component of the plane
  62218. */
  62219. d: number;
  62220. /**
  62221. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62222. * @param a a component of the plane
  62223. * @param b b component of the plane
  62224. * @param c c component of the plane
  62225. * @param d d component of the plane
  62226. */
  62227. constructor(a: number, b: number, c: number, d: number);
  62228. /**
  62229. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62230. */
  62231. asArray(): number[];
  62232. /**
  62233. * @returns a new plane copied from the current Plane.
  62234. */
  62235. clone(): Plane;
  62236. /**
  62237. * @returns the string "Plane".
  62238. */
  62239. getClassName(): string;
  62240. /**
  62241. * @returns the Plane hash code.
  62242. */
  62243. getHashCode(): number;
  62244. /**
  62245. * Normalize the current Plane in place.
  62246. * @returns the updated Plane.
  62247. */
  62248. normalize(): Plane;
  62249. /**
  62250. * Applies a transformation the plane and returns the result
  62251. * @param transformation the transformation matrix to be applied to the plane
  62252. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62253. */
  62254. transform(transformation: DeepImmutable<Matrix>): Plane;
  62255. /**
  62256. * Calcualtte the dot product between the point and the plane normal
  62257. * @param point point to calculate the dot product with
  62258. * @returns the dot product (float) of the point coordinates and the plane normal.
  62259. */
  62260. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62261. /**
  62262. * Updates the current Plane from the plane defined by the three given points.
  62263. * @param point1 one of the points used to contruct the plane
  62264. * @param point2 one of the points used to contruct the plane
  62265. * @param point3 one of the points used to contruct the plane
  62266. * @returns the updated Plane.
  62267. */
  62268. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62269. /**
  62270. * Checks if the plane is facing a given direction
  62271. * @param direction the direction to check if the plane is facing
  62272. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  62273. * @returns True is the vector "direction" is the same side than the plane normal.
  62274. */
  62275. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  62276. /**
  62277. * Calculates the distance to a point
  62278. * @param point point to calculate distance to
  62279. * @returns the signed distance (float) from the given point to the Plane.
  62280. */
  62281. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  62282. /**
  62283. * Creates a plane from an array
  62284. * @param array the array to create a plane from
  62285. * @returns a new Plane from the given array.
  62286. */
  62287. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  62288. /**
  62289. * Creates a plane from three points
  62290. * @param point1 point used to create the plane
  62291. * @param point2 point used to create the plane
  62292. * @param point3 point used to create the plane
  62293. * @returns a new Plane defined by the three given points.
  62294. */
  62295. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62296. /**
  62297. * Creates a plane from an origin point and a normal
  62298. * @param origin origin of the plane to be constructed
  62299. * @param normal normal of the plane to be constructed
  62300. * @returns a new Plane the normal vector to this plane at the given origin point.
  62301. * Note : the vector "normal" is updated because normalized.
  62302. */
  62303. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  62304. /**
  62305. * Calculates the distance from a plane and a point
  62306. * @param origin origin of the plane to be constructed
  62307. * @param normal normal of the plane to be constructed
  62308. * @param point point to calculate distance to
  62309. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  62310. */
  62311. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  62312. }
  62313. /**
  62314. * Class used to represent a viewport on screen
  62315. */
  62316. export class Viewport {
  62317. /** viewport left coordinate */
  62318. x: number;
  62319. /** viewport top coordinate */
  62320. y: number;
  62321. /**viewport width */
  62322. width: number;
  62323. /** viewport height */
  62324. height: number;
  62325. /**
  62326. * Creates a Viewport object located at (x, y) and sized (width, height)
  62327. * @param x defines viewport left coordinate
  62328. * @param y defines viewport top coordinate
  62329. * @param width defines the viewport width
  62330. * @param height defines the viewport height
  62331. */
  62332. constructor(
  62333. /** viewport left coordinate */
  62334. x: number,
  62335. /** viewport top coordinate */
  62336. y: number,
  62337. /**viewport width */
  62338. width: number,
  62339. /** viewport height */
  62340. height: number);
  62341. /**
  62342. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  62343. * @param renderWidth defines the rendering width
  62344. * @param renderHeight defines the rendering height
  62345. * @returns a new Viewport
  62346. */
  62347. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  62348. /**
  62349. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  62350. * @param renderWidth defines the rendering width
  62351. * @param renderHeight defines the rendering height
  62352. * @param ref defines the target viewport
  62353. * @returns the current viewport
  62354. */
  62355. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  62356. /**
  62357. * Returns a new Viewport copied from the current one
  62358. * @returns a new Viewport
  62359. */
  62360. clone(): Viewport;
  62361. }
  62362. /**
  62363. * Reprasents a camera frustum
  62364. */
  62365. export class Frustum {
  62366. /**
  62367. * Gets the planes representing the frustum
  62368. * @param transform matrix to be applied to the returned planes
  62369. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  62370. */
  62371. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  62372. /**
  62373. * Gets the near frustum plane transformed by the transform matrix
  62374. * @param transform transformation matrix to be applied to the resulting frustum plane
  62375. * @param frustumPlane the resuling frustum plane
  62376. */
  62377. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62378. /**
  62379. * Gets the far frustum plane transformed by the transform matrix
  62380. * @param transform transformation matrix to be applied to the resulting frustum plane
  62381. * @param frustumPlane the resuling frustum plane
  62382. */
  62383. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62384. /**
  62385. * Gets the left frustum plane transformed by the transform matrix
  62386. * @param transform transformation matrix to be applied to the resulting frustum plane
  62387. * @param frustumPlane the resuling frustum plane
  62388. */
  62389. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62390. /**
  62391. * Gets the right frustum plane transformed by the transform matrix
  62392. * @param transform transformation matrix to be applied to the resulting frustum plane
  62393. * @param frustumPlane the resuling frustum plane
  62394. */
  62395. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62396. /**
  62397. * Gets the top frustum plane transformed by the transform matrix
  62398. * @param transform transformation matrix to be applied to the resulting frustum plane
  62399. * @param frustumPlane the resuling frustum plane
  62400. */
  62401. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62402. /**
  62403. * Gets the bottom frustum plane transformed by the transform matrix
  62404. * @param transform transformation matrix to be applied to the resulting frustum plane
  62405. * @param frustumPlane the resuling frustum plane
  62406. */
  62407. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62408. /**
  62409. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  62410. * @param transform transformation matrix to be applied to the resulting frustum planes
  62411. * @param frustumPlanes the resuling frustum planes
  62412. */
  62413. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  62414. }
  62415. /** Defines supported spaces */
  62416. export enum Space {
  62417. /** Local (object) space */
  62418. LOCAL = 0,
  62419. /** World space */
  62420. WORLD = 1,
  62421. /** Bone space */
  62422. BONE = 2
  62423. }
  62424. /** Defines the 3 main axes */
  62425. export class Axis {
  62426. /** X axis */
  62427. static X: Vector3;
  62428. /** Y axis */
  62429. static Y: Vector3;
  62430. /** Z axis */
  62431. static Z: Vector3;
  62432. }
  62433. /** Class used to represent a Bezier curve */
  62434. export class BezierCurve {
  62435. /**
  62436. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  62437. * @param t defines the time
  62438. * @param x1 defines the left coordinate on X axis
  62439. * @param y1 defines the left coordinate on Y axis
  62440. * @param x2 defines the right coordinate on X axis
  62441. * @param y2 defines the right coordinate on Y axis
  62442. * @returns the interpolated value
  62443. */
  62444. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  62445. }
  62446. /**
  62447. * Defines potential orientation for back face culling
  62448. */
  62449. export enum Orientation {
  62450. /**
  62451. * Clockwise
  62452. */
  62453. CW = 0,
  62454. /** Counter clockwise */
  62455. CCW = 1
  62456. }
  62457. /**
  62458. * Defines angle representation
  62459. */
  62460. export class Angle {
  62461. private _radians;
  62462. /**
  62463. * Creates an Angle object of "radians" radians (float).
  62464. * @param radians the angle in radians
  62465. */
  62466. constructor(radians: number);
  62467. /**
  62468. * Get value in degrees
  62469. * @returns the Angle value in degrees (float)
  62470. */
  62471. degrees(): number;
  62472. /**
  62473. * Get value in radians
  62474. * @returns the Angle value in radians (float)
  62475. */
  62476. radians(): number;
  62477. /**
  62478. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  62479. * @param a defines first vector
  62480. * @param b defines second vector
  62481. * @returns a new Angle
  62482. */
  62483. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  62484. /**
  62485. * Gets a new Angle object from the given float in radians
  62486. * @param radians defines the angle value in radians
  62487. * @returns a new Angle
  62488. */
  62489. static FromRadians(radians: number): Angle;
  62490. /**
  62491. * Gets a new Angle object from the given float in degrees
  62492. * @param degrees defines the angle value in degrees
  62493. * @returns a new Angle
  62494. */
  62495. static FromDegrees(degrees: number): Angle;
  62496. }
  62497. /**
  62498. * This represents an arc in a 2d space.
  62499. */
  62500. export class Arc2 {
  62501. /** Defines the start point of the arc */
  62502. startPoint: Vector2;
  62503. /** Defines the mid point of the arc */
  62504. midPoint: Vector2;
  62505. /** Defines the end point of the arc */
  62506. endPoint: Vector2;
  62507. /**
  62508. * Defines the center point of the arc.
  62509. */
  62510. centerPoint: Vector2;
  62511. /**
  62512. * Defines the radius of the arc.
  62513. */
  62514. radius: number;
  62515. /**
  62516. * Defines the angle of the arc (from mid point to end point).
  62517. */
  62518. angle: Angle;
  62519. /**
  62520. * Defines the start angle of the arc (from start point to middle point).
  62521. */
  62522. startAngle: Angle;
  62523. /**
  62524. * Defines the orientation of the arc (clock wise/counter clock wise).
  62525. */
  62526. orientation: Orientation;
  62527. /**
  62528. * Creates an Arc object from the three given points : start, middle and end.
  62529. * @param startPoint Defines the start point of the arc
  62530. * @param midPoint Defines the midlle point of the arc
  62531. * @param endPoint Defines the end point of the arc
  62532. */
  62533. constructor(
  62534. /** Defines the start point of the arc */
  62535. startPoint: Vector2,
  62536. /** Defines the mid point of the arc */
  62537. midPoint: Vector2,
  62538. /** Defines the end point of the arc */
  62539. endPoint: Vector2);
  62540. }
  62541. /**
  62542. * Represents a 2D path made up of multiple 2D points
  62543. */
  62544. export class Path2 {
  62545. private _points;
  62546. private _length;
  62547. /**
  62548. * If the path start and end point are the same
  62549. */
  62550. closed: boolean;
  62551. /**
  62552. * Creates a Path2 object from the starting 2D coordinates x and y.
  62553. * @param x the starting points x value
  62554. * @param y the starting points y value
  62555. */
  62556. constructor(x: number, y: number);
  62557. /**
  62558. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  62559. * @param x the added points x value
  62560. * @param y the added points y value
  62561. * @returns the updated Path2.
  62562. */
  62563. addLineTo(x: number, y: number): Path2;
  62564. /**
  62565. * 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.
  62566. * @param midX middle point x value
  62567. * @param midY middle point y value
  62568. * @param endX end point x value
  62569. * @param endY end point y value
  62570. * @param numberOfSegments (default: 36)
  62571. * @returns the updated Path2.
  62572. */
  62573. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  62574. /**
  62575. * Closes the Path2.
  62576. * @returns the Path2.
  62577. */
  62578. close(): Path2;
  62579. /**
  62580. * Gets the sum of the distance between each sequential point in the path
  62581. * @returns the Path2 total length (float).
  62582. */
  62583. length(): number;
  62584. /**
  62585. * Gets the points which construct the path
  62586. * @returns the Path2 internal array of points.
  62587. */
  62588. getPoints(): Vector2[];
  62589. /**
  62590. * Retreives the point at the distance aways from the starting point
  62591. * @param normalizedLengthPosition the length along the path to retreive the point from
  62592. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  62593. */
  62594. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  62595. /**
  62596. * Creates a new path starting from an x and y position
  62597. * @param x starting x value
  62598. * @param y starting y value
  62599. * @returns a new Path2 starting at the coordinates (x, y).
  62600. */
  62601. static StartingAt(x: number, y: number): Path2;
  62602. }
  62603. /**
  62604. * Represents a 3D path made up of multiple 3D points
  62605. */
  62606. export class Path3D {
  62607. /**
  62608. * an array of Vector3, the curve axis of the Path3D
  62609. */
  62610. path: Vector3[];
  62611. private _curve;
  62612. private _distances;
  62613. private _tangents;
  62614. private _normals;
  62615. private _binormals;
  62616. private _raw;
  62617. /**
  62618. * new Path3D(path, normal, raw)
  62619. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  62620. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  62621. * @param path an array of Vector3, the curve axis of the Path3D
  62622. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  62623. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  62624. */
  62625. constructor(
  62626. /**
  62627. * an array of Vector3, the curve axis of the Path3D
  62628. */
  62629. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  62630. /**
  62631. * Returns the Path3D array of successive Vector3 designing its curve.
  62632. * @returns the Path3D array of successive Vector3 designing its curve.
  62633. */
  62634. getCurve(): Vector3[];
  62635. /**
  62636. * Returns an array populated with tangent vectors on each Path3D curve point.
  62637. * @returns an array populated with tangent vectors on each Path3D curve point.
  62638. */
  62639. getTangents(): Vector3[];
  62640. /**
  62641. * Returns an array populated with normal vectors on each Path3D curve point.
  62642. * @returns an array populated with normal vectors on each Path3D curve point.
  62643. */
  62644. getNormals(): Vector3[];
  62645. /**
  62646. * Returns an array populated with binormal vectors on each Path3D curve point.
  62647. * @returns an array populated with binormal vectors on each Path3D curve point.
  62648. */
  62649. getBinormals(): Vector3[];
  62650. /**
  62651. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  62652. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  62653. */
  62654. getDistances(): number[];
  62655. /**
  62656. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  62657. * @param path path which all values are copied into the curves points
  62658. * @param firstNormal which should be projected onto the curve
  62659. * @returns the same object updated.
  62660. */
  62661. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  62662. private _compute;
  62663. private _getFirstNonNullVector;
  62664. private _getLastNonNullVector;
  62665. private _normalVector;
  62666. }
  62667. /**
  62668. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62669. * A Curve3 is designed from a series of successive Vector3.
  62670. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  62671. */
  62672. export class Curve3 {
  62673. private _points;
  62674. private _length;
  62675. /**
  62676. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  62677. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  62678. * @param v1 (Vector3) the control point
  62679. * @param v2 (Vector3) the end point of the Quadratic Bezier
  62680. * @param nbPoints (integer) the wanted number of points in the curve
  62681. * @returns the created Curve3
  62682. */
  62683. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62684. /**
  62685. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  62686. * @param v0 (Vector3) the origin point of the Cubic Bezier
  62687. * @param v1 (Vector3) the first control point
  62688. * @param v2 (Vector3) the second control point
  62689. * @param v3 (Vector3) the end point of the Cubic Bezier
  62690. * @param nbPoints (integer) the wanted number of points in the curve
  62691. * @returns the created Curve3
  62692. */
  62693. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62694. /**
  62695. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  62696. * @param p1 (Vector3) the origin point of the Hermite Spline
  62697. * @param t1 (Vector3) the tangent vector at the origin point
  62698. * @param p2 (Vector3) the end point of the Hermite Spline
  62699. * @param t2 (Vector3) the tangent vector at the end point
  62700. * @param nbPoints (integer) the wanted number of points in the curve
  62701. * @returns the created Curve3
  62702. */
  62703. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62704. /**
  62705. * Returns a Curve3 object along a CatmullRom Spline curve :
  62706. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  62707. * @param nbPoints (integer) the wanted number of points between each curve control points
  62708. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  62709. * @returns the created Curve3
  62710. */
  62711. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  62712. /**
  62713. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62714. * A Curve3 is designed from a series of successive Vector3.
  62715. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  62716. * @param points points which make up the curve
  62717. */
  62718. constructor(points: Vector3[]);
  62719. /**
  62720. * @returns the Curve3 stored array of successive Vector3
  62721. */
  62722. getPoints(): Vector3[];
  62723. /**
  62724. * @returns the computed length (float) of the curve.
  62725. */
  62726. length(): number;
  62727. /**
  62728. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  62729. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  62730. * curveA and curveB keep unchanged.
  62731. * @param curve the curve to continue from this curve
  62732. * @returns the newly constructed curve
  62733. */
  62734. continue(curve: DeepImmutable<Curve3>): Curve3;
  62735. private _computeLength;
  62736. }
  62737. /**
  62738. * Contains position and normal vectors for a vertex
  62739. */
  62740. export class PositionNormalVertex {
  62741. /** the position of the vertex (defaut: 0,0,0) */
  62742. position: Vector3;
  62743. /** the normal of the vertex (defaut: 0,1,0) */
  62744. normal: Vector3;
  62745. /**
  62746. * Creates a PositionNormalVertex
  62747. * @param position the position of the vertex (defaut: 0,0,0)
  62748. * @param normal the normal of the vertex (defaut: 0,1,0)
  62749. */
  62750. constructor(
  62751. /** the position of the vertex (defaut: 0,0,0) */
  62752. position?: Vector3,
  62753. /** the normal of the vertex (defaut: 0,1,0) */
  62754. normal?: Vector3);
  62755. /**
  62756. * Clones the PositionNormalVertex
  62757. * @returns the cloned PositionNormalVertex
  62758. */
  62759. clone(): PositionNormalVertex;
  62760. }
  62761. /**
  62762. * Contains position, normal and uv vectors for a vertex
  62763. */
  62764. export class PositionNormalTextureVertex {
  62765. /** the position of the vertex (defaut: 0,0,0) */
  62766. position: Vector3;
  62767. /** the normal of the vertex (defaut: 0,1,0) */
  62768. normal: Vector3;
  62769. /** the uv of the vertex (default: 0,0) */
  62770. uv: Vector2;
  62771. /**
  62772. * Creates a PositionNormalTextureVertex
  62773. * @param position the position of the vertex (defaut: 0,0,0)
  62774. * @param normal the normal of the vertex (defaut: 0,1,0)
  62775. * @param uv the uv of the vertex (default: 0,0)
  62776. */
  62777. constructor(
  62778. /** the position of the vertex (defaut: 0,0,0) */
  62779. position?: Vector3,
  62780. /** the normal of the vertex (defaut: 0,1,0) */
  62781. normal?: Vector3,
  62782. /** the uv of the vertex (default: 0,0) */
  62783. uv?: Vector2);
  62784. /**
  62785. * Clones the PositionNormalTextureVertex
  62786. * @returns the cloned PositionNormalTextureVertex
  62787. */
  62788. clone(): PositionNormalTextureVertex;
  62789. }
  62790. /**
  62791. * @hidden
  62792. */
  62793. export class Tmp {
  62794. static Color3: Color3[];
  62795. static Color4: Color4[];
  62796. static Vector2: Vector2[];
  62797. static Vector3: Vector3[];
  62798. static Vector4: Vector4[];
  62799. static Quaternion: Quaternion[];
  62800. static Matrix: Matrix[];
  62801. }
  62802. }
  62803. declare module BABYLON {
  62804. /**
  62805. * Class used to enable access to offline support
  62806. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62807. */
  62808. export interface IOfflineProvider {
  62809. /**
  62810. * Gets a boolean indicating if scene must be saved in the database
  62811. */
  62812. enableSceneOffline: boolean;
  62813. /**
  62814. * Gets a boolean indicating if textures must be saved in the database
  62815. */
  62816. enableTexturesOffline: boolean;
  62817. /**
  62818. * Open the offline support and make it available
  62819. * @param successCallback defines the callback to call on success
  62820. * @param errorCallback defines the callback to call on error
  62821. */
  62822. open(successCallback: () => void, errorCallback: () => void): void;
  62823. /**
  62824. * Loads an image from the offline support
  62825. * @param url defines the url to load from
  62826. * @param image defines the target DOM image
  62827. */
  62828. loadImage(url: string, image: HTMLImageElement): void;
  62829. /**
  62830. * Loads a file from offline support
  62831. * @param url defines the URL to load from
  62832. * @param sceneLoaded defines a callback to call on success
  62833. * @param progressCallBack defines a callback to call when progress changed
  62834. * @param errorCallback defines a callback to call on error
  62835. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62836. */
  62837. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62838. }
  62839. }
  62840. declare module BABYLON {
  62841. /**
  62842. * A class serves as a medium between the observable and its observers
  62843. */
  62844. export class EventState {
  62845. /**
  62846. * Create a new EventState
  62847. * @param mask defines the mask associated with this state
  62848. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62849. * @param target defines the original target of the state
  62850. * @param currentTarget defines the current target of the state
  62851. */
  62852. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62853. /**
  62854. * Initialize the current event state
  62855. * @param mask defines the mask associated with this state
  62856. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62857. * @param target defines the original target of the state
  62858. * @param currentTarget defines the current target of the state
  62859. * @returns the current event state
  62860. */
  62861. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  62862. /**
  62863. * An Observer can set this property to true to prevent subsequent observers of being notified
  62864. */
  62865. skipNextObservers: boolean;
  62866. /**
  62867. * Get the mask value that were used to trigger the event corresponding to this EventState object
  62868. */
  62869. mask: number;
  62870. /**
  62871. * The object that originally notified the event
  62872. */
  62873. target?: any;
  62874. /**
  62875. * The current object in the bubbling phase
  62876. */
  62877. currentTarget?: any;
  62878. /**
  62879. * This will be populated with the return value of the last function that was executed.
  62880. * If it is the first function in the callback chain it will be the event data.
  62881. */
  62882. lastReturnValue?: any;
  62883. }
  62884. /**
  62885. * Represent an Observer registered to a given Observable object.
  62886. */
  62887. export class Observer<T> {
  62888. /**
  62889. * Defines the callback to call when the observer is notified
  62890. */
  62891. callback: (eventData: T, eventState: EventState) => void;
  62892. /**
  62893. * Defines the mask of the observer (used to filter notifications)
  62894. */
  62895. mask: number;
  62896. /**
  62897. * Defines the current scope used to restore the JS context
  62898. */
  62899. scope: any;
  62900. /** @hidden */
  62901. _willBeUnregistered: boolean;
  62902. /**
  62903. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62904. */
  62905. unregisterOnNextCall: boolean;
  62906. /**
  62907. * Creates a new observer
  62908. * @param callback defines the callback to call when the observer is notified
  62909. * @param mask defines the mask of the observer (used to filter notifications)
  62910. * @param scope defines the current scope used to restore the JS context
  62911. */
  62912. constructor(
  62913. /**
  62914. * Defines the callback to call when the observer is notified
  62915. */
  62916. callback: (eventData: T, eventState: EventState) => void,
  62917. /**
  62918. * Defines the mask of the observer (used to filter notifications)
  62919. */
  62920. mask: number,
  62921. /**
  62922. * Defines the current scope used to restore the JS context
  62923. */
  62924. scope?: any);
  62925. }
  62926. /**
  62927. * Represent a list of observers registered to multiple Observables object.
  62928. */
  62929. export class MultiObserver<T> {
  62930. private _observers;
  62931. private _observables;
  62932. /**
  62933. * Release associated resources
  62934. */
  62935. dispose(): void;
  62936. /**
  62937. * Raise a callback when one of the observable will notify
  62938. * @param observables defines a list of observables to watch
  62939. * @param callback defines the callback to call on notification
  62940. * @param mask defines the mask used to filter notifications
  62941. * @param scope defines the current scope used to restore the JS context
  62942. * @returns the new MultiObserver
  62943. */
  62944. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62945. }
  62946. /**
  62947. * The Observable class is a simple implementation of the Observable pattern.
  62948. *
  62949. * 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.
  62950. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62951. * 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).
  62952. * 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.
  62953. */
  62954. export class Observable<T> {
  62955. private _observers;
  62956. private _eventState;
  62957. private _onObserverAdded;
  62958. /**
  62959. * Creates a new observable
  62960. * @param onObserverAdded defines a callback to call when a new observer is added
  62961. */
  62962. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62963. /**
  62964. * Create a new Observer with the specified callback
  62965. * @param callback the callback that will be executed for that Observer
  62966. * @param mask the mask used to filter observers
  62967. * @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.
  62968. * @param scope optional scope for the callback to be called from
  62969. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62970. * @returns the new observer created for the callback
  62971. */
  62972. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62973. /**
  62974. * Create a new Observer with the specified callback and unregisters after the next notification
  62975. * @param callback the callback that will be executed for that Observer
  62976. * @returns the new observer created for the callback
  62977. */
  62978. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62979. /**
  62980. * Remove an Observer from the Observable object
  62981. * @param observer the instance of the Observer to remove
  62982. * @returns false if it doesn't belong to this Observable
  62983. */
  62984. remove(observer: Nullable<Observer<T>>): boolean;
  62985. /**
  62986. * Remove a callback from the Observable object
  62987. * @param callback the callback to remove
  62988. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62989. * @returns false if it doesn't belong to this Observable
  62990. */
  62991. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62992. private _deferUnregister;
  62993. private _remove;
  62994. /**
  62995. * Moves the observable to the top of the observer list making it get called first when notified
  62996. * @param observer the observer to move
  62997. */
  62998. makeObserverTopPriority(observer: Observer<T>): void;
  62999. /**
  63000. * Moves the observable to the bottom of the observer list making it get called last when notified
  63001. * @param observer the observer to move
  63002. */
  63003. makeObserverBottomPriority(observer: Observer<T>): void;
  63004. /**
  63005. * Notify all Observers by calling their respective callback with the given data
  63006. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63007. * @param eventData defines the data to send to all observers
  63008. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63009. * @param target defines the original target of the state
  63010. * @param currentTarget defines the current target of the state
  63011. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63012. */
  63013. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63014. /**
  63015. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63016. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63017. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63018. * and it is crucial that all callbacks will be executed.
  63019. * The order of the callbacks is kept, callbacks are not executed parallel.
  63020. *
  63021. * @param eventData The data to be sent to each callback
  63022. * @param mask is used to filter observers defaults to -1
  63023. * @param target defines the callback target (see EventState)
  63024. * @param currentTarget defines he current object in the bubbling phase
  63025. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63026. */
  63027. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63028. /**
  63029. * Notify a specific observer
  63030. * @param observer defines the observer to notify
  63031. * @param eventData defines the data to be sent to each callback
  63032. * @param mask is used to filter observers defaults to -1
  63033. */
  63034. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63035. /**
  63036. * Gets a boolean indicating if the observable has at least one observer
  63037. * @returns true is the Observable has at least one Observer registered
  63038. */
  63039. hasObservers(): boolean;
  63040. /**
  63041. * Clear the list of observers
  63042. */
  63043. clear(): void;
  63044. /**
  63045. * Clone the current observable
  63046. * @returns a new observable
  63047. */
  63048. clone(): Observable<T>;
  63049. /**
  63050. * Does this observable handles observer registered with a given mask
  63051. * @param mask defines the mask to be tested
  63052. * @return whether or not one observer registered with the given mask is handeled
  63053. **/
  63054. hasSpecificMask(mask?: number): boolean;
  63055. }
  63056. }
  63057. declare module BABYLON {
  63058. /**
  63059. * Class used to help managing file picking and drag'n'drop
  63060. * File Storage
  63061. */
  63062. export class FilesInputStore {
  63063. /**
  63064. * List of files ready to be loaded
  63065. */
  63066. static FilesToLoad: {
  63067. [key: string]: File;
  63068. };
  63069. }
  63070. }
  63071. declare module BABYLON {
  63072. /** Defines the cross module used constants to avoid circular dependncies */
  63073. export class Constants {
  63074. /** Defines that alpha blending is disabled */
  63075. static readonly ALPHA_DISABLE: number;
  63076. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63077. static readonly ALPHA_ADD: number;
  63078. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63079. static readonly ALPHA_COMBINE: number;
  63080. /** Defines that alpha blending to DEST - SRC * DEST */
  63081. static readonly ALPHA_SUBTRACT: number;
  63082. /** Defines that alpha blending to SRC * DEST */
  63083. static readonly ALPHA_MULTIPLY: number;
  63084. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63085. static readonly ALPHA_MAXIMIZED: number;
  63086. /** Defines that alpha blending to SRC + DEST */
  63087. static readonly ALPHA_ONEONE: number;
  63088. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63089. static readonly ALPHA_PREMULTIPLIED: number;
  63090. /**
  63091. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63092. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63093. */
  63094. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63095. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63096. static readonly ALPHA_INTERPOLATE: number;
  63097. /**
  63098. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63099. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63100. */
  63101. static readonly ALPHA_SCREENMODE: number;
  63102. /** Defines that the ressource is not delayed*/
  63103. static readonly DELAYLOADSTATE_NONE: number;
  63104. /** Defines that the ressource was successfully delay loaded */
  63105. static readonly DELAYLOADSTATE_LOADED: number;
  63106. /** Defines that the ressource is currently delay loading */
  63107. static readonly DELAYLOADSTATE_LOADING: number;
  63108. /** Defines that the ressource is delayed and has not started loading */
  63109. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63110. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63111. static readonly NEVER: number;
  63112. /** 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 */
  63113. static readonly ALWAYS: number;
  63114. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63115. static readonly LESS: number;
  63116. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63117. static readonly EQUAL: number;
  63118. /** 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 */
  63119. static readonly LEQUAL: number;
  63120. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63121. static readonly GREATER: number;
  63122. /** 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 */
  63123. static readonly GEQUAL: number;
  63124. /** 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 */
  63125. static readonly NOTEQUAL: number;
  63126. /** Passed to stencilOperation to specify that stencil value must be kept */
  63127. static readonly KEEP: number;
  63128. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63129. static readonly REPLACE: number;
  63130. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63131. static readonly INCR: number;
  63132. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63133. static readonly DECR: number;
  63134. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63135. static readonly INVERT: number;
  63136. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63137. static readonly INCR_WRAP: number;
  63138. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63139. static readonly DECR_WRAP: number;
  63140. /** Texture is not repeating outside of 0..1 UVs */
  63141. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63142. /** Texture is repeating outside of 0..1 UVs */
  63143. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63144. /** Texture is repeating and mirrored */
  63145. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63146. /** ALPHA */
  63147. static readonly TEXTUREFORMAT_ALPHA: number;
  63148. /** LUMINANCE */
  63149. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63150. /** LUMINANCE_ALPHA */
  63151. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63152. /** RGB */
  63153. static readonly TEXTUREFORMAT_RGB: number;
  63154. /** RGBA */
  63155. static readonly TEXTUREFORMAT_RGBA: number;
  63156. /** RED */
  63157. static readonly TEXTUREFORMAT_RED: number;
  63158. /** RED (2nd reference) */
  63159. static readonly TEXTUREFORMAT_R: number;
  63160. /** RG */
  63161. static readonly TEXTUREFORMAT_RG: number;
  63162. /** RED_INTEGER */
  63163. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63164. /** RED_INTEGER (2nd reference) */
  63165. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63166. /** RG_INTEGER */
  63167. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63168. /** RGB_INTEGER */
  63169. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63170. /** RGBA_INTEGER */
  63171. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63172. /** UNSIGNED_BYTE */
  63173. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63174. /** UNSIGNED_BYTE (2nd reference) */
  63175. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63176. /** FLOAT */
  63177. static readonly TEXTURETYPE_FLOAT: number;
  63178. /** HALF_FLOAT */
  63179. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63180. /** BYTE */
  63181. static readonly TEXTURETYPE_BYTE: number;
  63182. /** SHORT */
  63183. static readonly TEXTURETYPE_SHORT: number;
  63184. /** UNSIGNED_SHORT */
  63185. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63186. /** INT */
  63187. static readonly TEXTURETYPE_INT: number;
  63188. /** UNSIGNED_INT */
  63189. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63190. /** UNSIGNED_SHORT_4_4_4_4 */
  63191. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63192. /** UNSIGNED_SHORT_5_5_5_1 */
  63193. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63194. /** UNSIGNED_SHORT_5_6_5 */
  63195. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63196. /** UNSIGNED_INT_2_10_10_10_REV */
  63197. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63198. /** UNSIGNED_INT_24_8 */
  63199. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63200. /** UNSIGNED_INT_10F_11F_11F_REV */
  63201. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63202. /** UNSIGNED_INT_5_9_9_9_REV */
  63203. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63204. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63205. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63206. /** nearest is mag = nearest and min = nearest and mip = linear */
  63207. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63208. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63209. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63210. /** Trilinear is mag = linear and min = linear and mip = linear */
  63211. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63212. /** nearest is mag = nearest and min = nearest and mip = linear */
  63213. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63214. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63215. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63216. /** Trilinear is mag = linear and min = linear and mip = linear */
  63217. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63218. /** mag = nearest and min = nearest and mip = nearest */
  63219. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63220. /** mag = nearest and min = linear and mip = nearest */
  63221. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63222. /** mag = nearest and min = linear and mip = linear */
  63223. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63224. /** mag = nearest and min = linear and mip = none */
  63225. static readonly TEXTURE_NEAREST_LINEAR: number;
  63226. /** mag = nearest and min = nearest and mip = none */
  63227. static readonly TEXTURE_NEAREST_NEAREST: number;
  63228. /** mag = linear and min = nearest and mip = nearest */
  63229. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63230. /** mag = linear and min = nearest and mip = linear */
  63231. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63232. /** mag = linear and min = linear and mip = none */
  63233. static readonly TEXTURE_LINEAR_LINEAR: number;
  63234. /** mag = linear and min = nearest and mip = none */
  63235. static readonly TEXTURE_LINEAR_NEAREST: number;
  63236. /** Explicit coordinates mode */
  63237. static readonly TEXTURE_EXPLICIT_MODE: number;
  63238. /** Spherical coordinates mode */
  63239. static readonly TEXTURE_SPHERICAL_MODE: number;
  63240. /** Planar coordinates mode */
  63241. static readonly TEXTURE_PLANAR_MODE: number;
  63242. /** Cubic coordinates mode */
  63243. static readonly TEXTURE_CUBIC_MODE: number;
  63244. /** Projection coordinates mode */
  63245. static readonly TEXTURE_PROJECTION_MODE: number;
  63246. /** Skybox coordinates mode */
  63247. static readonly TEXTURE_SKYBOX_MODE: number;
  63248. /** Inverse Cubic coordinates mode */
  63249. static readonly TEXTURE_INVCUBIC_MODE: number;
  63250. /** Equirectangular coordinates mode */
  63251. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63252. /** Equirectangular Fixed coordinates mode */
  63253. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63254. /** Equirectangular Fixed Mirrored coordinates mode */
  63255. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63256. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63257. static readonly SCALEMODE_FLOOR: number;
  63258. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63259. static readonly SCALEMODE_NEAREST: number;
  63260. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63261. static readonly SCALEMODE_CEILING: number;
  63262. /**
  63263. * The dirty texture flag value
  63264. */
  63265. static readonly MATERIAL_TextureDirtyFlag: number;
  63266. /**
  63267. * The dirty light flag value
  63268. */
  63269. static readonly MATERIAL_LightDirtyFlag: number;
  63270. /**
  63271. * The dirty fresnel flag value
  63272. */
  63273. static readonly MATERIAL_FresnelDirtyFlag: number;
  63274. /**
  63275. * The dirty attribute flag value
  63276. */
  63277. static readonly MATERIAL_AttributesDirtyFlag: number;
  63278. /**
  63279. * The dirty misc flag value
  63280. */
  63281. static readonly MATERIAL_MiscDirtyFlag: number;
  63282. /**
  63283. * The all dirty flag value
  63284. */
  63285. static readonly MATERIAL_AllDirtyFlag: number;
  63286. /**
  63287. * Returns the triangle fill mode
  63288. */
  63289. static readonly MATERIAL_TriangleFillMode: number;
  63290. /**
  63291. * Returns the wireframe mode
  63292. */
  63293. static readonly MATERIAL_WireFrameFillMode: number;
  63294. /**
  63295. * Returns the point fill mode
  63296. */
  63297. static readonly MATERIAL_PointFillMode: number;
  63298. /**
  63299. * Returns the point list draw mode
  63300. */
  63301. static readonly MATERIAL_PointListDrawMode: number;
  63302. /**
  63303. * Returns the line list draw mode
  63304. */
  63305. static readonly MATERIAL_LineListDrawMode: number;
  63306. /**
  63307. * Returns the line loop draw mode
  63308. */
  63309. static readonly MATERIAL_LineLoopDrawMode: number;
  63310. /**
  63311. * Returns the line strip draw mode
  63312. */
  63313. static readonly MATERIAL_LineStripDrawMode: number;
  63314. /**
  63315. * Returns the triangle strip draw mode
  63316. */
  63317. static readonly MATERIAL_TriangleStripDrawMode: number;
  63318. /**
  63319. * Returns the triangle fan draw mode
  63320. */
  63321. static readonly MATERIAL_TriangleFanDrawMode: number;
  63322. /**
  63323. * Stores the clock-wise side orientation
  63324. */
  63325. static readonly MATERIAL_ClockWiseSideOrientation: number;
  63326. /**
  63327. * Stores the counter clock-wise side orientation
  63328. */
  63329. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  63330. /**
  63331. * Nothing
  63332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63333. */
  63334. static readonly ACTION_NothingTrigger: number;
  63335. /**
  63336. * On pick
  63337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63338. */
  63339. static readonly ACTION_OnPickTrigger: number;
  63340. /**
  63341. * On left pick
  63342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63343. */
  63344. static readonly ACTION_OnLeftPickTrigger: number;
  63345. /**
  63346. * On right pick
  63347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63348. */
  63349. static readonly ACTION_OnRightPickTrigger: number;
  63350. /**
  63351. * On center pick
  63352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63353. */
  63354. static readonly ACTION_OnCenterPickTrigger: number;
  63355. /**
  63356. * On pick down
  63357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63358. */
  63359. static readonly ACTION_OnPickDownTrigger: number;
  63360. /**
  63361. * On double pick
  63362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63363. */
  63364. static readonly ACTION_OnDoublePickTrigger: number;
  63365. /**
  63366. * On pick up
  63367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63368. */
  63369. static readonly ACTION_OnPickUpTrigger: number;
  63370. /**
  63371. * On pick out.
  63372. * This trigger will only be raised if you also declared a OnPickDown
  63373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63374. */
  63375. static readonly ACTION_OnPickOutTrigger: number;
  63376. /**
  63377. * On long press
  63378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63379. */
  63380. static readonly ACTION_OnLongPressTrigger: number;
  63381. /**
  63382. * On pointer over
  63383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63384. */
  63385. static readonly ACTION_OnPointerOverTrigger: number;
  63386. /**
  63387. * On pointer out
  63388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63389. */
  63390. static readonly ACTION_OnPointerOutTrigger: number;
  63391. /**
  63392. * On every frame
  63393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63394. */
  63395. static readonly ACTION_OnEveryFrameTrigger: number;
  63396. /**
  63397. * On intersection enter
  63398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63399. */
  63400. static readonly ACTION_OnIntersectionEnterTrigger: number;
  63401. /**
  63402. * On intersection exit
  63403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63404. */
  63405. static readonly ACTION_OnIntersectionExitTrigger: number;
  63406. /**
  63407. * On key down
  63408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63409. */
  63410. static readonly ACTION_OnKeyDownTrigger: number;
  63411. /**
  63412. * On key up
  63413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63414. */
  63415. static readonly ACTION_OnKeyUpTrigger: number;
  63416. /**
  63417. * Billboard mode will only apply to Y axis
  63418. */
  63419. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  63420. /**
  63421. * Billboard mode will apply to all axes
  63422. */
  63423. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  63424. /**
  63425. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  63426. */
  63427. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  63428. /**
  63429. * Gets or sets base Assets URL
  63430. */
  63431. static readonly PARTICLES_BaseAssetsUrl: string;
  63432. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  63433. * Test order :
  63434. * Is the bounding sphere outside the frustum ?
  63435. * If not, are the bounding box vertices outside the frustum ?
  63436. * It not, then the cullable object is in the frustum.
  63437. */
  63438. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  63439. /** Culling strategy : Bounding Sphere Only.
  63440. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  63441. * It's also less accurate than the standard because some not visible objects can still be selected.
  63442. * Test : is the bounding sphere outside the frustum ?
  63443. * If not, then the cullable object is in the frustum.
  63444. */
  63445. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  63446. /** Culling strategy : Optimistic Inclusion.
  63447. * This in an inclusion test first, then the standard exclusion test.
  63448. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  63449. * 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.
  63450. * Anyway, it's as accurate as the standard strategy.
  63451. * Test :
  63452. * Is the cullable object bounding sphere center in the frustum ?
  63453. * If not, apply the default culling strategy.
  63454. */
  63455. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  63456. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  63457. * This in an inclusion test first, then the bounding sphere only exclusion test.
  63458. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  63459. * 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.
  63460. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  63461. * Test :
  63462. * Is the cullable object bounding sphere center in the frustum ?
  63463. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  63464. */
  63465. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  63466. /**
  63467. * No logging while loading
  63468. */
  63469. static readonly SCENELOADER_NO_LOGGING: number;
  63470. /**
  63471. * Minimal logging while loading
  63472. */
  63473. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  63474. /**
  63475. * Summary logging while loading
  63476. */
  63477. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  63478. /**
  63479. * Detailled logging while loading
  63480. */
  63481. static readonly SCENELOADER_DETAILED_LOGGING: number;
  63482. }
  63483. }
  63484. declare module BABYLON {
  63485. /**
  63486. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63487. * Babylon.js
  63488. */
  63489. export class DomManagement {
  63490. /**
  63491. * Checks if the window object exists
  63492. * @returns true if the window object exists
  63493. */
  63494. static IsWindowObjectExist(): boolean;
  63495. /**
  63496. * Extracts text content from a DOM element hierarchy
  63497. * @param element defines the root element
  63498. * @returns a string
  63499. */
  63500. static GetDOMTextContent(element: HTMLElement): string;
  63501. }
  63502. }
  63503. declare module BABYLON {
  63504. /**
  63505. * Logger used througouht the application to allow configuration of
  63506. * the log level required for the messages.
  63507. */
  63508. export class Logger {
  63509. /**
  63510. * No log
  63511. */
  63512. static readonly NoneLogLevel: number;
  63513. /**
  63514. * Only message logs
  63515. */
  63516. static readonly MessageLogLevel: number;
  63517. /**
  63518. * Only warning logs
  63519. */
  63520. static readonly WarningLogLevel: number;
  63521. /**
  63522. * Only error logs
  63523. */
  63524. static readonly ErrorLogLevel: number;
  63525. /**
  63526. * All logs
  63527. */
  63528. static readonly AllLogLevel: number;
  63529. private static _LogCache;
  63530. /**
  63531. * Gets a value indicating the number of loading errors
  63532. * @ignorenaming
  63533. */
  63534. static errorsCount: number;
  63535. /**
  63536. * Callback called when a new log is added
  63537. */
  63538. static OnNewCacheEntry: (entry: string) => void;
  63539. private static _AddLogEntry;
  63540. private static _FormatMessage;
  63541. private static _LogDisabled;
  63542. private static _LogEnabled;
  63543. private static _WarnDisabled;
  63544. private static _WarnEnabled;
  63545. private static _ErrorDisabled;
  63546. private static _ErrorEnabled;
  63547. /**
  63548. * Log a message to the console
  63549. */
  63550. static Log: (message: string) => void;
  63551. /**
  63552. * Write a warning message to the console
  63553. */
  63554. static Warn: (message: string) => void;
  63555. /**
  63556. * Write an error message to the console
  63557. */
  63558. static Error: (message: string) => void;
  63559. /**
  63560. * Gets current log cache (list of logs)
  63561. */
  63562. static readonly LogCache: string;
  63563. /**
  63564. * Clears the log cache
  63565. */
  63566. static ClearLogCache(): void;
  63567. /**
  63568. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  63569. */
  63570. static LogLevels: number;
  63571. }
  63572. }
  63573. declare module BABYLON {
  63574. /** @hidden */
  63575. export class _TypeStore {
  63576. /** @hidden */
  63577. static RegisteredTypes: {
  63578. [key: string]: Object;
  63579. };
  63580. /** @hidden */
  63581. static GetClass(fqdn: string): any;
  63582. }
  63583. }
  63584. declare module BABYLON {
  63585. /**
  63586. * Class containing a set of static utilities functions for deep copy.
  63587. */
  63588. export class DeepCopier {
  63589. /**
  63590. * Tries to copy an object by duplicating every property
  63591. * @param source defines the source object
  63592. * @param destination defines the target object
  63593. * @param doNotCopyList defines a list of properties to avoid
  63594. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  63595. */
  63596. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  63597. }
  63598. }
  63599. declare module BABYLON {
  63600. /**
  63601. * Class containing a set of static utilities functions for precision date
  63602. */
  63603. export class PrecisionDate {
  63604. /**
  63605. * Gets either window.performance.now() if supported or Date.now() else
  63606. */
  63607. static readonly Now: number;
  63608. }
  63609. }
  63610. declare module BABYLON {
  63611. /** @hidden */
  63612. export class _DevTools {
  63613. static WarnImport(name: string): string;
  63614. }
  63615. }
  63616. declare module BABYLON {
  63617. /**
  63618. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  63619. */
  63620. export class WebRequest {
  63621. private _xhr;
  63622. /**
  63623. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  63624. * i.e. when loading files, where the server/service expects an Authorization header
  63625. */
  63626. static CustomRequestHeaders: {
  63627. [key: string]: string;
  63628. };
  63629. /**
  63630. * Add callback functions in this array to update all the requests before they get sent to the network
  63631. */
  63632. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  63633. private _injectCustomRequestHeaders;
  63634. /**
  63635. * Gets or sets a function to be called when loading progress changes
  63636. */
  63637. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  63638. /**
  63639. * Returns client's state
  63640. */
  63641. readonly readyState: number;
  63642. /**
  63643. * Returns client's status
  63644. */
  63645. readonly status: number;
  63646. /**
  63647. * Returns client's status as a text
  63648. */
  63649. readonly statusText: string;
  63650. /**
  63651. * Returns client's response
  63652. */
  63653. readonly response: any;
  63654. /**
  63655. * Returns client's response url
  63656. */
  63657. readonly responseURL: string;
  63658. /**
  63659. * Returns client's response as text
  63660. */
  63661. readonly responseText: string;
  63662. /**
  63663. * Gets or sets the expected response type
  63664. */
  63665. responseType: XMLHttpRequestResponseType;
  63666. /** @hidden */
  63667. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  63668. /** @hidden */
  63669. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  63670. /**
  63671. * Cancels any network activity
  63672. */
  63673. abort(): void;
  63674. /**
  63675. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  63676. * @param body defines an optional request body
  63677. */
  63678. send(body?: Document | BodyInit | null): void;
  63679. /**
  63680. * Sets the request method, request URL
  63681. * @param method defines the method to use (GET, POST, etc..)
  63682. * @param url defines the url to connect with
  63683. */
  63684. open(method: string, url: string): void;
  63685. }
  63686. }
  63687. declare module BABYLON {
  63688. /**
  63689. * Class used to evalaute queries containing `and` and `or` operators
  63690. */
  63691. export class AndOrNotEvaluator {
  63692. /**
  63693. * Evaluate a query
  63694. * @param query defines the query to evaluate
  63695. * @param evaluateCallback defines the callback used to filter result
  63696. * @returns true if the query matches
  63697. */
  63698. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  63699. private static _HandleParenthesisContent;
  63700. private static _SimplifyNegation;
  63701. }
  63702. }
  63703. declare module BABYLON {
  63704. /**
  63705. * Class used to store custom tags
  63706. */
  63707. export class Tags {
  63708. /**
  63709. * Adds support for tags on the given object
  63710. * @param obj defines the object to use
  63711. */
  63712. static EnableFor(obj: any): void;
  63713. /**
  63714. * Removes tags support
  63715. * @param obj defines the object to use
  63716. */
  63717. static DisableFor(obj: any): void;
  63718. /**
  63719. * Gets a boolean indicating if the given object has tags
  63720. * @param obj defines the object to use
  63721. * @returns a boolean
  63722. */
  63723. static HasTags(obj: any): boolean;
  63724. /**
  63725. * Gets the tags available on a given object
  63726. * @param obj defines the object to use
  63727. * @param asString defines if the tags must be returned as a string instead of an array of strings
  63728. * @returns the tags
  63729. */
  63730. static GetTags(obj: any, asString?: boolean): any;
  63731. /**
  63732. * Adds tags to an object
  63733. * @param obj defines the object to use
  63734. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  63735. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  63736. */
  63737. static AddTagsTo(obj: any, tagsString: string): void;
  63738. /**
  63739. * @hidden
  63740. */
  63741. static _AddTagTo(obj: any, tag: string): void;
  63742. /**
  63743. * Removes specific tags from a specific object
  63744. * @param obj defines the object to use
  63745. * @param tagsString defines the tags to remove
  63746. */
  63747. static RemoveTagsFrom(obj: any, tagsString: string): void;
  63748. /**
  63749. * @hidden
  63750. */
  63751. static _RemoveTagFrom(obj: any, tag: string): void;
  63752. /**
  63753. * Defines if tags hosted on an object match a given query
  63754. * @param obj defines the object to use
  63755. * @param tagsQuery defines the tag query
  63756. * @returns a boolean
  63757. */
  63758. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  63759. }
  63760. }
  63761. declare module BABYLON {
  63762. /**
  63763. * Manages the defines for the Material
  63764. */
  63765. export class MaterialDefines {
  63766. private _keys;
  63767. private _isDirty;
  63768. /** @hidden */
  63769. _renderId: number;
  63770. /** @hidden */
  63771. _areLightsDirty: boolean;
  63772. /** @hidden */
  63773. _areAttributesDirty: boolean;
  63774. /** @hidden */
  63775. _areTexturesDirty: boolean;
  63776. /** @hidden */
  63777. _areFresnelDirty: boolean;
  63778. /** @hidden */
  63779. _areMiscDirty: boolean;
  63780. /** @hidden */
  63781. _areImageProcessingDirty: boolean;
  63782. /** @hidden */
  63783. _normals: boolean;
  63784. /** @hidden */
  63785. _uvs: boolean;
  63786. /** @hidden */
  63787. _needNormals: boolean;
  63788. /** @hidden */
  63789. _needUVs: boolean;
  63790. /**
  63791. * Specifies if the material needs to be re-calculated
  63792. */
  63793. readonly isDirty: boolean;
  63794. /**
  63795. * Marks the material to indicate that it has been re-calculated
  63796. */
  63797. markAsProcessed(): void;
  63798. /**
  63799. * Marks the material to indicate that it needs to be re-calculated
  63800. */
  63801. markAsUnprocessed(): void;
  63802. /**
  63803. * Marks the material to indicate all of its defines need to be re-calculated
  63804. */
  63805. markAllAsDirty(): void;
  63806. /**
  63807. * Marks the material to indicate that image processing needs to be re-calculated
  63808. */
  63809. markAsImageProcessingDirty(): void;
  63810. /**
  63811. * Marks the material to indicate the lights need to be re-calculated
  63812. */
  63813. markAsLightDirty(): void;
  63814. /**
  63815. * Marks the attribute state as changed
  63816. */
  63817. markAsAttributesDirty(): void;
  63818. /**
  63819. * Marks the texture state as changed
  63820. */
  63821. markAsTexturesDirty(): void;
  63822. /**
  63823. * Marks the fresnel state as changed
  63824. */
  63825. markAsFresnelDirty(): void;
  63826. /**
  63827. * Marks the misc state as changed
  63828. */
  63829. markAsMiscDirty(): void;
  63830. /**
  63831. * Rebuilds the material defines
  63832. */
  63833. rebuild(): void;
  63834. /**
  63835. * Specifies if two material defines are equal
  63836. * @param other - A material define instance to compare to
  63837. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63838. */
  63839. isEqual(other: MaterialDefines): boolean;
  63840. /**
  63841. * Clones this instance's defines to another instance
  63842. * @param other - material defines to clone values to
  63843. */
  63844. cloneTo(other: MaterialDefines): void;
  63845. /**
  63846. * Resets the material define values
  63847. */
  63848. reset(): void;
  63849. /**
  63850. * Converts the material define values to a string
  63851. * @returns - String of material define information
  63852. */
  63853. toString(): string;
  63854. }
  63855. }
  63856. declare module BABYLON {
  63857. /**
  63858. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  63859. */
  63860. export class PerformanceMonitor {
  63861. private _enabled;
  63862. private _rollingFrameTime;
  63863. private _lastFrameTimeMs;
  63864. /**
  63865. * constructor
  63866. * @param frameSampleSize The number of samples required to saturate the sliding window
  63867. */
  63868. constructor(frameSampleSize?: number);
  63869. /**
  63870. * Samples current frame
  63871. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  63872. */
  63873. sampleFrame(timeMs?: number): void;
  63874. /**
  63875. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63876. */
  63877. readonly averageFrameTime: number;
  63878. /**
  63879. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63880. */
  63881. readonly averageFrameTimeVariance: number;
  63882. /**
  63883. * Returns the frame time of the most recent frame
  63884. */
  63885. readonly instantaneousFrameTime: number;
  63886. /**
  63887. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63888. */
  63889. readonly averageFPS: number;
  63890. /**
  63891. * Returns the average framerate in frames per second using the most recent frame time
  63892. */
  63893. readonly instantaneousFPS: number;
  63894. /**
  63895. * Returns true if enough samples have been taken to completely fill the sliding window
  63896. */
  63897. readonly isSaturated: boolean;
  63898. /**
  63899. * Enables contributions to the sliding window sample set
  63900. */
  63901. enable(): void;
  63902. /**
  63903. * Disables contributions to the sliding window sample set
  63904. * Samples will not be interpolated over the disabled period
  63905. */
  63906. disable(): void;
  63907. /**
  63908. * Returns true if sampling is enabled
  63909. */
  63910. readonly isEnabled: boolean;
  63911. /**
  63912. * Resets performance monitor
  63913. */
  63914. reset(): void;
  63915. }
  63916. /**
  63917. * RollingAverage
  63918. *
  63919. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63920. */
  63921. export class RollingAverage {
  63922. /**
  63923. * Current average
  63924. */
  63925. average: number;
  63926. /**
  63927. * Current variance
  63928. */
  63929. variance: number;
  63930. protected _samples: Array<number>;
  63931. protected _sampleCount: number;
  63932. protected _pos: number;
  63933. protected _m2: number;
  63934. /**
  63935. * constructor
  63936. * @param length The number of samples required to saturate the sliding window
  63937. */
  63938. constructor(length: number);
  63939. /**
  63940. * Adds a sample to the sample set
  63941. * @param v The sample value
  63942. */
  63943. add(v: number): void;
  63944. /**
  63945. * Returns previously added values or null if outside of history or outside the sliding window domain
  63946. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63947. * @return Value previously recorded with add() or null if outside of range
  63948. */
  63949. history(i: number): number;
  63950. /**
  63951. * Returns true if enough samples have been taken to completely fill the sliding window
  63952. * @return true if sample-set saturated
  63953. */
  63954. isSaturated(): boolean;
  63955. /**
  63956. * Resets the rolling average (equivalent to 0 samples taken so far)
  63957. */
  63958. reset(): void;
  63959. /**
  63960. * Wraps a value around the sample range boundaries
  63961. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63962. * @return Wrapped position in sample range
  63963. */
  63964. protected _wrapPosition(i: number): number;
  63965. }
  63966. }
  63967. declare module BABYLON {
  63968. /**
  63969. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63970. * The underlying implementation relies on an associative array to ensure the best performances.
  63971. * The value can be anything including 'null' but except 'undefined'
  63972. */
  63973. export class StringDictionary<T> {
  63974. /**
  63975. * This will clear this dictionary and copy the content from the 'source' one.
  63976. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63977. * @param source the dictionary to take the content from and copy to this dictionary
  63978. */
  63979. copyFrom(source: StringDictionary<T>): void;
  63980. /**
  63981. * Get a value based from its key
  63982. * @param key the given key to get the matching value from
  63983. * @return the value if found, otherwise undefined is returned
  63984. */
  63985. get(key: string): T | undefined;
  63986. /**
  63987. * Get a value from its key or add it if it doesn't exist.
  63988. * This method will ensure you that a given key/data will be present in the dictionary.
  63989. * @param key the given key to get the matching value from
  63990. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63991. * The factory will only be invoked if there's no data for the given key.
  63992. * @return the value corresponding to the key.
  63993. */
  63994. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63995. /**
  63996. * Get a value from its key if present in the dictionary otherwise add it
  63997. * @param key the key to get the value from
  63998. * @param val if there's no such key/value pair in the dictionary add it with this value
  63999. * @return the value corresponding to the key
  64000. */
  64001. getOrAdd(key: string, val: T): T;
  64002. /**
  64003. * Check if there's a given key in the dictionary
  64004. * @param key the key to check for
  64005. * @return true if the key is present, false otherwise
  64006. */
  64007. contains(key: string): boolean;
  64008. /**
  64009. * Add a new key and its corresponding value
  64010. * @param key the key to add
  64011. * @param value the value corresponding to the key
  64012. * @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
  64013. */
  64014. add(key: string, value: T): boolean;
  64015. /**
  64016. * Update a specific value associated to a key
  64017. * @param key defines the key to use
  64018. * @param value defines the value to store
  64019. * @returns true if the value was updated (or false if the key was not found)
  64020. */
  64021. set(key: string, value: T): boolean;
  64022. /**
  64023. * Get the element of the given key and remove it from the dictionary
  64024. * @param key defines the key to search
  64025. * @returns the value associated with the key or null if not found
  64026. */
  64027. getAndRemove(key: string): Nullable<T>;
  64028. /**
  64029. * Remove a key/value from the dictionary.
  64030. * @param key the key to remove
  64031. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64032. */
  64033. remove(key: string): boolean;
  64034. /**
  64035. * Clear the whole content of the dictionary
  64036. */
  64037. clear(): void;
  64038. /**
  64039. * Gets the current count
  64040. */
  64041. readonly count: number;
  64042. /**
  64043. * Execute a callback on each key/val of the dictionary.
  64044. * Note that you can remove any element in this dictionary in the callback implementation
  64045. * @param callback the callback to execute on a given key/value pair
  64046. */
  64047. forEach(callback: (key: string, val: T) => void): void;
  64048. /**
  64049. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64050. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64051. * Note that you can remove any element in this dictionary in the callback implementation
  64052. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64053. * @returns the first item
  64054. */
  64055. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64056. private _count;
  64057. private _data;
  64058. }
  64059. }
  64060. declare module BABYLON {
  64061. /**
  64062. * Helper class that provides a small promise polyfill
  64063. */
  64064. export class PromisePolyfill {
  64065. /**
  64066. * Static function used to check if the polyfill is required
  64067. * If this is the case then the function will inject the polyfill to window.Promise
  64068. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64069. */
  64070. static Apply(force?: boolean): void;
  64071. }
  64072. }
  64073. declare module BABYLON {
  64074. /**
  64075. * Class used to store data that will be store in GPU memory
  64076. */
  64077. export class Buffer {
  64078. private _engine;
  64079. private _buffer;
  64080. /** @hidden */
  64081. _data: Nullable<DataArray>;
  64082. private _updatable;
  64083. private _instanced;
  64084. /**
  64085. * Gets the byte stride.
  64086. */
  64087. readonly byteStride: number;
  64088. /**
  64089. * Constructor
  64090. * @param engine the engine
  64091. * @param data the data to use for this buffer
  64092. * @param updatable whether the data is updatable
  64093. * @param stride the stride (optional)
  64094. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64095. * @param instanced whether the buffer is instanced (optional)
  64096. * @param useBytes set to true if the stride in in bytes (optional)
  64097. */
  64098. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64099. /**
  64100. * Create a new VertexBuffer based on the current buffer
  64101. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64102. * @param offset defines offset in the buffer (0 by default)
  64103. * @param size defines the size in floats of attributes (position is 3 for instance)
  64104. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64105. * @param instanced defines if the vertex buffer contains indexed data
  64106. * @param useBytes defines if the offset and stride are in bytes
  64107. * @returns the new vertex buffer
  64108. */
  64109. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64110. /**
  64111. * Gets a boolean indicating if the Buffer is updatable?
  64112. * @returns true if the buffer is updatable
  64113. */
  64114. isUpdatable(): boolean;
  64115. /**
  64116. * Gets current buffer's data
  64117. * @returns a DataArray or null
  64118. */
  64119. getData(): Nullable<DataArray>;
  64120. /**
  64121. * Gets underlying native buffer
  64122. * @returns underlying native buffer
  64123. */
  64124. getBuffer(): Nullable<WebGLBuffer>;
  64125. /**
  64126. * Gets the stride in float32 units (i.e. byte stride / 4).
  64127. * May not be an integer if the byte stride is not divisible by 4.
  64128. * DEPRECATED. Use byteStride instead.
  64129. * @returns the stride in float32 units
  64130. */
  64131. getStrideSize(): number;
  64132. /**
  64133. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64134. * @param data defines the data to store
  64135. */
  64136. create(data?: Nullable<DataArray>): void;
  64137. /** @hidden */
  64138. _rebuild(): void;
  64139. /**
  64140. * Update current buffer data
  64141. * @param data defines the data to store
  64142. */
  64143. update(data: DataArray): void;
  64144. /**
  64145. * Updates the data directly.
  64146. * @param data the new data
  64147. * @param offset the new offset
  64148. * @param vertexCount the vertex count (optional)
  64149. * @param useBytes set to true if the offset is in bytes
  64150. */
  64151. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64152. /**
  64153. * Release all resources
  64154. */
  64155. dispose(): void;
  64156. }
  64157. /**
  64158. * Specialized buffer used to store vertex data
  64159. */
  64160. export class VertexBuffer {
  64161. /** @hidden */
  64162. _buffer: Buffer;
  64163. private _kind;
  64164. private _size;
  64165. private _ownsBuffer;
  64166. private _instanced;
  64167. private _instanceDivisor;
  64168. /**
  64169. * The byte type.
  64170. */
  64171. static readonly BYTE: number;
  64172. /**
  64173. * The unsigned byte type.
  64174. */
  64175. static readonly UNSIGNED_BYTE: number;
  64176. /**
  64177. * The short type.
  64178. */
  64179. static readonly SHORT: number;
  64180. /**
  64181. * The unsigned short type.
  64182. */
  64183. static readonly UNSIGNED_SHORT: number;
  64184. /**
  64185. * The integer type.
  64186. */
  64187. static readonly INT: number;
  64188. /**
  64189. * The unsigned integer type.
  64190. */
  64191. static readonly UNSIGNED_INT: number;
  64192. /**
  64193. * The float type.
  64194. */
  64195. static readonly FLOAT: number;
  64196. /**
  64197. * Gets or sets the instance divisor when in instanced mode
  64198. */
  64199. instanceDivisor: number;
  64200. /**
  64201. * Gets the byte stride.
  64202. */
  64203. readonly byteStride: number;
  64204. /**
  64205. * Gets the byte offset.
  64206. */
  64207. readonly byteOffset: number;
  64208. /**
  64209. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64210. */
  64211. readonly normalized: boolean;
  64212. /**
  64213. * Gets the data type of each component in the array.
  64214. */
  64215. readonly type: number;
  64216. /**
  64217. * Constructor
  64218. * @param engine the engine
  64219. * @param data the data to use for this vertex buffer
  64220. * @param kind the vertex buffer kind
  64221. * @param updatable whether the data is updatable
  64222. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64223. * @param stride the stride (optional)
  64224. * @param instanced whether the buffer is instanced (optional)
  64225. * @param offset the offset of the data (optional)
  64226. * @param size the number of components (optional)
  64227. * @param type the type of the component (optional)
  64228. * @param normalized whether the data contains normalized data (optional)
  64229. * @param useBytes set to true if stride and offset are in bytes (optional)
  64230. */
  64231. 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);
  64232. /** @hidden */
  64233. _rebuild(): void;
  64234. /**
  64235. * Returns the kind of the VertexBuffer (string)
  64236. * @returns a string
  64237. */
  64238. getKind(): string;
  64239. /**
  64240. * Gets a boolean indicating if the VertexBuffer is updatable?
  64241. * @returns true if the buffer is updatable
  64242. */
  64243. isUpdatable(): boolean;
  64244. /**
  64245. * Gets current buffer's data
  64246. * @returns a DataArray or null
  64247. */
  64248. getData(): Nullable<DataArray>;
  64249. /**
  64250. * Gets underlying native buffer
  64251. * @returns underlying native buffer
  64252. */
  64253. getBuffer(): Nullable<WebGLBuffer>;
  64254. /**
  64255. * Gets the stride in float32 units (i.e. byte stride / 4).
  64256. * May not be an integer if the byte stride is not divisible by 4.
  64257. * DEPRECATED. Use byteStride instead.
  64258. * @returns the stride in float32 units
  64259. */
  64260. getStrideSize(): number;
  64261. /**
  64262. * Returns the offset as a multiple of the type byte length.
  64263. * DEPRECATED. Use byteOffset instead.
  64264. * @returns the offset in bytes
  64265. */
  64266. getOffset(): number;
  64267. /**
  64268. * Returns the number of components per vertex attribute (integer)
  64269. * @returns the size in float
  64270. */
  64271. getSize(): number;
  64272. /**
  64273. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64274. * @returns true if this buffer is instanced
  64275. */
  64276. getIsInstanced(): boolean;
  64277. /**
  64278. * Returns the instancing divisor, zero for non-instanced (integer).
  64279. * @returns a number
  64280. */
  64281. getInstanceDivisor(): number;
  64282. /**
  64283. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64284. * @param data defines the data to store
  64285. */
  64286. create(data?: DataArray): void;
  64287. /**
  64288. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64289. * This function will create a new buffer if the current one is not updatable
  64290. * @param data defines the data to store
  64291. */
  64292. update(data: DataArray): void;
  64293. /**
  64294. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64295. * Returns the directly updated WebGLBuffer.
  64296. * @param data the new data
  64297. * @param offset the new offset
  64298. * @param useBytes set to true if the offset is in bytes
  64299. */
  64300. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64301. /**
  64302. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64303. */
  64304. dispose(): void;
  64305. /**
  64306. * Enumerates each value of this vertex buffer as numbers.
  64307. * @param count the number of values to enumerate
  64308. * @param callback the callback function called for each value
  64309. */
  64310. forEach(count: number, callback: (value: number, index: number) => void): void;
  64311. /**
  64312. * Positions
  64313. */
  64314. static readonly PositionKind: string;
  64315. /**
  64316. * Normals
  64317. */
  64318. static readonly NormalKind: string;
  64319. /**
  64320. * Tangents
  64321. */
  64322. static readonly TangentKind: string;
  64323. /**
  64324. * Texture coordinates
  64325. */
  64326. static readonly UVKind: string;
  64327. /**
  64328. * Texture coordinates 2
  64329. */
  64330. static readonly UV2Kind: string;
  64331. /**
  64332. * Texture coordinates 3
  64333. */
  64334. static readonly UV3Kind: string;
  64335. /**
  64336. * Texture coordinates 4
  64337. */
  64338. static readonly UV4Kind: string;
  64339. /**
  64340. * Texture coordinates 5
  64341. */
  64342. static readonly UV5Kind: string;
  64343. /**
  64344. * Texture coordinates 6
  64345. */
  64346. static readonly UV6Kind: string;
  64347. /**
  64348. * Colors
  64349. */
  64350. static readonly ColorKind: string;
  64351. /**
  64352. * Matrix indices (for bones)
  64353. */
  64354. static readonly MatricesIndicesKind: string;
  64355. /**
  64356. * Matrix weights (for bones)
  64357. */
  64358. static readonly MatricesWeightsKind: string;
  64359. /**
  64360. * Additional matrix indices (for bones)
  64361. */
  64362. static readonly MatricesIndicesExtraKind: string;
  64363. /**
  64364. * Additional matrix weights (for bones)
  64365. */
  64366. static readonly MatricesWeightsExtraKind: string;
  64367. /**
  64368. * Deduces the stride given a kind.
  64369. * @param kind The kind string to deduce
  64370. * @returns The deduced stride
  64371. */
  64372. static DeduceStride(kind: string): number;
  64373. /**
  64374. * Gets the byte length of the given type.
  64375. * @param type the type
  64376. * @returns the number of bytes
  64377. */
  64378. static GetTypeByteLength(type: number): number;
  64379. /**
  64380. * Enumerates each value of the given parameters as numbers.
  64381. * @param data the data to enumerate
  64382. * @param byteOffset the byte offset of the data
  64383. * @param byteStride the byte stride of the data
  64384. * @param componentCount the number of components per element
  64385. * @param componentType the type of the component
  64386. * @param count the total number of components
  64387. * @param normalized whether the data is normalized
  64388. * @param callback the callback function called for each value
  64389. */
  64390. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64391. private static _GetFloatValue;
  64392. }
  64393. }
  64394. declare module BABYLON {
  64395. /**
  64396. * Class representing spherical polynomial coefficients to the 3rd degree
  64397. */
  64398. export class SphericalPolynomial {
  64399. /**
  64400. * The x coefficients of the spherical polynomial
  64401. */
  64402. x: Vector3;
  64403. /**
  64404. * The y coefficients of the spherical polynomial
  64405. */
  64406. y: Vector3;
  64407. /**
  64408. * The z coefficients of the spherical polynomial
  64409. */
  64410. z: Vector3;
  64411. /**
  64412. * The xx coefficients of the spherical polynomial
  64413. */
  64414. xx: Vector3;
  64415. /**
  64416. * The yy coefficients of the spherical polynomial
  64417. */
  64418. yy: Vector3;
  64419. /**
  64420. * The zz coefficients of the spherical polynomial
  64421. */
  64422. zz: Vector3;
  64423. /**
  64424. * The xy coefficients of the spherical polynomial
  64425. */
  64426. xy: Vector3;
  64427. /**
  64428. * The yz coefficients of the spherical polynomial
  64429. */
  64430. yz: Vector3;
  64431. /**
  64432. * The zx coefficients of the spherical polynomial
  64433. */
  64434. zx: Vector3;
  64435. /**
  64436. * Adds an ambient color to the spherical polynomial
  64437. * @param color the color to add
  64438. */
  64439. addAmbient(color: Color3): void;
  64440. /**
  64441. * Scales the spherical polynomial by the given amount
  64442. * @param scale the amount to scale
  64443. */
  64444. scale(scale: number): void;
  64445. /**
  64446. * Gets the spherical polynomial from harmonics
  64447. * @param harmonics the spherical harmonics
  64448. * @returns the spherical polynomial
  64449. */
  64450. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  64451. /**
  64452. * Constructs a spherical polynomial from an array.
  64453. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  64454. * @returns the spherical polynomial
  64455. */
  64456. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  64457. }
  64458. /**
  64459. * Class representing spherical harmonics coefficients to the 3rd degree
  64460. */
  64461. export class SphericalHarmonics {
  64462. /**
  64463. * The l0,0 coefficients of the spherical harmonics
  64464. */
  64465. l00: Vector3;
  64466. /**
  64467. * The l1,-1 coefficients of the spherical harmonics
  64468. */
  64469. l1_1: Vector3;
  64470. /**
  64471. * The l1,0 coefficients of the spherical harmonics
  64472. */
  64473. l10: Vector3;
  64474. /**
  64475. * The l1,1 coefficients of the spherical harmonics
  64476. */
  64477. l11: Vector3;
  64478. /**
  64479. * The l2,-2 coefficients of the spherical harmonics
  64480. */
  64481. l2_2: Vector3;
  64482. /**
  64483. * The l2,-1 coefficients of the spherical harmonics
  64484. */
  64485. l2_1: Vector3;
  64486. /**
  64487. * The l2,0 coefficients of the spherical harmonics
  64488. */
  64489. l20: Vector3;
  64490. /**
  64491. * The l2,1 coefficients of the spherical harmonics
  64492. */
  64493. l21: Vector3;
  64494. /**
  64495. * The l2,2 coefficients of the spherical harmonics
  64496. */
  64497. lL22: Vector3;
  64498. /**
  64499. * Adds a light to the spherical harmonics
  64500. * @param direction the direction of the light
  64501. * @param color the color of the light
  64502. * @param deltaSolidAngle the delta solid angle of the light
  64503. */
  64504. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  64505. /**
  64506. * Scales the spherical harmonics by the given amount
  64507. * @param scale the amount to scale
  64508. */
  64509. scale(scale: number): void;
  64510. /**
  64511. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  64512. *
  64513. * ```
  64514. * E_lm = A_l * L_lm
  64515. * ```
  64516. *
  64517. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  64518. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  64519. * the scaling factors are given in equation 9.
  64520. */
  64521. convertIncidentRadianceToIrradiance(): void;
  64522. /**
  64523. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  64524. *
  64525. * ```
  64526. * L = (1/pi) * E * rho
  64527. * ```
  64528. *
  64529. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  64530. */
  64531. convertIrradianceToLambertianRadiance(): void;
  64532. /**
  64533. * Gets the spherical harmonics from polynomial
  64534. * @param polynomial the spherical polynomial
  64535. * @returns the spherical harmonics
  64536. */
  64537. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  64538. /**
  64539. * Constructs a spherical harmonics from an array.
  64540. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  64541. * @returns the spherical harmonics
  64542. */
  64543. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  64544. }
  64545. }
  64546. declare module BABYLON {
  64547. /**
  64548. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  64549. */
  64550. export interface CubeMapInfo {
  64551. /**
  64552. * The pixel array for the front face.
  64553. * This is stored in format, left to right, up to down format.
  64554. */
  64555. front: Nullable<ArrayBufferView>;
  64556. /**
  64557. * The pixel array for the back face.
  64558. * This is stored in format, left to right, up to down format.
  64559. */
  64560. back: Nullable<ArrayBufferView>;
  64561. /**
  64562. * The pixel array for the left face.
  64563. * This is stored in format, left to right, up to down format.
  64564. */
  64565. left: Nullable<ArrayBufferView>;
  64566. /**
  64567. * The pixel array for the right face.
  64568. * This is stored in format, left to right, up to down format.
  64569. */
  64570. right: Nullable<ArrayBufferView>;
  64571. /**
  64572. * The pixel array for the up face.
  64573. * This is stored in format, left to right, up to down format.
  64574. */
  64575. up: Nullable<ArrayBufferView>;
  64576. /**
  64577. * The pixel array for the down face.
  64578. * This is stored in format, left to right, up to down format.
  64579. */
  64580. down: Nullable<ArrayBufferView>;
  64581. /**
  64582. * The size of the cubemap stored.
  64583. *
  64584. * Each faces will be size * size pixels.
  64585. */
  64586. size: number;
  64587. /**
  64588. * The format of the texture.
  64589. *
  64590. * RGBA, RGB.
  64591. */
  64592. format: number;
  64593. /**
  64594. * The type of the texture data.
  64595. *
  64596. * UNSIGNED_INT, FLOAT.
  64597. */
  64598. type: number;
  64599. /**
  64600. * Specifies whether the texture is in gamma space.
  64601. */
  64602. gammaSpace: boolean;
  64603. }
  64604. /**
  64605. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  64606. */
  64607. export class PanoramaToCubeMapTools {
  64608. private static FACE_FRONT;
  64609. private static FACE_BACK;
  64610. private static FACE_RIGHT;
  64611. private static FACE_LEFT;
  64612. private static FACE_DOWN;
  64613. private static FACE_UP;
  64614. /**
  64615. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  64616. *
  64617. * @param float32Array The source data.
  64618. * @param inputWidth The width of the input panorama.
  64619. * @param inputHeight The height of the input panorama.
  64620. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  64621. * @return The cubemap data
  64622. */
  64623. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  64624. private static CreateCubemapTexture;
  64625. private static CalcProjectionSpherical;
  64626. }
  64627. }
  64628. declare module BABYLON {
  64629. /**
  64630. * Helper class dealing with the extraction of spherical polynomial dataArray
  64631. * from a cube map.
  64632. */
  64633. export class CubeMapToSphericalPolynomialTools {
  64634. private static FileFaces;
  64635. /**
  64636. * Converts a texture to the according Spherical Polynomial data.
  64637. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64638. *
  64639. * @param texture The texture to extract the information from.
  64640. * @return The Spherical Polynomial data.
  64641. */
  64642. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  64643. /**
  64644. * Converts a cubemap to the according Spherical Polynomial data.
  64645. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64646. *
  64647. * @param cubeInfo The Cube map to extract the information from.
  64648. * @return The Spherical Polynomial data.
  64649. */
  64650. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  64651. }
  64652. }
  64653. declare module BABYLON {
  64654. /**
  64655. * The engine store class is responsible to hold all the instances of Engine and Scene created
  64656. * during the life time of the application.
  64657. */
  64658. export class EngineStore {
  64659. /** Gets the list of created engines */
  64660. static Instances: Engine[];
  64661. /**
  64662. * Gets the latest created engine
  64663. */
  64664. static readonly LastCreatedEngine: Nullable<Engine>;
  64665. /**
  64666. * Gets the latest created scene
  64667. */
  64668. static readonly LastCreatedScene: Nullable<Scene>;
  64669. }
  64670. }
  64671. declare module BABYLON {
  64672. /**
  64673. * Define options used to create a render target texture
  64674. */
  64675. export class RenderTargetCreationOptions {
  64676. /**
  64677. * Specifies is mipmaps must be generated
  64678. */
  64679. generateMipMaps?: boolean;
  64680. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  64681. generateDepthBuffer?: boolean;
  64682. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  64683. generateStencilBuffer?: boolean;
  64684. /** Defines texture type (int by default) */
  64685. type?: number;
  64686. /** Defines sampling mode (trilinear by default) */
  64687. samplingMode?: number;
  64688. /** Defines format (RGBA by default) */
  64689. format?: number;
  64690. }
  64691. }
  64692. declare module BABYLON {
  64693. /**
  64694. * @hidden
  64695. **/
  64696. export class _AlphaState {
  64697. private _isAlphaBlendDirty;
  64698. private _isBlendFunctionParametersDirty;
  64699. private _isBlendEquationParametersDirty;
  64700. private _isBlendConstantsDirty;
  64701. private _alphaBlend;
  64702. private _blendFunctionParameters;
  64703. private _blendEquationParameters;
  64704. private _blendConstants;
  64705. /**
  64706. * Initializes the state.
  64707. */
  64708. constructor();
  64709. readonly isDirty: boolean;
  64710. alphaBlend: boolean;
  64711. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  64712. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  64713. setAlphaEquationParameters(rgb: number, alpha: number): void;
  64714. reset(): void;
  64715. apply(gl: WebGLRenderingContext): void;
  64716. }
  64717. }
  64718. declare module BABYLON {
  64719. /**
  64720. * @hidden
  64721. **/
  64722. export class _DepthCullingState {
  64723. private _isDepthTestDirty;
  64724. private _isDepthMaskDirty;
  64725. private _isDepthFuncDirty;
  64726. private _isCullFaceDirty;
  64727. private _isCullDirty;
  64728. private _isZOffsetDirty;
  64729. private _isFrontFaceDirty;
  64730. private _depthTest;
  64731. private _depthMask;
  64732. private _depthFunc;
  64733. private _cull;
  64734. private _cullFace;
  64735. private _zOffset;
  64736. private _frontFace;
  64737. /**
  64738. * Initializes the state.
  64739. */
  64740. constructor();
  64741. readonly isDirty: boolean;
  64742. zOffset: number;
  64743. cullFace: Nullable<number>;
  64744. cull: Nullable<boolean>;
  64745. depthFunc: Nullable<number>;
  64746. depthMask: boolean;
  64747. depthTest: boolean;
  64748. frontFace: Nullable<number>;
  64749. reset(): void;
  64750. apply(gl: WebGLRenderingContext): void;
  64751. }
  64752. }
  64753. declare module BABYLON {
  64754. /**
  64755. * @hidden
  64756. **/
  64757. export class _StencilState {
  64758. /** 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 */
  64759. static readonly ALWAYS: number;
  64760. /** Passed to stencilOperation to specify that stencil value must be kept */
  64761. static readonly KEEP: number;
  64762. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64763. static readonly REPLACE: number;
  64764. private _isStencilTestDirty;
  64765. private _isStencilMaskDirty;
  64766. private _isStencilFuncDirty;
  64767. private _isStencilOpDirty;
  64768. private _stencilTest;
  64769. private _stencilMask;
  64770. private _stencilFunc;
  64771. private _stencilFuncRef;
  64772. private _stencilFuncMask;
  64773. private _stencilOpStencilFail;
  64774. private _stencilOpDepthFail;
  64775. private _stencilOpStencilDepthPass;
  64776. readonly isDirty: boolean;
  64777. stencilFunc: number;
  64778. stencilFuncRef: number;
  64779. stencilFuncMask: number;
  64780. stencilOpStencilFail: number;
  64781. stencilOpDepthFail: number;
  64782. stencilOpStencilDepthPass: number;
  64783. stencilMask: number;
  64784. stencilTest: boolean;
  64785. constructor();
  64786. reset(): void;
  64787. apply(gl: WebGLRenderingContext): void;
  64788. }
  64789. }
  64790. declare module BABYLON {
  64791. /**
  64792. * @hidden
  64793. **/
  64794. export class _TimeToken {
  64795. _startTimeQuery: Nullable<WebGLQuery>;
  64796. _endTimeQuery: Nullable<WebGLQuery>;
  64797. _timeElapsedQuery: Nullable<WebGLQuery>;
  64798. _timeElapsedQueryEnded: boolean;
  64799. }
  64800. }
  64801. declare module BABYLON {
  64802. /**
  64803. * Internal interface used to track InternalTexture already bound to the GL context
  64804. */
  64805. export interface IInternalTextureTracker {
  64806. /**
  64807. * Gets or set the previous tracker in the list
  64808. */
  64809. previous: Nullable<IInternalTextureTracker>;
  64810. /**
  64811. * Gets or set the next tracker in the list
  64812. */
  64813. next: Nullable<IInternalTextureTracker>;
  64814. }
  64815. /**
  64816. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  64817. */
  64818. export class DummyInternalTextureTracker {
  64819. /**
  64820. * Gets or set the previous tracker in the list
  64821. */
  64822. previous: Nullable<IInternalTextureTracker>;
  64823. /**
  64824. * Gets or set the next tracker in the list
  64825. */
  64826. next: Nullable<IInternalTextureTracker>;
  64827. }
  64828. }
  64829. declare module BABYLON {
  64830. /**
  64831. * Class used to store data associated with WebGL texture data for the engine
  64832. * This class should not be used directly
  64833. */
  64834. export class InternalTexture implements IInternalTextureTracker {
  64835. /** hidden */
  64836. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  64837. /**
  64838. * The source of the texture data is unknown
  64839. */
  64840. static DATASOURCE_UNKNOWN: number;
  64841. /**
  64842. * Texture data comes from an URL
  64843. */
  64844. static DATASOURCE_URL: number;
  64845. /**
  64846. * Texture data is only used for temporary storage
  64847. */
  64848. static DATASOURCE_TEMP: number;
  64849. /**
  64850. * Texture data comes from raw data (ArrayBuffer)
  64851. */
  64852. static DATASOURCE_RAW: number;
  64853. /**
  64854. * Texture content is dynamic (video or dynamic texture)
  64855. */
  64856. static DATASOURCE_DYNAMIC: number;
  64857. /**
  64858. * Texture content is generated by rendering to it
  64859. */
  64860. static DATASOURCE_RENDERTARGET: number;
  64861. /**
  64862. * Texture content is part of a multi render target process
  64863. */
  64864. static DATASOURCE_MULTIRENDERTARGET: number;
  64865. /**
  64866. * Texture data comes from a cube data file
  64867. */
  64868. static DATASOURCE_CUBE: number;
  64869. /**
  64870. * Texture data comes from a raw cube data
  64871. */
  64872. static DATASOURCE_CUBERAW: number;
  64873. /**
  64874. * Texture data come from a prefiltered cube data file
  64875. */
  64876. static DATASOURCE_CUBEPREFILTERED: number;
  64877. /**
  64878. * Texture content is raw 3D data
  64879. */
  64880. static DATASOURCE_RAW3D: number;
  64881. /**
  64882. * Texture content is a depth texture
  64883. */
  64884. static DATASOURCE_DEPTHTEXTURE: number;
  64885. /**
  64886. * Texture data comes from a raw cube data encoded with RGBD
  64887. */
  64888. static DATASOURCE_CUBERAW_RGBD: number;
  64889. /**
  64890. * Defines if the texture is ready
  64891. */
  64892. isReady: boolean;
  64893. /**
  64894. * Defines if the texture is a cube texture
  64895. */
  64896. isCube: boolean;
  64897. /**
  64898. * Defines if the texture contains 3D data
  64899. */
  64900. is3D: boolean;
  64901. /**
  64902. * Defines if the texture contains multiview data
  64903. */
  64904. isMultiview: boolean;
  64905. /**
  64906. * Gets the URL used to load this texture
  64907. */
  64908. url: string;
  64909. /**
  64910. * Gets the sampling mode of the texture
  64911. */
  64912. samplingMode: number;
  64913. /**
  64914. * Gets a boolean indicating if the texture needs mipmaps generation
  64915. */
  64916. generateMipMaps: boolean;
  64917. /**
  64918. * Gets the number of samples used by the texture (WebGL2+ only)
  64919. */
  64920. samples: number;
  64921. /**
  64922. * Gets the type of the texture (int, float...)
  64923. */
  64924. type: number;
  64925. /**
  64926. * Gets the format of the texture (RGB, RGBA...)
  64927. */
  64928. format: number;
  64929. /**
  64930. * Observable called when the texture is loaded
  64931. */
  64932. onLoadedObservable: Observable<InternalTexture>;
  64933. /**
  64934. * Gets the width of the texture
  64935. */
  64936. width: number;
  64937. /**
  64938. * Gets the height of the texture
  64939. */
  64940. height: number;
  64941. /**
  64942. * Gets the depth of the texture
  64943. */
  64944. depth: number;
  64945. /**
  64946. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64947. */
  64948. baseWidth: number;
  64949. /**
  64950. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64951. */
  64952. baseHeight: number;
  64953. /**
  64954. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64955. */
  64956. baseDepth: number;
  64957. /**
  64958. * Gets a boolean indicating if the texture is inverted on Y axis
  64959. */
  64960. invertY: boolean;
  64961. /**
  64962. * Gets or set the previous tracker in the list
  64963. */
  64964. previous: Nullable<IInternalTextureTracker>;
  64965. /**
  64966. * Gets or set the next tracker in the list
  64967. */
  64968. next: Nullable<IInternalTextureTracker>;
  64969. /** @hidden */
  64970. _invertVScale: boolean;
  64971. /** @hidden */
  64972. _initialSlot: number;
  64973. /** @hidden */
  64974. _designatedSlot: number;
  64975. /** @hidden */
  64976. _dataSource: number;
  64977. /** @hidden */
  64978. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64979. /** @hidden */
  64980. _bufferView: Nullable<ArrayBufferView>;
  64981. /** @hidden */
  64982. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64983. /** @hidden */
  64984. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64985. /** @hidden */
  64986. _size: number;
  64987. /** @hidden */
  64988. _extension: string;
  64989. /** @hidden */
  64990. _files: Nullable<string[]>;
  64991. /** @hidden */
  64992. _workingCanvas: HTMLCanvasElement;
  64993. /** @hidden */
  64994. _workingContext: CanvasRenderingContext2D;
  64995. /** @hidden */
  64996. _framebuffer: Nullable<WebGLFramebuffer>;
  64997. /** @hidden */
  64998. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64999. /** @hidden */
  65000. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65001. /** @hidden */
  65002. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65003. /** @hidden */
  65004. _attachments: Nullable<number[]>;
  65005. /** @hidden */
  65006. _cachedCoordinatesMode: Nullable<number>;
  65007. /** @hidden */
  65008. _cachedWrapU: Nullable<number>;
  65009. /** @hidden */
  65010. _cachedWrapV: Nullable<number>;
  65011. /** @hidden */
  65012. _cachedWrapR: Nullable<number>;
  65013. /** @hidden */
  65014. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65015. /** @hidden */
  65016. _isDisabled: boolean;
  65017. /** @hidden */
  65018. _compression: Nullable<string>;
  65019. /** @hidden */
  65020. _generateStencilBuffer: boolean;
  65021. /** @hidden */
  65022. _generateDepthBuffer: boolean;
  65023. /** @hidden */
  65024. _comparisonFunction: number;
  65025. /** @hidden */
  65026. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65027. /** @hidden */
  65028. _lodGenerationScale: number;
  65029. /** @hidden */
  65030. _lodGenerationOffset: number;
  65031. /** @hidden */
  65032. _colorTextureArray: Nullable<WebGLTexture>;
  65033. /** @hidden */
  65034. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65035. /** @hidden */
  65036. _lodTextureHigh: BaseTexture;
  65037. /** @hidden */
  65038. _lodTextureMid: BaseTexture;
  65039. /** @hidden */
  65040. _lodTextureLow: BaseTexture;
  65041. /** @hidden */
  65042. _isRGBD: boolean;
  65043. /** @hidden */
  65044. _webGLTexture: Nullable<WebGLTexture>;
  65045. /** @hidden */
  65046. _references: number;
  65047. private _engine;
  65048. /**
  65049. * Gets the Engine the texture belongs to.
  65050. * @returns The babylon engine
  65051. */
  65052. getEngine(): Engine;
  65053. /**
  65054. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65055. */
  65056. readonly dataSource: number;
  65057. /**
  65058. * Creates a new InternalTexture
  65059. * @param engine defines the engine to use
  65060. * @param dataSource defines the type of data that will be used
  65061. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65062. */
  65063. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65064. /**
  65065. * Increments the number of references (ie. the number of Texture that point to it)
  65066. */
  65067. incrementReferences(): void;
  65068. /**
  65069. * Change the size of the texture (not the size of the content)
  65070. * @param width defines the new width
  65071. * @param height defines the new height
  65072. * @param depth defines the new depth (1 by default)
  65073. */
  65074. updateSize(width: int, height: int, depth?: int): void;
  65075. /** @hidden */
  65076. _rebuild(): void;
  65077. /** @hidden */
  65078. _swapAndDie(target: InternalTexture): void;
  65079. /**
  65080. * Dispose the current allocated resources
  65081. */
  65082. dispose(): void;
  65083. }
  65084. }
  65085. declare module BABYLON {
  65086. /**
  65087. * This represents the main contract an easing function should follow.
  65088. * Easing functions are used throughout the animation system.
  65089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65090. */
  65091. export interface IEasingFunction {
  65092. /**
  65093. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65094. * of the easing function.
  65095. * The link below provides some of the most common examples of easing functions.
  65096. * @see https://easings.net/
  65097. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65098. * @returns the corresponding value on the curve defined by the easing function
  65099. */
  65100. ease(gradient: number): number;
  65101. }
  65102. /**
  65103. * Base class used for every default easing function.
  65104. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65105. */
  65106. export class EasingFunction implements IEasingFunction {
  65107. /**
  65108. * Interpolation follows the mathematical formula associated with the easing function.
  65109. */
  65110. static readonly EASINGMODE_EASEIN: number;
  65111. /**
  65112. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65113. */
  65114. static readonly EASINGMODE_EASEOUT: number;
  65115. /**
  65116. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65117. */
  65118. static readonly EASINGMODE_EASEINOUT: number;
  65119. private _easingMode;
  65120. /**
  65121. * Sets the easing mode of the current function.
  65122. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65123. */
  65124. setEasingMode(easingMode: number): void;
  65125. /**
  65126. * Gets the current easing mode.
  65127. * @returns the easing mode
  65128. */
  65129. getEasingMode(): number;
  65130. /**
  65131. * @hidden
  65132. */
  65133. easeInCore(gradient: number): number;
  65134. /**
  65135. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65136. * of the easing function.
  65137. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65138. * @returns the corresponding value on the curve defined by the easing function
  65139. */
  65140. ease(gradient: number): number;
  65141. }
  65142. /**
  65143. * Easing function with a circle shape (see link below).
  65144. * @see https://easings.net/#easeInCirc
  65145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65146. */
  65147. export class CircleEase extends EasingFunction implements IEasingFunction {
  65148. /** @hidden */
  65149. easeInCore(gradient: number): number;
  65150. }
  65151. /**
  65152. * Easing function with a ease back shape (see link below).
  65153. * @see https://easings.net/#easeInBack
  65154. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65155. */
  65156. export class BackEase extends EasingFunction implements IEasingFunction {
  65157. /** Defines the amplitude of the function */
  65158. amplitude: number;
  65159. /**
  65160. * Instantiates a back ease easing
  65161. * @see https://easings.net/#easeInBack
  65162. * @param amplitude Defines the amplitude of the function
  65163. */
  65164. constructor(
  65165. /** Defines the amplitude of the function */
  65166. amplitude?: number);
  65167. /** @hidden */
  65168. easeInCore(gradient: number): number;
  65169. }
  65170. /**
  65171. * Easing function with a bouncing shape (see link below).
  65172. * @see https://easings.net/#easeInBounce
  65173. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65174. */
  65175. export class BounceEase extends EasingFunction implements IEasingFunction {
  65176. /** Defines the number of bounces */
  65177. bounces: number;
  65178. /** Defines the amplitude of the bounce */
  65179. bounciness: number;
  65180. /**
  65181. * Instantiates a bounce easing
  65182. * @see https://easings.net/#easeInBounce
  65183. * @param bounces Defines the number of bounces
  65184. * @param bounciness Defines the amplitude of the bounce
  65185. */
  65186. constructor(
  65187. /** Defines the number of bounces */
  65188. bounces?: number,
  65189. /** Defines the amplitude of the bounce */
  65190. bounciness?: number);
  65191. /** @hidden */
  65192. easeInCore(gradient: number): number;
  65193. }
  65194. /**
  65195. * Easing function with a power of 3 shape (see link below).
  65196. * @see https://easings.net/#easeInCubic
  65197. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65198. */
  65199. export class CubicEase extends EasingFunction implements IEasingFunction {
  65200. /** @hidden */
  65201. easeInCore(gradient: number): number;
  65202. }
  65203. /**
  65204. * Easing function with an elastic shape (see link below).
  65205. * @see https://easings.net/#easeInElastic
  65206. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65207. */
  65208. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65209. /** Defines the number of oscillations*/
  65210. oscillations: number;
  65211. /** Defines the amplitude of the oscillations*/
  65212. springiness: number;
  65213. /**
  65214. * Instantiates an elastic easing function
  65215. * @see https://easings.net/#easeInElastic
  65216. * @param oscillations Defines the number of oscillations
  65217. * @param springiness Defines the amplitude of the oscillations
  65218. */
  65219. constructor(
  65220. /** Defines the number of oscillations*/
  65221. oscillations?: number,
  65222. /** Defines the amplitude of the oscillations*/
  65223. springiness?: number);
  65224. /** @hidden */
  65225. easeInCore(gradient: number): number;
  65226. }
  65227. /**
  65228. * Easing function with an exponential shape (see link below).
  65229. * @see https://easings.net/#easeInExpo
  65230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65231. */
  65232. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65233. /** Defines the exponent of the function */
  65234. exponent: number;
  65235. /**
  65236. * Instantiates an exponential easing function
  65237. * @see https://easings.net/#easeInExpo
  65238. * @param exponent Defines the exponent of the function
  65239. */
  65240. constructor(
  65241. /** Defines the exponent of the function */
  65242. exponent?: number);
  65243. /** @hidden */
  65244. easeInCore(gradient: number): number;
  65245. }
  65246. /**
  65247. * Easing function with a power shape (see link below).
  65248. * @see https://easings.net/#easeInQuad
  65249. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65250. */
  65251. export class PowerEase extends EasingFunction implements IEasingFunction {
  65252. /** Defines the power of the function */
  65253. power: number;
  65254. /**
  65255. * Instantiates an power base easing function
  65256. * @see https://easings.net/#easeInQuad
  65257. * @param power Defines the power of the function
  65258. */
  65259. constructor(
  65260. /** Defines the power of the function */
  65261. power?: number);
  65262. /** @hidden */
  65263. easeInCore(gradient: number): number;
  65264. }
  65265. /**
  65266. * Easing function with a power of 2 shape (see link below).
  65267. * @see https://easings.net/#easeInQuad
  65268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65269. */
  65270. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65271. /** @hidden */
  65272. easeInCore(gradient: number): number;
  65273. }
  65274. /**
  65275. * Easing function with a power of 4 shape (see link below).
  65276. * @see https://easings.net/#easeInQuart
  65277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65278. */
  65279. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65280. /** @hidden */
  65281. easeInCore(gradient: number): number;
  65282. }
  65283. /**
  65284. * Easing function with a power of 5 shape (see link below).
  65285. * @see https://easings.net/#easeInQuint
  65286. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65287. */
  65288. export class QuinticEase extends EasingFunction implements IEasingFunction {
  65289. /** @hidden */
  65290. easeInCore(gradient: number): number;
  65291. }
  65292. /**
  65293. * Easing function with a sin shape (see link below).
  65294. * @see https://easings.net/#easeInSine
  65295. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65296. */
  65297. export class SineEase extends EasingFunction implements IEasingFunction {
  65298. /** @hidden */
  65299. easeInCore(gradient: number): number;
  65300. }
  65301. /**
  65302. * Easing function with a bezier shape (see link below).
  65303. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65304. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65305. */
  65306. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65307. /** Defines the x component of the start tangent in the bezier curve */
  65308. x1: number;
  65309. /** Defines the y component of the start tangent in the bezier curve */
  65310. y1: number;
  65311. /** Defines the x component of the end tangent in the bezier curve */
  65312. x2: number;
  65313. /** Defines the y component of the end tangent in the bezier curve */
  65314. y2: number;
  65315. /**
  65316. * Instantiates a bezier function
  65317. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65318. * @param x1 Defines the x component of the start tangent in the bezier curve
  65319. * @param y1 Defines the y component of the start tangent in the bezier curve
  65320. * @param x2 Defines the x component of the end tangent in the bezier curve
  65321. * @param y2 Defines the y component of the end tangent in the bezier curve
  65322. */
  65323. constructor(
  65324. /** Defines the x component of the start tangent in the bezier curve */
  65325. x1?: number,
  65326. /** Defines the y component of the start tangent in the bezier curve */
  65327. y1?: number,
  65328. /** Defines the x component of the end tangent in the bezier curve */
  65329. x2?: number,
  65330. /** Defines the y component of the end tangent in the bezier curve */
  65331. y2?: number);
  65332. /** @hidden */
  65333. easeInCore(gradient: number): number;
  65334. }
  65335. }
  65336. declare module BABYLON {
  65337. /**
  65338. * Defines an interface which represents an animation key frame
  65339. */
  65340. export interface IAnimationKey {
  65341. /**
  65342. * Frame of the key frame
  65343. */
  65344. frame: number;
  65345. /**
  65346. * Value at the specifies key frame
  65347. */
  65348. value: any;
  65349. /**
  65350. * The input tangent for the cubic hermite spline
  65351. */
  65352. inTangent?: any;
  65353. /**
  65354. * The output tangent for the cubic hermite spline
  65355. */
  65356. outTangent?: any;
  65357. /**
  65358. * The animation interpolation type
  65359. */
  65360. interpolation?: AnimationKeyInterpolation;
  65361. }
  65362. /**
  65363. * Enum for the animation key frame interpolation type
  65364. */
  65365. export enum AnimationKeyInterpolation {
  65366. /**
  65367. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  65368. */
  65369. STEP = 1
  65370. }
  65371. }
  65372. declare module BABYLON {
  65373. /**
  65374. * Represents the range of an animation
  65375. */
  65376. export class AnimationRange {
  65377. /**The name of the animation range**/
  65378. name: string;
  65379. /**The starting frame of the animation */
  65380. from: number;
  65381. /**The ending frame of the animation*/
  65382. to: number;
  65383. /**
  65384. * Initializes the range of an animation
  65385. * @param name The name of the animation range
  65386. * @param from The starting frame of the animation
  65387. * @param to The ending frame of the animation
  65388. */
  65389. constructor(
  65390. /**The name of the animation range**/
  65391. name: string,
  65392. /**The starting frame of the animation */
  65393. from: number,
  65394. /**The ending frame of the animation*/
  65395. to: number);
  65396. /**
  65397. * Makes a copy of the animation range
  65398. * @returns A copy of the animation range
  65399. */
  65400. clone(): AnimationRange;
  65401. }
  65402. }
  65403. declare module BABYLON {
  65404. /**
  65405. * Composed of a frame, and an action function
  65406. */
  65407. export class AnimationEvent {
  65408. /** The frame for which the event is triggered **/
  65409. frame: number;
  65410. /** The event to perform when triggered **/
  65411. action: (currentFrame: number) => void;
  65412. /** Specifies if the event should be triggered only once**/
  65413. onlyOnce?: boolean | undefined;
  65414. /**
  65415. * Specifies if the animation event is done
  65416. */
  65417. isDone: boolean;
  65418. /**
  65419. * Initializes the animation event
  65420. * @param frame The frame for which the event is triggered
  65421. * @param action The event to perform when triggered
  65422. * @param onlyOnce Specifies if the event should be triggered only once
  65423. */
  65424. constructor(
  65425. /** The frame for which the event is triggered **/
  65426. frame: number,
  65427. /** The event to perform when triggered **/
  65428. action: (currentFrame: number) => void,
  65429. /** Specifies if the event should be triggered only once**/
  65430. onlyOnce?: boolean | undefined);
  65431. /** @hidden */
  65432. _clone(): AnimationEvent;
  65433. }
  65434. }
  65435. declare module BABYLON {
  65436. /**
  65437. * Interface used to define a behavior
  65438. */
  65439. export interface Behavior<T> {
  65440. /** gets or sets behavior's name */
  65441. name: string;
  65442. /**
  65443. * Function called when the behavior needs to be initialized (after attaching it to a target)
  65444. */
  65445. init(): void;
  65446. /**
  65447. * Called when the behavior is attached to a target
  65448. * @param target defines the target where the behavior is attached to
  65449. */
  65450. attach(target: T): void;
  65451. /**
  65452. * Called when the behavior is detached from its target
  65453. */
  65454. detach(): void;
  65455. }
  65456. /**
  65457. * Interface implemented by classes supporting behaviors
  65458. */
  65459. export interface IBehaviorAware<T> {
  65460. /**
  65461. * Attach a behavior
  65462. * @param behavior defines the behavior to attach
  65463. * @returns the current host
  65464. */
  65465. addBehavior(behavior: Behavior<T>): T;
  65466. /**
  65467. * Remove a behavior from the current object
  65468. * @param behavior defines the behavior to detach
  65469. * @returns the current host
  65470. */
  65471. removeBehavior(behavior: Behavior<T>): T;
  65472. /**
  65473. * Gets a behavior using its name to search
  65474. * @param name defines the name to search
  65475. * @returns the behavior or null if not found
  65476. */
  65477. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  65478. }
  65479. }
  65480. declare module BABYLON {
  65481. /**
  65482. * @hidden
  65483. */
  65484. export class IntersectionInfo {
  65485. bu: Nullable<number>;
  65486. bv: Nullable<number>;
  65487. distance: number;
  65488. faceId: number;
  65489. subMeshId: number;
  65490. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  65491. }
  65492. }
  65493. declare module BABYLON {
  65494. /**
  65495. * Class used to store bounding sphere information
  65496. */
  65497. export class BoundingSphere {
  65498. /**
  65499. * Gets the center of the bounding sphere in local space
  65500. */
  65501. readonly center: Vector3;
  65502. /**
  65503. * Radius of the bounding sphere in local space
  65504. */
  65505. radius: number;
  65506. /**
  65507. * Gets the center of the bounding sphere in world space
  65508. */
  65509. readonly centerWorld: Vector3;
  65510. /**
  65511. * Radius of the bounding sphere in world space
  65512. */
  65513. radiusWorld: number;
  65514. /**
  65515. * Gets the minimum vector in local space
  65516. */
  65517. readonly minimum: Vector3;
  65518. /**
  65519. * Gets the maximum vector in local space
  65520. */
  65521. readonly maximum: Vector3;
  65522. private _worldMatrix;
  65523. private static readonly TmpVector3;
  65524. /**
  65525. * Creates a new bounding sphere
  65526. * @param min defines the minimum vector (in local space)
  65527. * @param max defines the maximum vector (in local space)
  65528. * @param worldMatrix defines the new world matrix
  65529. */
  65530. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65531. /**
  65532. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  65533. * @param min defines the new minimum vector (in local space)
  65534. * @param max defines the new maximum vector (in local space)
  65535. * @param worldMatrix defines the new world matrix
  65536. */
  65537. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65538. /**
  65539. * Scale the current bounding sphere by applying a scale factor
  65540. * @param factor defines the scale factor to apply
  65541. * @returns the current bounding box
  65542. */
  65543. scale(factor: number): BoundingSphere;
  65544. /**
  65545. * Gets the world matrix of the bounding box
  65546. * @returns a matrix
  65547. */
  65548. getWorldMatrix(): DeepImmutable<Matrix>;
  65549. /** @hidden */
  65550. _update(worldMatrix: DeepImmutable<Matrix>): void;
  65551. /**
  65552. * Tests if the bounding sphere is intersecting the frustum planes
  65553. * @param frustumPlanes defines the frustum planes to test
  65554. * @returns true if there is an intersection
  65555. */
  65556. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65557. /**
  65558. * Tests if the bounding sphere center is in between the frustum planes.
  65559. * Used for optimistic fast inclusion.
  65560. * @param frustumPlanes defines the frustum planes to test
  65561. * @returns true if the sphere center is in between the frustum planes
  65562. */
  65563. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65564. /**
  65565. * Tests if a point is inside the bounding sphere
  65566. * @param point defines the point to test
  65567. * @returns true if the point is inside the bounding sphere
  65568. */
  65569. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65570. /**
  65571. * Checks if two sphere intersct
  65572. * @param sphere0 sphere 0
  65573. * @param sphere1 sphere 1
  65574. * @returns true if the speres intersect
  65575. */
  65576. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  65577. }
  65578. }
  65579. declare module BABYLON {
  65580. /**
  65581. * Class used to store bounding box information
  65582. */
  65583. export class BoundingBox implements ICullable {
  65584. /**
  65585. * Gets the 8 vectors representing the bounding box in local space
  65586. */
  65587. readonly vectors: Vector3[];
  65588. /**
  65589. * Gets the center of the bounding box in local space
  65590. */
  65591. readonly center: Vector3;
  65592. /**
  65593. * Gets the center of the bounding box in world space
  65594. */
  65595. readonly centerWorld: Vector3;
  65596. /**
  65597. * Gets the extend size in local space
  65598. */
  65599. readonly extendSize: Vector3;
  65600. /**
  65601. * Gets the extend size in world space
  65602. */
  65603. readonly extendSizeWorld: Vector3;
  65604. /**
  65605. * Gets the OBB (object bounding box) directions
  65606. */
  65607. readonly directions: Vector3[];
  65608. /**
  65609. * Gets the 8 vectors representing the bounding box in world space
  65610. */
  65611. readonly vectorsWorld: Vector3[];
  65612. /**
  65613. * Gets the minimum vector in world space
  65614. */
  65615. readonly minimumWorld: Vector3;
  65616. /**
  65617. * Gets the maximum vector in world space
  65618. */
  65619. readonly maximumWorld: Vector3;
  65620. /**
  65621. * Gets the minimum vector in local space
  65622. */
  65623. readonly minimum: Vector3;
  65624. /**
  65625. * Gets the maximum vector in local space
  65626. */
  65627. readonly maximum: Vector3;
  65628. private _worldMatrix;
  65629. private static readonly TmpVector3;
  65630. /**
  65631. * @hidden
  65632. */
  65633. _tag: number;
  65634. /**
  65635. * Creates a new bounding box
  65636. * @param min defines the minimum vector (in local space)
  65637. * @param max defines the maximum vector (in local space)
  65638. * @param worldMatrix defines the new world matrix
  65639. */
  65640. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65641. /**
  65642. * Recreates the entire bounding box from scratch as if we call the constructor in place
  65643. * @param min defines the new minimum vector (in local space)
  65644. * @param max defines the new maximum vector (in local space)
  65645. * @param worldMatrix defines the new world matrix
  65646. */
  65647. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65648. /**
  65649. * Scale the current bounding box by applying a scale factor
  65650. * @param factor defines the scale factor to apply
  65651. * @returns the current bounding box
  65652. */
  65653. scale(factor: number): BoundingBox;
  65654. /**
  65655. * Gets the world matrix of the bounding box
  65656. * @returns a matrix
  65657. */
  65658. getWorldMatrix(): DeepImmutable<Matrix>;
  65659. /** @hidden */
  65660. _update(world: DeepImmutable<Matrix>): void;
  65661. /**
  65662. * Tests if the bounding box is intersecting the frustum planes
  65663. * @param frustumPlanes defines the frustum planes to test
  65664. * @returns true if there is an intersection
  65665. */
  65666. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65667. /**
  65668. * Tests if the bounding box is entirely inside the frustum planes
  65669. * @param frustumPlanes defines the frustum planes to test
  65670. * @returns true if there is an inclusion
  65671. */
  65672. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65673. /**
  65674. * Tests if a point is inside the bounding box
  65675. * @param point defines the point to test
  65676. * @returns true if the point is inside the bounding box
  65677. */
  65678. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65679. /**
  65680. * Tests if the bounding box intersects with a bounding sphere
  65681. * @param sphere defines the sphere to test
  65682. * @returns true if there is an intersection
  65683. */
  65684. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  65685. /**
  65686. * Tests if the bounding box intersects with a box defined by a min and max vectors
  65687. * @param min defines the min vector to use
  65688. * @param max defines the max vector to use
  65689. * @returns true if there is an intersection
  65690. */
  65691. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  65692. /**
  65693. * Tests if two bounding boxes are intersections
  65694. * @param box0 defines the first box to test
  65695. * @param box1 defines the second box to test
  65696. * @returns true if there is an intersection
  65697. */
  65698. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  65699. /**
  65700. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  65701. * @param minPoint defines the minimum vector of the bounding box
  65702. * @param maxPoint defines the maximum vector of the bounding box
  65703. * @param sphereCenter defines the sphere center
  65704. * @param sphereRadius defines the sphere radius
  65705. * @returns true if there is an intersection
  65706. */
  65707. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  65708. /**
  65709. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  65710. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65711. * @param frustumPlanes defines the frustum planes to test
  65712. * @return true if there is an inclusion
  65713. */
  65714. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65715. /**
  65716. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  65717. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65718. * @param frustumPlanes defines the frustum planes to test
  65719. * @return true if there is an intersection
  65720. */
  65721. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65722. }
  65723. }
  65724. declare module BABYLON {
  65725. /** @hidden */
  65726. export class Collider {
  65727. /** Define if a collision was found */
  65728. collisionFound: boolean;
  65729. /**
  65730. * Define last intersection point in local space
  65731. */
  65732. intersectionPoint: Vector3;
  65733. /**
  65734. * Define last collided mesh
  65735. */
  65736. collidedMesh: Nullable<AbstractMesh>;
  65737. private _collisionPoint;
  65738. private _planeIntersectionPoint;
  65739. private _tempVector;
  65740. private _tempVector2;
  65741. private _tempVector3;
  65742. private _tempVector4;
  65743. private _edge;
  65744. private _baseToVertex;
  65745. private _destinationPoint;
  65746. private _slidePlaneNormal;
  65747. private _displacementVector;
  65748. /** @hidden */
  65749. _radius: Vector3;
  65750. /** @hidden */
  65751. _retry: number;
  65752. private _velocity;
  65753. private _basePoint;
  65754. private _epsilon;
  65755. /** @hidden */
  65756. _velocityWorldLength: number;
  65757. /** @hidden */
  65758. _basePointWorld: Vector3;
  65759. private _velocityWorld;
  65760. private _normalizedVelocity;
  65761. /** @hidden */
  65762. _initialVelocity: Vector3;
  65763. /** @hidden */
  65764. _initialPosition: Vector3;
  65765. private _nearestDistance;
  65766. private _collisionMask;
  65767. collisionMask: number;
  65768. /**
  65769. * Gets the plane normal used to compute the sliding response (in local space)
  65770. */
  65771. readonly slidePlaneNormal: Vector3;
  65772. /** @hidden */
  65773. _initialize(source: Vector3, dir: Vector3, e: number): void;
  65774. /** @hidden */
  65775. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  65776. /** @hidden */
  65777. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  65778. /** @hidden */
  65779. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  65780. /** @hidden */
  65781. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  65782. /** @hidden */
  65783. _getResponse(pos: Vector3, vel: Vector3): void;
  65784. }
  65785. }
  65786. declare module BABYLON {
  65787. /**
  65788. * Interface for cullable objects
  65789. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  65790. */
  65791. export interface ICullable {
  65792. /**
  65793. * Checks if the object or part of the object is in the frustum
  65794. * @param frustumPlanes Camera near/planes
  65795. * @returns true if the object is in frustum otherwise false
  65796. */
  65797. isInFrustum(frustumPlanes: Plane[]): boolean;
  65798. /**
  65799. * Checks if a cullable object (mesh...) is in the camera frustum
  65800. * Unlike isInFrustum this cheks the full bounding box
  65801. * @param frustumPlanes Camera near/planes
  65802. * @returns true if the object is in frustum otherwise false
  65803. */
  65804. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  65805. }
  65806. /**
  65807. * Info for a bounding data of a mesh
  65808. */
  65809. export class BoundingInfo implements ICullable {
  65810. /**
  65811. * Bounding box for the mesh
  65812. */
  65813. readonly boundingBox: BoundingBox;
  65814. /**
  65815. * Bounding sphere for the mesh
  65816. */
  65817. readonly boundingSphere: BoundingSphere;
  65818. private _isLocked;
  65819. private static readonly TmpVector3;
  65820. /**
  65821. * Constructs bounding info
  65822. * @param minimum min vector of the bounding box/sphere
  65823. * @param maximum max vector of the bounding box/sphere
  65824. * @param worldMatrix defines the new world matrix
  65825. */
  65826. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65827. /**
  65828. * Recreates the entire bounding info from scratch as if we call the constructor in place
  65829. * @param min defines the new minimum vector (in local space)
  65830. * @param max defines the new maximum vector (in local space)
  65831. * @param worldMatrix defines the new world matrix
  65832. */
  65833. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65834. /**
  65835. * min vector of the bounding box/sphere
  65836. */
  65837. readonly minimum: Vector3;
  65838. /**
  65839. * max vector of the bounding box/sphere
  65840. */
  65841. readonly maximum: Vector3;
  65842. /**
  65843. * If the info is locked and won't be updated to avoid perf overhead
  65844. */
  65845. isLocked: boolean;
  65846. /**
  65847. * Updates the bounding sphere and box
  65848. * @param world world matrix to be used to update
  65849. */
  65850. update(world: DeepImmutable<Matrix>): void;
  65851. /**
  65852. * Recreate the bounding info to be centered around a specific point given a specific extend.
  65853. * @param center New center of the bounding info
  65854. * @param extend New extend of the bounding info
  65855. * @returns the current bounding info
  65856. */
  65857. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  65858. /**
  65859. * Scale the current bounding info by applying a scale factor
  65860. * @param factor defines the scale factor to apply
  65861. * @returns the current bounding info
  65862. */
  65863. scale(factor: number): BoundingInfo;
  65864. /**
  65865. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  65866. * @param frustumPlanes defines the frustum to test
  65867. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  65868. * @returns true if the bounding info is in the frustum planes
  65869. */
  65870. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  65871. /**
  65872. * Gets the world distance between the min and max points of the bounding box
  65873. */
  65874. readonly diagonalLength: number;
  65875. /**
  65876. * Checks if a cullable object (mesh...) is in the camera frustum
  65877. * Unlike isInFrustum this cheks the full bounding box
  65878. * @param frustumPlanes Camera near/planes
  65879. * @returns true if the object is in frustum otherwise false
  65880. */
  65881. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65882. /** @hidden */
  65883. _checkCollision(collider: Collider): boolean;
  65884. /**
  65885. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  65886. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65887. * @param point the point to check intersection with
  65888. * @returns if the point intersects
  65889. */
  65890. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65891. /**
  65892. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  65893. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65894. * @param boundingInfo the bounding info to check intersection with
  65895. * @param precise if the intersection should be done using OBB
  65896. * @returns if the bounding info intersects
  65897. */
  65898. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65899. }
  65900. }
  65901. declare module BABYLON {
  65902. /**
  65903. * Defines an array and its length.
  65904. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65905. */
  65906. export interface ISmartArrayLike<T> {
  65907. /**
  65908. * The data of the array.
  65909. */
  65910. data: Array<T>;
  65911. /**
  65912. * The active length of the array.
  65913. */
  65914. length: number;
  65915. }
  65916. /**
  65917. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65918. */
  65919. export class SmartArray<T> implements ISmartArrayLike<T> {
  65920. /**
  65921. * The full set of data from the array.
  65922. */
  65923. data: Array<T>;
  65924. /**
  65925. * The active length of the array.
  65926. */
  65927. length: number;
  65928. protected _id: number;
  65929. /**
  65930. * Instantiates a Smart Array.
  65931. * @param capacity defines the default capacity of the array.
  65932. */
  65933. constructor(capacity: number);
  65934. /**
  65935. * Pushes a value at the end of the active data.
  65936. * @param value defines the object to push in the array.
  65937. */
  65938. push(value: T): void;
  65939. /**
  65940. * Iterates over the active data and apply the lambda to them.
  65941. * @param func defines the action to apply on each value.
  65942. */
  65943. forEach(func: (content: T) => void): void;
  65944. /**
  65945. * Sorts the full sets of data.
  65946. * @param compareFn defines the comparison function to apply.
  65947. */
  65948. sort(compareFn: (a: T, b: T) => number): void;
  65949. /**
  65950. * Resets the active data to an empty array.
  65951. */
  65952. reset(): void;
  65953. /**
  65954. * Releases all the data from the array as well as the array.
  65955. */
  65956. dispose(): void;
  65957. /**
  65958. * Concats the active data with a given array.
  65959. * @param array defines the data to concatenate with.
  65960. */
  65961. concat(array: any): void;
  65962. /**
  65963. * Returns the position of a value in the active data.
  65964. * @param value defines the value to find the index for
  65965. * @returns the index if found in the active data otherwise -1
  65966. */
  65967. indexOf(value: T): number;
  65968. /**
  65969. * Returns whether an element is part of the active data.
  65970. * @param value defines the value to look for
  65971. * @returns true if found in the active data otherwise false
  65972. */
  65973. contains(value: T): boolean;
  65974. private static _GlobalId;
  65975. }
  65976. /**
  65977. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65978. * The data in this array can only be present once
  65979. */
  65980. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65981. private _duplicateId;
  65982. /**
  65983. * Pushes a value at the end of the active data.
  65984. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65985. * @param value defines the object to push in the array.
  65986. */
  65987. push(value: T): void;
  65988. /**
  65989. * Pushes a value at the end of the active data.
  65990. * If the data is already present, it won t be added again
  65991. * @param value defines the object to push in the array.
  65992. * @returns true if added false if it was already present
  65993. */
  65994. pushNoDuplicate(value: T): boolean;
  65995. /**
  65996. * Resets the active data to an empty array.
  65997. */
  65998. reset(): void;
  65999. /**
  66000. * Concats the active data with a given array.
  66001. * This ensures no dupplicate will be present in the result.
  66002. * @param array defines the data to concatenate with.
  66003. */
  66004. concatWithNoDuplicate(array: any): void;
  66005. }
  66006. }
  66007. declare module BABYLON {
  66008. /**
  66009. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66010. * separate meshes. This can be use to improve performances.
  66011. * @see http://doc.babylonjs.com/how_to/multi_materials
  66012. */
  66013. export class MultiMaterial extends Material {
  66014. private _subMaterials;
  66015. /**
  66016. * Gets or Sets the list of Materials used within the multi material.
  66017. * They need to be ordered according to the submeshes order in the associated mesh
  66018. */
  66019. subMaterials: Nullable<Material>[];
  66020. /**
  66021. * Function used to align with Node.getChildren()
  66022. * @returns the list of Materials used within the multi material
  66023. */
  66024. getChildren(): Nullable<Material>[];
  66025. /**
  66026. * Instantiates a new Multi Material
  66027. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66028. * separate meshes. This can be use to improve performances.
  66029. * @see http://doc.babylonjs.com/how_to/multi_materials
  66030. * @param name Define the name in the scene
  66031. * @param scene Define the scene the material belongs to
  66032. */
  66033. constructor(name: string, scene: Scene);
  66034. private _hookArray;
  66035. /**
  66036. * Get one of the submaterial by its index in the submaterials array
  66037. * @param index The index to look the sub material at
  66038. * @returns The Material if the index has been defined
  66039. */
  66040. getSubMaterial(index: number): Nullable<Material>;
  66041. /**
  66042. * Get the list of active textures for the whole sub materials list.
  66043. * @returns All the textures that will be used during the rendering
  66044. */
  66045. getActiveTextures(): BaseTexture[];
  66046. /**
  66047. * Gets the current class name of the material e.g. "MultiMaterial"
  66048. * Mainly use in serialization.
  66049. * @returns the class name
  66050. */
  66051. getClassName(): string;
  66052. /**
  66053. * Checks if the material is ready to render the requested sub mesh
  66054. * @param mesh Define the mesh the submesh belongs to
  66055. * @param subMesh Define the sub mesh to look readyness for
  66056. * @param useInstances Define whether or not the material is used with instances
  66057. * @returns true if ready, otherwise false
  66058. */
  66059. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66060. /**
  66061. * Clones the current material and its related sub materials
  66062. * @param name Define the name of the newly cloned material
  66063. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66064. * @returns the cloned material
  66065. */
  66066. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66067. /**
  66068. * Serializes the materials into a JSON representation.
  66069. * @returns the JSON representation
  66070. */
  66071. serialize(): any;
  66072. /**
  66073. * Dispose the material and release its associated resources
  66074. * @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)
  66075. * @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)
  66076. * @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)
  66077. */
  66078. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66079. /**
  66080. * Creates a MultiMaterial from parsed MultiMaterial data.
  66081. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66082. * @param scene defines the hosting scene
  66083. * @returns a new MultiMaterial
  66084. */
  66085. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66086. }
  66087. }
  66088. declare module BABYLON {
  66089. /**
  66090. * Class used to represent data loading progression
  66091. */
  66092. export class SceneLoaderFlags {
  66093. private static _ForceFullSceneLoadingForIncremental;
  66094. private static _ShowLoadingScreen;
  66095. private static _CleanBoneMatrixWeights;
  66096. private static _loggingLevel;
  66097. /**
  66098. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66099. */
  66100. static ForceFullSceneLoadingForIncremental: boolean;
  66101. /**
  66102. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66103. */
  66104. static ShowLoadingScreen: boolean;
  66105. /**
  66106. * Defines the current logging level (while loading the scene)
  66107. * @ignorenaming
  66108. */
  66109. static loggingLevel: number;
  66110. /**
  66111. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66112. */
  66113. static CleanBoneMatrixWeights: boolean;
  66114. }
  66115. }
  66116. declare module BABYLON {
  66117. /**
  66118. * 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.
  66119. * @see https://doc.babylonjs.com/how_to/transformnode
  66120. */
  66121. export class TransformNode extends Node {
  66122. /**
  66123. * Object will not rotate to face the camera
  66124. */
  66125. static BILLBOARDMODE_NONE: number;
  66126. /**
  66127. * Object will rotate to face the camera but only on the x axis
  66128. */
  66129. static BILLBOARDMODE_X: number;
  66130. /**
  66131. * Object will rotate to face the camera but only on the y axis
  66132. */
  66133. static BILLBOARDMODE_Y: number;
  66134. /**
  66135. * Object will rotate to face the camera but only on the z axis
  66136. */
  66137. static BILLBOARDMODE_Z: number;
  66138. /**
  66139. * Object will rotate to face the camera
  66140. */
  66141. static BILLBOARDMODE_ALL: number;
  66142. private _forward;
  66143. private _forwardInverted;
  66144. private _up;
  66145. private _right;
  66146. private _rightInverted;
  66147. private _position;
  66148. private _rotation;
  66149. private _rotationQuaternion;
  66150. protected _scaling: Vector3;
  66151. protected _isDirty: boolean;
  66152. private _transformToBoneReferal;
  66153. /**
  66154. * Set the billboard mode. Default is 0.
  66155. *
  66156. * | Value | Type | Description |
  66157. * | --- | --- | --- |
  66158. * | 0 | BILLBOARDMODE_NONE | |
  66159. * | 1 | BILLBOARDMODE_X | |
  66160. * | 2 | BILLBOARDMODE_Y | |
  66161. * | 4 | BILLBOARDMODE_Z | |
  66162. * | 7 | BILLBOARDMODE_ALL | |
  66163. *
  66164. */
  66165. billboardMode: number;
  66166. /**
  66167. * 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
  66168. */
  66169. scalingDeterminant: number;
  66170. /**
  66171. * Sets the distance of the object to max, often used by skybox
  66172. */
  66173. infiniteDistance: boolean;
  66174. /**
  66175. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66176. * By default the system will update normals to compensate
  66177. */
  66178. ignoreNonUniformScaling: boolean;
  66179. /** @hidden */
  66180. _poseMatrix: Matrix;
  66181. /** @hidden */
  66182. _localMatrix: Matrix;
  66183. private _absolutePosition;
  66184. private _pivotMatrix;
  66185. private _pivotMatrixInverse;
  66186. protected _postMultiplyPivotMatrix: boolean;
  66187. private _tempMatrix;
  66188. private _tempMatrix2;
  66189. protected _isWorldMatrixFrozen: boolean;
  66190. /** @hidden */
  66191. _indexInSceneTransformNodesArray: number;
  66192. /**
  66193. * An event triggered after the world matrix is updated
  66194. */
  66195. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66196. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66197. /**
  66198. * Gets a string identifying the name of the class
  66199. * @returns "TransformNode" string
  66200. */
  66201. getClassName(): string;
  66202. /**
  66203. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66204. */
  66205. position: Vector3;
  66206. /**
  66207. * 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)).
  66208. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66209. */
  66210. rotation: Vector3;
  66211. /**
  66212. * 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)).
  66213. */
  66214. scaling: Vector3;
  66215. /**
  66216. * 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).
  66217. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66218. */
  66219. rotationQuaternion: Nullable<Quaternion>;
  66220. /**
  66221. * The forward direction of that transform in world space.
  66222. */
  66223. readonly forward: Vector3;
  66224. /**
  66225. * The up direction of that transform in world space.
  66226. */
  66227. readonly up: Vector3;
  66228. /**
  66229. * The right direction of that transform in world space.
  66230. */
  66231. readonly right: Vector3;
  66232. /**
  66233. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66234. * @param matrix the matrix to copy the pose from
  66235. * @returns this TransformNode.
  66236. */
  66237. updatePoseMatrix(matrix: Matrix): TransformNode;
  66238. /**
  66239. * Returns the mesh Pose matrix.
  66240. * @returns the pose matrix
  66241. */
  66242. getPoseMatrix(): Matrix;
  66243. /** @hidden */
  66244. _isSynchronized(): boolean;
  66245. /** @hidden */
  66246. _initCache(): void;
  66247. /**
  66248. * Flag the transform node as dirty (Forcing it to update everything)
  66249. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66250. * @returns this transform node
  66251. */
  66252. markAsDirty(property: string): TransformNode;
  66253. /**
  66254. * Returns the current mesh absolute position.
  66255. * Returns a Vector3.
  66256. */
  66257. readonly absolutePosition: Vector3;
  66258. /**
  66259. * Sets a new matrix to apply before all other transformation
  66260. * @param matrix defines the transform matrix
  66261. * @returns the current TransformNode
  66262. */
  66263. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66264. /**
  66265. * Sets a new pivot matrix to the current node
  66266. * @param matrix defines the new pivot matrix to use
  66267. * @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
  66268. * @returns the current TransformNode
  66269. */
  66270. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  66271. /**
  66272. * Returns the mesh pivot matrix.
  66273. * Default : Identity.
  66274. * @returns the matrix
  66275. */
  66276. getPivotMatrix(): Matrix;
  66277. /**
  66278. * Prevents the World matrix to be computed any longer.
  66279. * @returns the TransformNode.
  66280. */
  66281. freezeWorldMatrix(): TransformNode;
  66282. /**
  66283. * Allows back the World matrix computation.
  66284. * @returns the TransformNode.
  66285. */
  66286. unfreezeWorldMatrix(): this;
  66287. /**
  66288. * True if the World matrix has been frozen.
  66289. */
  66290. readonly isWorldMatrixFrozen: boolean;
  66291. /**
  66292. * Retuns the mesh absolute position in the World.
  66293. * @returns a Vector3.
  66294. */
  66295. getAbsolutePosition(): Vector3;
  66296. /**
  66297. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66298. * @param absolutePosition the absolute position to set
  66299. * @returns the TransformNode.
  66300. */
  66301. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66302. /**
  66303. * Sets the mesh position in its local space.
  66304. * @param vector3 the position to set in localspace
  66305. * @returns the TransformNode.
  66306. */
  66307. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66308. /**
  66309. * Returns the mesh position in the local space from the current World matrix values.
  66310. * @returns a new Vector3.
  66311. */
  66312. getPositionExpressedInLocalSpace(): Vector3;
  66313. /**
  66314. * Translates the mesh along the passed Vector3 in its local space.
  66315. * @param vector3 the distance to translate in localspace
  66316. * @returns the TransformNode.
  66317. */
  66318. locallyTranslate(vector3: Vector3): TransformNode;
  66319. private static _lookAtVectorCache;
  66320. /**
  66321. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66322. * @param targetPoint the position (must be in same space as current mesh) to look at
  66323. * @param yawCor optional yaw (y-axis) correction in radians
  66324. * @param pitchCor optional pitch (x-axis) correction in radians
  66325. * @param rollCor optional roll (z-axis) correction in radians
  66326. * @param space the choosen space of the target
  66327. * @returns the TransformNode.
  66328. */
  66329. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66330. /**
  66331. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66332. * This Vector3 is expressed in the World space.
  66333. * @param localAxis axis to rotate
  66334. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66335. */
  66336. getDirection(localAxis: Vector3): Vector3;
  66337. /**
  66338. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66339. * localAxis is expressed in the mesh local space.
  66340. * result is computed in the Wordl space from the mesh World matrix.
  66341. * @param localAxis axis to rotate
  66342. * @param result the resulting transformnode
  66343. * @returns this TransformNode.
  66344. */
  66345. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66346. /**
  66347. * Sets this transform node rotation to the given local axis.
  66348. * @param localAxis the axis in local space
  66349. * @param yawCor optional yaw (y-axis) correction in radians
  66350. * @param pitchCor optional pitch (x-axis) correction in radians
  66351. * @param rollCor optional roll (z-axis) correction in radians
  66352. * @returns this TransformNode
  66353. */
  66354. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66355. /**
  66356. * Sets a new pivot point to the current node
  66357. * @param point defines the new pivot point to use
  66358. * @param space defines if the point is in world or local space (local by default)
  66359. * @returns the current TransformNode
  66360. */
  66361. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66362. /**
  66363. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66364. * @returns the pivot point
  66365. */
  66366. getPivotPoint(): Vector3;
  66367. /**
  66368. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66369. * @param result the vector3 to store the result
  66370. * @returns this TransformNode.
  66371. */
  66372. getPivotPointToRef(result: Vector3): TransformNode;
  66373. /**
  66374. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66375. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66376. */
  66377. getAbsolutePivotPoint(): Vector3;
  66378. /**
  66379. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66380. * @param result vector3 to store the result
  66381. * @returns this TransformNode.
  66382. */
  66383. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66384. /**
  66385. * Defines the passed node as the parent of the current node.
  66386. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66387. * @see https://doc.babylonjs.com/how_to/parenting
  66388. * @param node the node ot set as the parent
  66389. * @returns this TransformNode.
  66390. */
  66391. setParent(node: Nullable<Node>): TransformNode;
  66392. private _nonUniformScaling;
  66393. /**
  66394. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66395. */
  66396. readonly nonUniformScaling: boolean;
  66397. /** @hidden */
  66398. _updateNonUniformScalingState(value: boolean): boolean;
  66399. /**
  66400. * Attach the current TransformNode to another TransformNode associated with a bone
  66401. * @param bone Bone affecting the TransformNode
  66402. * @param affectedTransformNode TransformNode associated with the bone
  66403. * @returns this object
  66404. */
  66405. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66406. /**
  66407. * Detach the transform node if its associated with a bone
  66408. * @returns this object
  66409. */
  66410. detachFromBone(): TransformNode;
  66411. private static _rotationAxisCache;
  66412. /**
  66413. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66414. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66415. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66416. * The passed axis is also normalized.
  66417. * @param axis the axis to rotate around
  66418. * @param amount the amount to rotate in radians
  66419. * @param space Space to rotate in (Default: local)
  66420. * @returns the TransformNode.
  66421. */
  66422. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66423. /**
  66424. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66425. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66426. * The passed axis is also normalized. .
  66427. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66428. * @param point the point to rotate around
  66429. * @param axis the axis to rotate around
  66430. * @param amount the amount to rotate in radians
  66431. * @returns the TransformNode
  66432. */
  66433. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66434. /**
  66435. * Translates the mesh along the axis vector for the passed distance in the given space.
  66436. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66437. * @param axis the axis to translate in
  66438. * @param distance the distance to translate
  66439. * @param space Space to rotate in (Default: local)
  66440. * @returns the TransformNode.
  66441. */
  66442. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66443. /**
  66444. * Adds a rotation step to the mesh current rotation.
  66445. * x, y, z are Euler angles expressed in radians.
  66446. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66447. * This means this rotation is made in the mesh local space only.
  66448. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66449. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66450. * ```javascript
  66451. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66452. * ```
  66453. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66454. * 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.
  66455. * @param x Rotation to add
  66456. * @param y Rotation to add
  66457. * @param z Rotation to add
  66458. * @returns the TransformNode.
  66459. */
  66460. addRotation(x: number, y: number, z: number): TransformNode;
  66461. /**
  66462. * Computes the world matrix of the node
  66463. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66464. * @returns the world matrix
  66465. */
  66466. computeWorldMatrix(force?: boolean): Matrix;
  66467. protected _afterComputeWorldMatrix(): void;
  66468. /**
  66469. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66470. * @param func callback function to add
  66471. *
  66472. * @returns the TransformNode.
  66473. */
  66474. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66475. /**
  66476. * Removes a registered callback function.
  66477. * @param func callback function to remove
  66478. * @returns the TransformNode.
  66479. */
  66480. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66481. /**
  66482. * Gets the position of the current mesh in camera space
  66483. * @param camera defines the camera to use
  66484. * @returns a position
  66485. */
  66486. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66487. /**
  66488. * Returns the distance from the mesh to the active camera
  66489. * @param camera defines the camera to use
  66490. * @returns the distance
  66491. */
  66492. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66493. /**
  66494. * Clone the current transform node
  66495. * @param name Name of the new clone
  66496. * @param newParent New parent for the clone
  66497. * @param doNotCloneChildren Do not clone children hierarchy
  66498. * @returns the new transform node
  66499. */
  66500. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66501. /**
  66502. * Serializes the objects information.
  66503. * @param currentSerializationObject defines the object to serialize in
  66504. * @returns the serialized object
  66505. */
  66506. serialize(currentSerializationObject?: any): any;
  66507. /**
  66508. * Returns a new TransformNode object parsed from the source provided.
  66509. * @param parsedTransformNode is the source.
  66510. * @param scene the scne the object belongs to
  66511. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66512. * @returns a new TransformNode object parsed from the source provided.
  66513. */
  66514. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66515. /**
  66516. * Get all child-transformNodes of this node
  66517. * @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
  66518. * @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
  66519. * @returns an array of TransformNode
  66520. */
  66521. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66522. /**
  66523. * Releases resources associated with this transform node.
  66524. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66525. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66526. */
  66527. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66528. }
  66529. }
  66530. declare module BABYLON {
  66531. /**
  66532. * Class used to override all child animations of a given target
  66533. */
  66534. export class AnimationPropertiesOverride {
  66535. /**
  66536. * Gets or sets a value indicating if animation blending must be used
  66537. */
  66538. enableBlending: boolean;
  66539. /**
  66540. * Gets or sets the blending speed to use when enableBlending is true
  66541. */
  66542. blendingSpeed: number;
  66543. /**
  66544. * Gets or sets the default loop mode to use
  66545. */
  66546. loopMode: number;
  66547. }
  66548. }
  66549. declare module BABYLON {
  66550. /**
  66551. * Class used to store bone information
  66552. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  66553. */
  66554. export class Bone extends Node {
  66555. /**
  66556. * defines the bone name
  66557. */
  66558. name: string;
  66559. private static _tmpVecs;
  66560. private static _tmpQuat;
  66561. private static _tmpMats;
  66562. /**
  66563. * Gets the list of child bones
  66564. */
  66565. children: Bone[];
  66566. /** Gets the animations associated with this bone */
  66567. animations: Animation[];
  66568. /**
  66569. * Gets or sets bone length
  66570. */
  66571. length: number;
  66572. /**
  66573. * @hidden Internal only
  66574. * Set this value to map this bone to a different index in the transform matrices
  66575. * Set this value to -1 to exclude the bone from the transform matrices
  66576. */
  66577. _index: Nullable<number>;
  66578. private _skeleton;
  66579. private _localMatrix;
  66580. private _restPose;
  66581. private _baseMatrix;
  66582. private _absoluteTransform;
  66583. private _invertedAbsoluteTransform;
  66584. private _parent;
  66585. private _scalingDeterminant;
  66586. private _worldTransform;
  66587. private _localScaling;
  66588. private _localRotation;
  66589. private _localPosition;
  66590. private _needToDecompose;
  66591. private _needToCompose;
  66592. /** @hidden */
  66593. _linkedTransformNode: Nullable<TransformNode>;
  66594. /** @hidden */
  66595. /** @hidden */
  66596. _matrix: Matrix;
  66597. /**
  66598. * Create a new bone
  66599. * @param name defines the bone name
  66600. * @param skeleton defines the parent skeleton
  66601. * @param parentBone defines the parent (can be null if the bone is the root)
  66602. * @param localMatrix defines the local matrix
  66603. * @param restPose defines the rest pose matrix
  66604. * @param baseMatrix defines the base matrix
  66605. * @param index defines index of the bone in the hiearchy
  66606. */
  66607. constructor(
  66608. /**
  66609. * defines the bone name
  66610. */
  66611. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  66612. /**
  66613. * Gets the current object class name.
  66614. * @return the class name
  66615. */
  66616. getClassName(): string;
  66617. /**
  66618. * Gets the parent skeleton
  66619. * @returns a skeleton
  66620. */
  66621. getSkeleton(): Skeleton;
  66622. /**
  66623. * Gets parent bone
  66624. * @returns a bone or null if the bone is the root of the bone hierarchy
  66625. */
  66626. getParent(): Nullable<Bone>;
  66627. /**
  66628. * Returns an array containing the root bones
  66629. * @returns an array containing the root bones
  66630. */
  66631. getChildren(): Array<Bone>;
  66632. /**
  66633. * Sets the parent bone
  66634. * @param parent defines the parent (can be null if the bone is the root)
  66635. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66636. */
  66637. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  66638. /**
  66639. * Gets the local matrix
  66640. * @returns a matrix
  66641. */
  66642. getLocalMatrix(): Matrix;
  66643. /**
  66644. * Gets the base matrix (initial matrix which remains unchanged)
  66645. * @returns a matrix
  66646. */
  66647. getBaseMatrix(): Matrix;
  66648. /**
  66649. * Gets the rest pose matrix
  66650. * @returns a matrix
  66651. */
  66652. getRestPose(): Matrix;
  66653. /**
  66654. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  66655. */
  66656. getWorldMatrix(): Matrix;
  66657. /**
  66658. * Sets the local matrix to rest pose matrix
  66659. */
  66660. returnToRest(): void;
  66661. /**
  66662. * Gets the inverse of the absolute transform matrix.
  66663. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  66664. * @returns a matrix
  66665. */
  66666. getInvertedAbsoluteTransform(): Matrix;
  66667. /**
  66668. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  66669. * @returns a matrix
  66670. */
  66671. getAbsoluteTransform(): Matrix;
  66672. /**
  66673. * Links with the given transform node.
  66674. * The local matrix of this bone is copied from the transform node every frame.
  66675. * @param transformNode defines the transform node to link to
  66676. */
  66677. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  66678. /** Gets or sets current position (in local space) */
  66679. position: Vector3;
  66680. /** Gets or sets current rotation (in local space) */
  66681. rotation: Vector3;
  66682. /** Gets or sets current rotation quaternion (in local space) */
  66683. rotationQuaternion: Quaternion;
  66684. /** Gets or sets current scaling (in local space) */
  66685. scaling: Vector3;
  66686. /**
  66687. * Gets the animation properties override
  66688. */
  66689. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  66690. private _decompose;
  66691. private _compose;
  66692. /**
  66693. * Update the base and local matrices
  66694. * @param matrix defines the new base or local matrix
  66695. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66696. * @param updateLocalMatrix defines if the local matrix should be updated
  66697. */
  66698. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  66699. /** @hidden */
  66700. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  66701. /**
  66702. * Flag the bone as dirty (Forcing it to update everything)
  66703. */
  66704. markAsDirty(): void;
  66705. private _markAsDirtyAndCompose;
  66706. private _markAsDirtyAndDecompose;
  66707. /**
  66708. * Translate the bone in local or world space
  66709. * @param vec The amount to translate the bone
  66710. * @param space The space that the translation is in
  66711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66712. */
  66713. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66714. /**
  66715. * Set the postion of the bone in local or world space
  66716. * @param position The position to set the bone
  66717. * @param space The space that the position is in
  66718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66719. */
  66720. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66721. /**
  66722. * Set the absolute position of the bone (world space)
  66723. * @param position The position to set the bone
  66724. * @param mesh The mesh that this bone is attached to
  66725. */
  66726. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  66727. /**
  66728. * Scale the bone on the x, y and z axes (in local space)
  66729. * @param x The amount to scale the bone on the x axis
  66730. * @param y The amount to scale the bone on the y axis
  66731. * @param z The amount to scale the bone on the z axis
  66732. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  66733. */
  66734. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  66735. /**
  66736. * Set the bone scaling in local space
  66737. * @param scale defines the scaling vector
  66738. */
  66739. setScale(scale: Vector3): void;
  66740. /**
  66741. * Gets the current scaling in local space
  66742. * @returns the current scaling vector
  66743. */
  66744. getScale(): Vector3;
  66745. /**
  66746. * Gets the current scaling in local space and stores it in a target vector
  66747. * @param result defines the target vector
  66748. */
  66749. getScaleToRef(result: Vector3): void;
  66750. /**
  66751. * Set the yaw, pitch, and roll of the bone in local or world space
  66752. * @param yaw The rotation of the bone on the y axis
  66753. * @param pitch The rotation of the bone on the x axis
  66754. * @param roll The rotation of the bone on the z axis
  66755. * @param space The space that the axes of rotation are in
  66756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66757. */
  66758. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  66759. /**
  66760. * Add a rotation to the bone on an axis in local or world space
  66761. * @param axis The axis to rotate the bone on
  66762. * @param amount The amount to rotate the bone
  66763. * @param space The space that the axis is in
  66764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66765. */
  66766. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  66767. /**
  66768. * Set the rotation of the bone to a particular axis angle in local or world space
  66769. * @param axis The axis to rotate the bone on
  66770. * @param angle The angle that the bone should be rotated to
  66771. * @param space The space that the axis is in
  66772. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66773. */
  66774. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  66775. /**
  66776. * Set the euler rotation of the bone in local of world space
  66777. * @param rotation The euler rotation that the bone should be set to
  66778. * @param space The space that the rotation is in
  66779. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66780. */
  66781. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66782. /**
  66783. * Set the quaternion rotation of the bone in local of world space
  66784. * @param quat The quaternion rotation that the bone should be set to
  66785. * @param space The space that the rotation is in
  66786. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66787. */
  66788. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  66789. /**
  66790. * Set the rotation matrix of the bone in local of world space
  66791. * @param rotMat The rotation matrix that the bone should be set to
  66792. * @param space The space that the rotation is in
  66793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66794. */
  66795. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  66796. private _rotateWithMatrix;
  66797. private _getNegativeRotationToRef;
  66798. /**
  66799. * Get the position of the bone in local or world space
  66800. * @param space The space that the returned position is in
  66801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66802. * @returns The position of the bone
  66803. */
  66804. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66805. /**
  66806. * Copy the position of the bone to a vector3 in local or world space
  66807. * @param space The space that the returned position is in
  66808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66809. * @param result The vector3 to copy the position to
  66810. */
  66811. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  66812. /**
  66813. * Get the absolute position of the bone (world space)
  66814. * @param mesh The mesh that this bone is attached to
  66815. * @returns The absolute position of the bone
  66816. */
  66817. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  66818. /**
  66819. * Copy the absolute position of the bone (world space) to the result param
  66820. * @param mesh The mesh that this bone is attached to
  66821. * @param result The vector3 to copy the absolute position to
  66822. */
  66823. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  66824. /**
  66825. * Compute the absolute transforms of this bone and its children
  66826. */
  66827. computeAbsoluteTransforms(): void;
  66828. /**
  66829. * Get the world direction from an axis that is in the local space of the bone
  66830. * @param localAxis The local direction that is used to compute the world direction
  66831. * @param mesh The mesh that this bone is attached to
  66832. * @returns The world direction
  66833. */
  66834. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66835. /**
  66836. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  66837. * @param localAxis The local direction that is used to compute the world direction
  66838. * @param mesh The mesh that this bone is attached to
  66839. * @param result The vector3 that the world direction will be copied to
  66840. */
  66841. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66842. /**
  66843. * Get the euler rotation of the bone in local or world space
  66844. * @param space The space that the rotation should be in
  66845. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66846. * @returns The euler rotation
  66847. */
  66848. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66849. /**
  66850. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  66851. * @param space The space that the rotation should be in
  66852. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66853. * @param result The vector3 that the rotation should be copied to
  66854. */
  66855. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66856. /**
  66857. * Get the quaternion rotation of the bone in either local or world space
  66858. * @param space The space that the rotation should be in
  66859. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66860. * @returns The quaternion rotation
  66861. */
  66862. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  66863. /**
  66864. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  66865. * @param space The space that the rotation should be in
  66866. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66867. * @param result The quaternion that the rotation should be copied to
  66868. */
  66869. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  66870. /**
  66871. * Get the rotation matrix of the bone in local or world space
  66872. * @param space The space that the rotation should be in
  66873. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66874. * @returns The rotation matrix
  66875. */
  66876. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  66877. /**
  66878. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  66879. * @param space The space that the rotation should be in
  66880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66881. * @param result The quaternion that the rotation should be copied to
  66882. */
  66883. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  66884. /**
  66885. * Get the world position of a point that is in the local space of the bone
  66886. * @param position The local position
  66887. * @param mesh The mesh that this bone is attached to
  66888. * @returns The world position
  66889. */
  66890. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66891. /**
  66892. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  66893. * @param position The local position
  66894. * @param mesh The mesh that this bone is attached to
  66895. * @param result The vector3 that the world position should be copied to
  66896. */
  66897. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66898. /**
  66899. * Get the local position of a point that is in world space
  66900. * @param position The world position
  66901. * @param mesh The mesh that this bone is attached to
  66902. * @returns The local position
  66903. */
  66904. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66905. /**
  66906. * Get the local position of a point that is in world space and copy it to the result param
  66907. * @param position The world position
  66908. * @param mesh The mesh that this bone is attached to
  66909. * @param result The vector3 that the local position should be copied to
  66910. */
  66911. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66912. }
  66913. }
  66914. declare module BABYLON {
  66915. /**
  66916. * Enum that determines the text-wrapping mode to use.
  66917. */
  66918. export enum InspectableType {
  66919. /**
  66920. * Checkbox for booleans
  66921. */
  66922. Checkbox = 0,
  66923. /**
  66924. * Sliders for numbers
  66925. */
  66926. Slider = 1,
  66927. /**
  66928. * Vector3
  66929. */
  66930. Vector3 = 2,
  66931. /**
  66932. * Quaternions
  66933. */
  66934. Quaternion = 3,
  66935. /**
  66936. * Color3
  66937. */
  66938. Color3 = 4
  66939. }
  66940. /**
  66941. * Interface used to define custom inspectable properties.
  66942. * This interface is used by the inspector to display custom property grids
  66943. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66944. */
  66945. export interface IInspectable {
  66946. /**
  66947. * Gets the label to display
  66948. */
  66949. label: string;
  66950. /**
  66951. * Gets the name of the property to edit
  66952. */
  66953. propertyName: string;
  66954. /**
  66955. * Gets the type of the editor to use
  66956. */
  66957. type: InspectableType;
  66958. /**
  66959. * Gets the minimum value of the property when using in "slider" mode
  66960. */
  66961. min?: number;
  66962. /**
  66963. * Gets the maximum value of the property when using in "slider" mode
  66964. */
  66965. max?: number;
  66966. /**
  66967. * Gets the setp to use when using in "slider" mode
  66968. */
  66969. step?: number;
  66970. }
  66971. }
  66972. declare module BABYLON {
  66973. /**
  66974. * Class for creating a cube texture
  66975. */
  66976. export class CubeTexture extends BaseTexture {
  66977. private _delayedOnLoad;
  66978. /**
  66979. * The url of the texture
  66980. */
  66981. url: string;
  66982. /**
  66983. * Gets or sets the center of the bounding box associated with the cube texture.
  66984. * It must define where the camera used to render the texture was set
  66985. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66986. */
  66987. boundingBoxPosition: Vector3;
  66988. private _boundingBoxSize;
  66989. /**
  66990. * Gets or sets the size of the bounding box associated with the cube texture
  66991. * When defined, the cubemap will switch to local mode
  66992. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66993. * @example https://www.babylonjs-playground.com/#RNASML
  66994. */
  66995. /**
  66996. * Returns the bounding box size
  66997. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66998. */
  66999. boundingBoxSize: Vector3;
  67000. protected _rotationY: number;
  67001. /**
  67002. * Sets texture matrix rotation angle around Y axis in radians.
  67003. */
  67004. /**
  67005. * Gets texture matrix rotation angle around Y axis radians.
  67006. */
  67007. rotationY: number;
  67008. /**
  67009. * Are mip maps generated for this texture or not.
  67010. */
  67011. readonly noMipmap: boolean;
  67012. private _noMipmap;
  67013. private _files;
  67014. private _extensions;
  67015. private _textureMatrix;
  67016. private _format;
  67017. private _createPolynomials;
  67018. /** @hidden */
  67019. _prefiltered: boolean;
  67020. /**
  67021. * Creates a cube texture from an array of image urls
  67022. * @param files defines an array of image urls
  67023. * @param scene defines the hosting scene
  67024. * @param noMipmap specifies if mip maps are not used
  67025. * @returns a cube texture
  67026. */
  67027. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67028. /**
  67029. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67030. * @param url defines the url of the prefiltered texture
  67031. * @param scene defines the scene the texture is attached to
  67032. * @param forcedExtension defines the extension of the file if different from the url
  67033. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67034. * @return the prefiltered texture
  67035. */
  67036. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67037. /**
  67038. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67039. * as prefiltered data.
  67040. * @param rootUrl defines the url of the texture or the root name of the six images
  67041. * @param scene defines the scene the texture is attached to
  67042. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67043. * @param noMipmap defines if mipmaps should be created or not
  67044. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67045. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67046. * @param onError defines a callback triggered in case of error during load
  67047. * @param format defines the internal format to use for the texture once loaded
  67048. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67049. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67050. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67051. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67052. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67053. * @return the cube texture
  67054. */
  67055. 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);
  67056. /**
  67057. * Get the current class name of the texture useful for serialization or dynamic coding.
  67058. * @returns "CubeTexture"
  67059. */
  67060. getClassName(): string;
  67061. /**
  67062. * Update the url (and optional buffer) of this texture if url was null during construction.
  67063. * @param url the url of the texture
  67064. * @param forcedExtension defines the extension to use
  67065. * @param onLoad callback called when the texture is loaded (defaults to null)
  67066. */
  67067. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67068. /**
  67069. * Delays loading of the cube texture
  67070. * @param forcedExtension defines the extension to use
  67071. */
  67072. delayLoad(forcedExtension?: string): void;
  67073. /**
  67074. * Returns the reflection texture matrix
  67075. * @returns the reflection texture matrix
  67076. */
  67077. getReflectionTextureMatrix(): Matrix;
  67078. /**
  67079. * Sets the reflection texture matrix
  67080. * @param value Reflection texture matrix
  67081. */
  67082. setReflectionTextureMatrix(value: Matrix): void;
  67083. /**
  67084. * Parses text to create a cube texture
  67085. * @param parsedTexture define the serialized text to read from
  67086. * @param scene defines the hosting scene
  67087. * @param rootUrl defines the root url of the cube texture
  67088. * @returns a cube texture
  67089. */
  67090. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67091. /**
  67092. * Makes a clone, or deep copy, of the cube texture
  67093. * @returns a new cube texture
  67094. */
  67095. clone(): CubeTexture;
  67096. }
  67097. }
  67098. declare module BABYLON {
  67099. /** @hidden */
  67100. export var postprocessVertexShader: {
  67101. name: string;
  67102. shader: string;
  67103. };
  67104. }
  67105. declare module BABYLON {
  67106. /**
  67107. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67108. * This is the base of the follow, arc rotate cameras and Free camera
  67109. * @see http://doc.babylonjs.com/features/cameras
  67110. */
  67111. export class TargetCamera extends Camera {
  67112. private static _RigCamTransformMatrix;
  67113. private static _TargetTransformMatrix;
  67114. private static _TargetFocalPoint;
  67115. /**
  67116. * Define the current direction the camera is moving to
  67117. */
  67118. cameraDirection: Vector3;
  67119. /**
  67120. * Define the current rotation the camera is rotating to
  67121. */
  67122. cameraRotation: Vector2;
  67123. /**
  67124. * When set, the up vector of the camera will be updated by the rotation of the camera
  67125. */
  67126. updateUpVectorFromRotation: boolean;
  67127. private _tmpQuaternion;
  67128. /**
  67129. * Define the current rotation of the camera
  67130. */
  67131. rotation: Vector3;
  67132. /**
  67133. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67134. */
  67135. rotationQuaternion: Quaternion;
  67136. /**
  67137. * Define the current speed of the camera
  67138. */
  67139. speed: number;
  67140. /**
  67141. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67142. * around all axis.
  67143. */
  67144. noRotationConstraint: boolean;
  67145. /**
  67146. * Define the current target of the camera as an object or a position.
  67147. */
  67148. lockedTarget: any;
  67149. /** @hidden */
  67150. _currentTarget: Vector3;
  67151. /** @hidden */
  67152. _initialFocalDistance: number;
  67153. /** @hidden */
  67154. _viewMatrix: Matrix;
  67155. /** @hidden */
  67156. _camMatrix: Matrix;
  67157. /** @hidden */
  67158. _cameraTransformMatrix: Matrix;
  67159. /** @hidden */
  67160. _cameraRotationMatrix: Matrix;
  67161. /** @hidden */
  67162. _referencePoint: Vector3;
  67163. /** @hidden */
  67164. _transformedReferencePoint: Vector3;
  67165. protected _globalCurrentTarget: Vector3;
  67166. protected _globalCurrentUpVector: Vector3;
  67167. /** @hidden */
  67168. _reset: () => void;
  67169. private _defaultUp;
  67170. /**
  67171. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67172. * This is the base of the follow, arc rotate cameras and Free camera
  67173. * @see http://doc.babylonjs.com/features/cameras
  67174. * @param name Defines the name of the camera in the scene
  67175. * @param position Defines the start position of the camera in the scene
  67176. * @param scene Defines the scene the camera belongs to
  67177. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67178. */
  67179. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67180. /**
  67181. * Gets the position in front of the camera at a given distance.
  67182. * @param distance The distance from the camera we want the position to be
  67183. * @returns the position
  67184. */
  67185. getFrontPosition(distance: number): Vector3;
  67186. /** @hidden */
  67187. _getLockedTargetPosition(): Nullable<Vector3>;
  67188. private _storedPosition;
  67189. private _storedRotation;
  67190. private _storedRotationQuaternion;
  67191. /**
  67192. * Store current camera state of the camera (fov, position, rotation, etc..)
  67193. * @returns the camera
  67194. */
  67195. storeState(): Camera;
  67196. /**
  67197. * Restored camera state. You must call storeState() first
  67198. * @returns whether it was successful or not
  67199. * @hidden
  67200. */
  67201. _restoreStateValues(): boolean;
  67202. /** @hidden */
  67203. _initCache(): void;
  67204. /** @hidden */
  67205. _updateCache(ignoreParentClass?: boolean): void;
  67206. /** @hidden */
  67207. _isSynchronizedViewMatrix(): boolean;
  67208. /** @hidden */
  67209. _computeLocalCameraSpeed(): number;
  67210. /**
  67211. * Defines the target the camera should look at.
  67212. * This will automatically adapt alpha beta and radius to fit within the new target.
  67213. * @param target Defines the new target as a Vector or a mesh
  67214. */
  67215. setTarget(target: Vector3): void;
  67216. /**
  67217. * Return the current target position of the camera. This value is expressed in local space.
  67218. * @returns the target position
  67219. */
  67220. getTarget(): Vector3;
  67221. /** @hidden */
  67222. _decideIfNeedsToMove(): boolean;
  67223. /** @hidden */
  67224. _updatePosition(): void;
  67225. /** @hidden */
  67226. _checkInputs(): void;
  67227. protected _updateCameraRotationMatrix(): void;
  67228. /**
  67229. * 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)
  67230. * @returns the current camera
  67231. */
  67232. private _rotateUpVectorWithCameraRotationMatrix;
  67233. private _cachedRotationZ;
  67234. private _cachedQuaternionRotationZ;
  67235. /** @hidden */
  67236. _getViewMatrix(): Matrix;
  67237. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67238. /**
  67239. * @hidden
  67240. */
  67241. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67242. /**
  67243. * @hidden
  67244. */
  67245. _updateRigCameras(): void;
  67246. private _getRigCamPositionAndTarget;
  67247. /**
  67248. * Gets the current object class name.
  67249. * @return the class name
  67250. */
  67251. getClassName(): string;
  67252. }
  67253. }
  67254. declare module BABYLON {
  67255. /**
  67256. * @ignore
  67257. * This is a list of all the different input types that are available in the application.
  67258. * Fo instance: ArcRotateCameraGamepadInput...
  67259. */
  67260. export var CameraInputTypes: {};
  67261. /**
  67262. * This is the contract to implement in order to create a new input class.
  67263. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67264. */
  67265. export interface ICameraInput<TCamera extends Camera> {
  67266. /**
  67267. * Defines the camera the input is attached to.
  67268. */
  67269. camera: Nullable<TCamera>;
  67270. /**
  67271. * Gets the class name of the current intput.
  67272. * @returns the class name
  67273. */
  67274. getClassName(): string;
  67275. /**
  67276. * Get the friendly name associated with the input class.
  67277. * @returns the input friendly name
  67278. */
  67279. getSimpleName(): string;
  67280. /**
  67281. * Attach the input controls to a specific dom element to get the input from.
  67282. * @param element Defines the element the controls should be listened from
  67283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67284. */
  67285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67286. /**
  67287. * Detach the current controls from the specified dom element.
  67288. * @param element Defines the element to stop listening the inputs from
  67289. */
  67290. detachControl(element: Nullable<HTMLElement>): void;
  67291. /**
  67292. * Update the current camera state depending on the inputs that have been used this frame.
  67293. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67294. */
  67295. checkInputs?: () => void;
  67296. }
  67297. /**
  67298. * Represents a map of input types to input instance or input index to input instance.
  67299. */
  67300. export interface CameraInputsMap<TCamera extends Camera> {
  67301. /**
  67302. * Accessor to the input by input type.
  67303. */
  67304. [name: string]: ICameraInput<TCamera>;
  67305. /**
  67306. * Accessor to the input by input index.
  67307. */
  67308. [idx: number]: ICameraInput<TCamera>;
  67309. }
  67310. /**
  67311. * This represents the input manager used within a camera.
  67312. * It helps dealing with all the different kind of input attached to a camera.
  67313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67314. */
  67315. export class CameraInputsManager<TCamera extends Camera> {
  67316. /**
  67317. * Defines the list of inputs attahed to the camera.
  67318. */
  67319. attached: CameraInputsMap<TCamera>;
  67320. /**
  67321. * Defines the dom element the camera is collecting inputs from.
  67322. * This is null if the controls have not been attached.
  67323. */
  67324. attachedElement: Nullable<HTMLElement>;
  67325. /**
  67326. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67327. */
  67328. noPreventDefault: boolean;
  67329. /**
  67330. * Defined the camera the input manager belongs to.
  67331. */
  67332. camera: TCamera;
  67333. /**
  67334. * Update the current camera state depending on the inputs that have been used this frame.
  67335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67336. */
  67337. checkInputs: () => void;
  67338. /**
  67339. * Instantiate a new Camera Input Manager.
  67340. * @param camera Defines the camera the input manager blongs to
  67341. */
  67342. constructor(camera: TCamera);
  67343. /**
  67344. * Add an input method to a camera
  67345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67346. * @param input camera input method
  67347. */
  67348. add(input: ICameraInput<TCamera>): void;
  67349. /**
  67350. * Remove a specific input method from a camera
  67351. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  67352. * @param inputToRemove camera input method
  67353. */
  67354. remove(inputToRemove: ICameraInput<TCamera>): void;
  67355. /**
  67356. * Remove a specific input type from a camera
  67357. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  67358. * @param inputType the type of the input to remove
  67359. */
  67360. removeByType(inputType: string): void;
  67361. private _addCheckInputs;
  67362. /**
  67363. * Attach the input controls to the currently attached dom element to listen the events from.
  67364. * @param input Defines the input to attach
  67365. */
  67366. attachInput(input: ICameraInput<TCamera>): void;
  67367. /**
  67368. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  67369. * @param element Defines the dom element to collect the events from
  67370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67371. */
  67372. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  67373. /**
  67374. * Detach the current manager inputs controls from a specific dom element.
  67375. * @param element Defines the dom element to collect the events from
  67376. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  67377. */
  67378. detachElement(element: HTMLElement, disconnect?: boolean): void;
  67379. /**
  67380. * Rebuild the dynamic inputCheck function from the current list of
  67381. * defined inputs in the manager.
  67382. */
  67383. rebuildInputCheck(): void;
  67384. /**
  67385. * Remove all attached input methods from a camera
  67386. */
  67387. clear(): void;
  67388. /**
  67389. * Serialize the current input manager attached to a camera.
  67390. * This ensures than once parsed,
  67391. * the input associated to the camera will be identical to the current ones
  67392. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  67393. */
  67394. serialize(serializedCamera: any): void;
  67395. /**
  67396. * Parses an input manager serialized JSON to restore the previous list of inputs
  67397. * and states associated to a camera.
  67398. * @param parsedCamera Defines the JSON to parse
  67399. */
  67400. parse(parsedCamera: any): void;
  67401. }
  67402. }
  67403. declare module BABYLON {
  67404. /**
  67405. * Gather the list of keyboard event types as constants.
  67406. */
  67407. export class KeyboardEventTypes {
  67408. /**
  67409. * The keydown event is fired when a key becomes active (pressed).
  67410. */
  67411. static readonly KEYDOWN: number;
  67412. /**
  67413. * The keyup event is fired when a key has been released.
  67414. */
  67415. static readonly KEYUP: number;
  67416. }
  67417. /**
  67418. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67419. */
  67420. export class KeyboardInfo {
  67421. /**
  67422. * Defines the type of event (KeyboardEventTypes)
  67423. */
  67424. type: number;
  67425. /**
  67426. * Defines the related dom event
  67427. */
  67428. event: KeyboardEvent;
  67429. /**
  67430. * Instantiates a new keyboard info.
  67431. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67432. * @param type Defines the type of event (KeyboardEventTypes)
  67433. * @param event Defines the related dom event
  67434. */
  67435. constructor(
  67436. /**
  67437. * Defines the type of event (KeyboardEventTypes)
  67438. */
  67439. type: number,
  67440. /**
  67441. * Defines the related dom event
  67442. */
  67443. event: KeyboardEvent);
  67444. }
  67445. /**
  67446. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67447. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  67448. */
  67449. export class KeyboardInfoPre extends KeyboardInfo {
  67450. /**
  67451. * Defines the type of event (KeyboardEventTypes)
  67452. */
  67453. type: number;
  67454. /**
  67455. * Defines the related dom event
  67456. */
  67457. event: KeyboardEvent;
  67458. /**
  67459. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  67460. */
  67461. skipOnPointerObservable: boolean;
  67462. /**
  67463. * Instantiates a new keyboard pre info.
  67464. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67465. * @param type Defines the type of event (KeyboardEventTypes)
  67466. * @param event Defines the related dom event
  67467. */
  67468. constructor(
  67469. /**
  67470. * Defines the type of event (KeyboardEventTypes)
  67471. */
  67472. type: number,
  67473. /**
  67474. * Defines the related dom event
  67475. */
  67476. event: KeyboardEvent);
  67477. }
  67478. }
  67479. declare module BABYLON {
  67480. /**
  67481. * Manage the keyboard inputs to control the movement of a free camera.
  67482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67483. */
  67484. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  67485. /**
  67486. * Defines the camera the input is attached to.
  67487. */
  67488. camera: FreeCamera;
  67489. /**
  67490. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  67491. */
  67492. keysUp: number[];
  67493. /**
  67494. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  67495. */
  67496. keysDown: number[];
  67497. /**
  67498. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  67499. */
  67500. keysLeft: number[];
  67501. /**
  67502. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  67503. */
  67504. keysRight: number[];
  67505. private _keys;
  67506. private _onCanvasBlurObserver;
  67507. private _onKeyboardObserver;
  67508. private _engine;
  67509. private _scene;
  67510. /**
  67511. * Attach the input controls to a specific dom element to get the input from.
  67512. * @param element Defines the element the controls should be listened from
  67513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67514. */
  67515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67516. /**
  67517. * Detach the current controls from the specified dom element.
  67518. * @param element Defines the element to stop listening the inputs from
  67519. */
  67520. detachControl(element: Nullable<HTMLElement>): void;
  67521. /**
  67522. * Update the current camera state depending on the inputs that have been used this frame.
  67523. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67524. */
  67525. checkInputs(): void;
  67526. /**
  67527. * Gets the class name of the current intput.
  67528. * @returns the class name
  67529. */
  67530. getClassName(): string;
  67531. /** @hidden */
  67532. _onLostFocus(): void;
  67533. /**
  67534. * Get the friendly name associated with the input class.
  67535. * @returns the input friendly name
  67536. */
  67537. getSimpleName(): string;
  67538. }
  67539. }
  67540. declare module BABYLON {
  67541. /**
  67542. * Interface describing all the common properties and methods a shadow light needs to implement.
  67543. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  67544. * as well as binding the different shadow properties to the effects.
  67545. */
  67546. export interface IShadowLight extends Light {
  67547. /**
  67548. * The light id in the scene (used in scene.findLighById for instance)
  67549. */
  67550. id: string;
  67551. /**
  67552. * The position the shdow will be casted from.
  67553. */
  67554. position: Vector3;
  67555. /**
  67556. * In 2d mode (needCube being false), the direction used to cast the shadow.
  67557. */
  67558. direction: Vector3;
  67559. /**
  67560. * The transformed position. Position of the light in world space taking parenting in account.
  67561. */
  67562. transformedPosition: Vector3;
  67563. /**
  67564. * The transformed direction. Direction of the light in world space taking parenting in account.
  67565. */
  67566. transformedDirection: Vector3;
  67567. /**
  67568. * The friendly name of the light in the scene.
  67569. */
  67570. name: string;
  67571. /**
  67572. * Defines the shadow projection clipping minimum z value.
  67573. */
  67574. shadowMinZ: number;
  67575. /**
  67576. * Defines the shadow projection clipping maximum z value.
  67577. */
  67578. shadowMaxZ: number;
  67579. /**
  67580. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67581. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67582. */
  67583. computeTransformedInformation(): boolean;
  67584. /**
  67585. * Gets the scene the light belongs to.
  67586. * @returns The scene
  67587. */
  67588. getScene(): Scene;
  67589. /**
  67590. * Callback defining a custom Projection Matrix Builder.
  67591. * This can be used to override the default projection matrix computation.
  67592. */
  67593. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67594. /**
  67595. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67596. * @param matrix The materix to updated with the projection information
  67597. * @param viewMatrix The transform matrix of the light
  67598. * @param renderList The list of mesh to render in the map
  67599. * @returns The current light
  67600. */
  67601. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67602. /**
  67603. * Gets the current depth scale used in ESM.
  67604. * @returns The scale
  67605. */
  67606. getDepthScale(): number;
  67607. /**
  67608. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67609. * @returns true if a cube texture needs to be use
  67610. */
  67611. needCube(): boolean;
  67612. /**
  67613. * Detects if the projection matrix requires to be recomputed this frame.
  67614. * @returns true if it requires to be recomputed otherwise, false.
  67615. */
  67616. needProjectionMatrixCompute(): boolean;
  67617. /**
  67618. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67619. */
  67620. forceProjectionMatrixCompute(): void;
  67621. /**
  67622. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67623. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67624. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67625. */
  67626. getShadowDirection(faceIndex?: number): Vector3;
  67627. /**
  67628. * Gets the minZ used for shadow according to both the scene and the light.
  67629. * @param activeCamera The camera we are returning the min for
  67630. * @returns the depth min z
  67631. */
  67632. getDepthMinZ(activeCamera: Camera): number;
  67633. /**
  67634. * Gets the maxZ used for shadow according to both the scene and the light.
  67635. * @param activeCamera The camera we are returning the max for
  67636. * @returns the depth max z
  67637. */
  67638. getDepthMaxZ(activeCamera: Camera): number;
  67639. }
  67640. /**
  67641. * Base implementation IShadowLight
  67642. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  67643. */
  67644. export abstract class ShadowLight extends Light implements IShadowLight {
  67645. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67646. protected _position: Vector3;
  67647. protected _setPosition(value: Vector3): void;
  67648. /**
  67649. * Sets the position the shadow will be casted from. Also use as the light position for both
  67650. * point and spot lights.
  67651. */
  67652. /**
  67653. * Sets the position the shadow will be casted from. Also use as the light position for both
  67654. * point and spot lights.
  67655. */
  67656. position: Vector3;
  67657. protected _direction: Vector3;
  67658. protected _setDirection(value: Vector3): void;
  67659. /**
  67660. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  67661. * Also use as the light direction on spot and directional lights.
  67662. */
  67663. /**
  67664. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  67665. * Also use as the light direction on spot and directional lights.
  67666. */
  67667. direction: Vector3;
  67668. private _shadowMinZ;
  67669. /**
  67670. * Gets the shadow projection clipping minimum z value.
  67671. */
  67672. /**
  67673. * Sets the shadow projection clipping minimum z value.
  67674. */
  67675. shadowMinZ: number;
  67676. private _shadowMaxZ;
  67677. /**
  67678. * Sets the shadow projection clipping maximum z value.
  67679. */
  67680. /**
  67681. * Gets the shadow projection clipping maximum z value.
  67682. */
  67683. shadowMaxZ: number;
  67684. /**
  67685. * Callback defining a custom Projection Matrix Builder.
  67686. * This can be used to override the default projection matrix computation.
  67687. */
  67688. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67689. /**
  67690. * The transformed position. Position of the light in world space taking parenting in account.
  67691. */
  67692. transformedPosition: Vector3;
  67693. /**
  67694. * The transformed direction. Direction of the light in world space taking parenting in account.
  67695. */
  67696. transformedDirection: Vector3;
  67697. private _needProjectionMatrixCompute;
  67698. /**
  67699. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67700. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67701. */
  67702. computeTransformedInformation(): boolean;
  67703. /**
  67704. * Return the depth scale used for the shadow map.
  67705. * @returns the depth scale.
  67706. */
  67707. getDepthScale(): number;
  67708. /**
  67709. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67710. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67711. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67712. */
  67713. getShadowDirection(faceIndex?: number): Vector3;
  67714. /**
  67715. * Returns the ShadowLight absolute position in the World.
  67716. * @returns the position vector in world space
  67717. */
  67718. getAbsolutePosition(): Vector3;
  67719. /**
  67720. * Sets the ShadowLight direction toward the passed target.
  67721. * @param target The point to target in local space
  67722. * @returns the updated ShadowLight direction
  67723. */
  67724. setDirectionToTarget(target: Vector3): Vector3;
  67725. /**
  67726. * Returns the light rotation in euler definition.
  67727. * @returns the x y z rotation in local space.
  67728. */
  67729. getRotation(): Vector3;
  67730. /**
  67731. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67732. * @returns true if a cube texture needs to be use
  67733. */
  67734. needCube(): boolean;
  67735. /**
  67736. * Detects if the projection matrix requires to be recomputed this frame.
  67737. * @returns true if it requires to be recomputed otherwise, false.
  67738. */
  67739. needProjectionMatrixCompute(): boolean;
  67740. /**
  67741. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67742. */
  67743. forceProjectionMatrixCompute(): void;
  67744. /** @hidden */
  67745. _initCache(): void;
  67746. /** @hidden */
  67747. _isSynchronized(): boolean;
  67748. /**
  67749. * Computes the world matrix of the node
  67750. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67751. * @returns the world matrix
  67752. */
  67753. computeWorldMatrix(force?: boolean): Matrix;
  67754. /**
  67755. * Gets the minZ used for shadow according to both the scene and the light.
  67756. * @param activeCamera The camera we are returning the min for
  67757. * @returns the depth min z
  67758. */
  67759. getDepthMinZ(activeCamera: Camera): number;
  67760. /**
  67761. * Gets the maxZ used for shadow according to both the scene and the light.
  67762. * @param activeCamera The camera we are returning the max for
  67763. * @returns the depth max z
  67764. */
  67765. getDepthMaxZ(activeCamera: Camera): number;
  67766. /**
  67767. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67768. * @param matrix The materix to updated with the projection information
  67769. * @param viewMatrix The transform matrix of the light
  67770. * @param renderList The list of mesh to render in the map
  67771. * @returns The current light
  67772. */
  67773. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67774. }
  67775. }
  67776. declare module BABYLON {
  67777. /**
  67778. * "Static Class" containing the most commonly used helper while dealing with material for
  67779. * rendering purpose.
  67780. *
  67781. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  67782. *
  67783. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  67784. */
  67785. export class MaterialHelper {
  67786. /**
  67787. * Bind the current view position to an effect.
  67788. * @param effect The effect to be bound
  67789. * @param scene The scene the eyes position is used from
  67790. */
  67791. static BindEyePosition(effect: Effect, scene: Scene): void;
  67792. /**
  67793. * Helps preparing the defines values about the UVs in used in the effect.
  67794. * UVs are shared as much as we can accross channels in the shaders.
  67795. * @param texture The texture we are preparing the UVs for
  67796. * @param defines The defines to update
  67797. * @param key The channel key "diffuse", "specular"... used in the shader
  67798. */
  67799. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  67800. /**
  67801. * Binds a texture matrix value to its corrsponding uniform
  67802. * @param texture The texture to bind the matrix for
  67803. * @param uniformBuffer The uniform buffer receivin the data
  67804. * @param key The channel key "diffuse", "specular"... used in the shader
  67805. */
  67806. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  67807. /**
  67808. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  67809. * @param mesh defines the current mesh
  67810. * @param scene defines the current scene
  67811. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  67812. * @param pointsCloud defines if point cloud rendering has to be turned on
  67813. * @param fogEnabled defines if fog has to be turned on
  67814. * @param alphaTest defines if alpha testing has to be turned on
  67815. * @param defines defines the current list of defines
  67816. */
  67817. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  67818. /**
  67819. * Helper used to prepare the list of defines associated with frame values for shader compilation
  67820. * @param scene defines the current scene
  67821. * @param engine defines the current engine
  67822. * @param defines specifies the list of active defines
  67823. * @param useInstances defines if instances have to be turned on
  67824. * @param useClipPlane defines if clip plane have to be turned on
  67825. */
  67826. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  67827. /**
  67828. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  67829. * @param mesh The mesh containing the geometry data we will draw
  67830. * @param defines The defines to update
  67831. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  67832. * @param useBones Precise whether bones should be used or not (override mesh info)
  67833. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  67834. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  67835. * @returns false if defines are considered not dirty and have not been checked
  67836. */
  67837. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  67838. /**
  67839. * Prepares the defines related to the light information passed in parameter
  67840. * @param scene The scene we are intending to draw
  67841. * @param mesh The mesh the effect is compiling for
  67842. * @param defines The defines to update
  67843. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67844. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67845. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67846. * @returns true if normals will be required for the rest of the effect
  67847. */
  67848. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  67849. /**
  67850. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67851. * that won t be acctive due to defines being turned off.
  67852. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67853. * @param samplersList The samplers list
  67854. * @param defines The defines helping in the list generation
  67855. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67856. */
  67857. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  67858. /**
  67859. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67860. * @param defines The defines to update while falling back
  67861. * @param fallbacks The authorized effect fallbacks
  67862. * @param maxSimultaneousLights The maximum number of lights allowed
  67863. * @param rank the current rank of the Effect
  67864. * @returns The newly affected rank
  67865. */
  67866. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  67867. /**
  67868. * Prepares the list of attributes required for morph targets according to the effect defines.
  67869. * @param attribs The current list of supported attribs
  67870. * @param mesh The mesh to prepare the morph targets attributes for
  67871. * @param defines The current Defines of the effect
  67872. */
  67873. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  67874. /**
  67875. * Prepares the list of attributes required for bones according to the effect defines.
  67876. * @param attribs The current list of supported attribs
  67877. * @param mesh The mesh to prepare the bones attributes for
  67878. * @param defines The current Defines of the effect
  67879. * @param fallbacks The current efffect fallback strategy
  67880. */
  67881. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  67882. /**
  67883. * Prepares the list of attributes required for instances according to the effect defines.
  67884. * @param attribs The current list of supported attribs
  67885. * @param defines The current Defines of the effect
  67886. */
  67887. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  67888. /**
  67889. * Binds the light shadow information to the effect for the given mesh.
  67890. * @param light The light containing the generator
  67891. * @param scene The scene the lights belongs to
  67892. * @param mesh The mesh we are binding the information to render
  67893. * @param lightIndex The light index in the effect used to render the mesh
  67894. * @param effect The effect we are binding the data to
  67895. */
  67896. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  67897. /**
  67898. * Binds the light information to the effect.
  67899. * @param light The light containing the generator
  67900. * @param effect The effect we are binding the data to
  67901. * @param lightIndex The light index in the effect used to render
  67902. */
  67903. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  67904. /**
  67905. * Binds the lights information from the scene to the effect for the given mesh.
  67906. * @param scene The scene the lights belongs to
  67907. * @param mesh The mesh we are binding the information to render
  67908. * @param effect The effect we are binding the data to
  67909. * @param defines The generated defines for the effect
  67910. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67911. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67912. */
  67913. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  67914. private static _tempFogColor;
  67915. /**
  67916. * Binds the fog information from the scene to the effect for the given mesh.
  67917. * @param scene The scene the lights belongs to
  67918. * @param mesh The mesh we are binding the information to render
  67919. * @param effect The effect we are binding the data to
  67920. * @param linearSpace Defines if the fog effect is applied in linear space
  67921. */
  67922. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  67923. /**
  67924. * Binds the bones information from the mesh to the effect.
  67925. * @param mesh The mesh we are binding the information to render
  67926. * @param effect The effect we are binding the data to
  67927. */
  67928. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  67929. /**
  67930. * Binds the morph targets information from the mesh to the effect.
  67931. * @param abstractMesh The mesh we are binding the information to render
  67932. * @param effect The effect we are binding the data to
  67933. */
  67934. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  67935. /**
  67936. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67937. * @param defines The generated defines used in the effect
  67938. * @param effect The effect we are binding the data to
  67939. * @param scene The scene we are willing to render with logarithmic scale for
  67940. */
  67941. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  67942. /**
  67943. * Binds the clip plane information from the scene to the effect.
  67944. * @param scene The scene the clip plane information are extracted from
  67945. * @param effect The effect we are binding the data to
  67946. */
  67947. static BindClipPlane(effect: Effect, scene: Scene): void;
  67948. }
  67949. }
  67950. declare module BABYLON {
  67951. /** @hidden */
  67952. export var kernelBlurVaryingDeclaration: {
  67953. name: string;
  67954. shader: string;
  67955. };
  67956. }
  67957. declare module BABYLON {
  67958. /** @hidden */
  67959. export var kernelBlurFragment: {
  67960. name: string;
  67961. shader: string;
  67962. };
  67963. }
  67964. declare module BABYLON {
  67965. /** @hidden */
  67966. export var kernelBlurFragment2: {
  67967. name: string;
  67968. shader: string;
  67969. };
  67970. }
  67971. declare module BABYLON {
  67972. /** @hidden */
  67973. export var kernelBlurPixelShader: {
  67974. name: string;
  67975. shader: string;
  67976. };
  67977. }
  67978. declare module BABYLON {
  67979. /** @hidden */
  67980. export var kernelBlurVertex: {
  67981. name: string;
  67982. shader: string;
  67983. };
  67984. }
  67985. declare module BABYLON {
  67986. /** @hidden */
  67987. export var kernelBlurVertexShader: {
  67988. name: string;
  67989. shader: string;
  67990. };
  67991. }
  67992. declare module BABYLON {
  67993. /**
  67994. * The Blur Post Process which blurs an image based on a kernel and direction.
  67995. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67996. */
  67997. export class BlurPostProcess extends PostProcess {
  67998. /** The direction in which to blur the image. */
  67999. direction: Vector2;
  68000. private blockCompilation;
  68001. protected _kernel: number;
  68002. protected _idealKernel: number;
  68003. protected _packedFloat: boolean;
  68004. private _staticDefines;
  68005. /**
  68006. * Sets the length in pixels of the blur sample region
  68007. */
  68008. /**
  68009. * Gets the length in pixels of the blur sample region
  68010. */
  68011. kernel: number;
  68012. /**
  68013. * Sets wether or not the blur needs to unpack/repack floats
  68014. */
  68015. /**
  68016. * Gets wether or not the blur is unpacking/repacking floats
  68017. */
  68018. packedFloat: boolean;
  68019. /**
  68020. * Creates a new instance BlurPostProcess
  68021. * @param name The name of the effect.
  68022. * @param direction The direction in which to blur the image.
  68023. * @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.
  68024. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68025. * @param camera The camera to apply the render pass to.
  68026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68027. * @param engine The engine which the post process will be applied. (default: current engine)
  68028. * @param reusable If the post process can be reused on the same frame. (default: false)
  68029. * @param textureType Type of textures used when performing the post process. (default: 0)
  68030. * @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)
  68031. */
  68032. constructor(name: string,
  68033. /** The direction in which to blur the image. */
  68034. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68035. /**
  68036. * Updates the effect with the current post process compile time values and recompiles the shader.
  68037. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68038. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68039. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68040. * @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
  68041. * @param onCompiled Called when the shader has been compiled.
  68042. * @param onError Called if there is an error when compiling a shader.
  68043. */
  68044. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68045. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68046. /**
  68047. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68048. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68049. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68050. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68051. * The gaps between physical kernels are compensated for in the weighting of the samples
  68052. * @param idealKernel Ideal blur kernel.
  68053. * @return Nearest best kernel.
  68054. */
  68055. protected _nearestBestKernel(idealKernel: number): number;
  68056. /**
  68057. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68058. * @param x The point on the Gaussian distribution to sample.
  68059. * @return the value of the Gaussian function at x.
  68060. */
  68061. protected _gaussianWeight(x: number): number;
  68062. /**
  68063. * Generates a string that can be used as a floating point number in GLSL.
  68064. * @param x Value to print.
  68065. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68066. * @return GLSL float string.
  68067. */
  68068. protected _glslFloat(x: number, decimalFigures?: number): string;
  68069. }
  68070. }
  68071. declare module BABYLON {
  68072. /** @hidden */
  68073. export var shadowMapPixelShader: {
  68074. name: string;
  68075. shader: string;
  68076. };
  68077. }
  68078. declare module BABYLON {
  68079. /** @hidden */
  68080. export var bonesDeclaration: {
  68081. name: string;
  68082. shader: string;
  68083. };
  68084. }
  68085. declare module BABYLON {
  68086. /** @hidden */
  68087. export var morphTargetsVertexGlobalDeclaration: {
  68088. name: string;
  68089. shader: string;
  68090. };
  68091. }
  68092. declare module BABYLON {
  68093. /** @hidden */
  68094. export var morphTargetsVertexDeclaration: {
  68095. name: string;
  68096. shader: string;
  68097. };
  68098. }
  68099. declare module BABYLON {
  68100. /** @hidden */
  68101. export var instancesDeclaration: {
  68102. name: string;
  68103. shader: string;
  68104. };
  68105. }
  68106. declare module BABYLON {
  68107. /** @hidden */
  68108. export var helperFunctions: {
  68109. name: string;
  68110. shader: string;
  68111. };
  68112. }
  68113. declare module BABYLON {
  68114. /** @hidden */
  68115. export var morphTargetsVertex: {
  68116. name: string;
  68117. shader: string;
  68118. };
  68119. }
  68120. declare module BABYLON {
  68121. /** @hidden */
  68122. export var instancesVertex: {
  68123. name: string;
  68124. shader: string;
  68125. };
  68126. }
  68127. declare module BABYLON {
  68128. /** @hidden */
  68129. export var bonesVertex: {
  68130. name: string;
  68131. shader: string;
  68132. };
  68133. }
  68134. declare module BABYLON {
  68135. /** @hidden */
  68136. export var shadowMapVertexShader: {
  68137. name: string;
  68138. shader: string;
  68139. };
  68140. }
  68141. declare module BABYLON {
  68142. /** @hidden */
  68143. export var depthBoxBlurPixelShader: {
  68144. name: string;
  68145. shader: string;
  68146. };
  68147. }
  68148. declare module BABYLON {
  68149. /**
  68150. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68151. */
  68152. export interface ICustomShaderOptions {
  68153. /**
  68154. * Gets or sets the custom shader name to use
  68155. */
  68156. shaderName: string;
  68157. /**
  68158. * The list of attribute names used in the shader
  68159. */
  68160. attributes?: string[];
  68161. /**
  68162. * The list of unifrom names used in the shader
  68163. */
  68164. uniforms?: string[];
  68165. /**
  68166. * The list of sampler names used in the shader
  68167. */
  68168. samplers?: string[];
  68169. /**
  68170. * The list of defines used in the shader
  68171. */
  68172. defines?: string[];
  68173. }
  68174. /**
  68175. * Interface to implement to create a shadow generator compatible with BJS.
  68176. */
  68177. export interface IShadowGenerator {
  68178. /**
  68179. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68180. * @returns The render target texture if present otherwise, null
  68181. */
  68182. getShadowMap(): Nullable<RenderTargetTexture>;
  68183. /**
  68184. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68185. * @returns The render target texture if the shadow map is present otherwise, null
  68186. */
  68187. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68188. /**
  68189. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68190. * @param subMesh The submesh we want to render in the shadow map
  68191. * @param useInstances Defines wether will draw in the map using instances
  68192. * @returns true if ready otherwise, false
  68193. */
  68194. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68195. /**
  68196. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68197. * @param defines Defines of the material we want to update
  68198. * @param lightIndex Index of the light in the enabled light list of the material
  68199. */
  68200. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68201. /**
  68202. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68203. * defined in the generator but impacting the effect).
  68204. * It implies the unifroms available on the materials are the standard BJS ones.
  68205. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68206. * @param effect The effect we are binfing the information for
  68207. */
  68208. bindShadowLight(lightIndex: string, effect: Effect): void;
  68209. /**
  68210. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68211. * (eq to shadow prjection matrix * light transform matrix)
  68212. * @returns The transform matrix used to create the shadow map
  68213. */
  68214. getTransformMatrix(): Matrix;
  68215. /**
  68216. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68217. * Cube and 2D textures for instance.
  68218. */
  68219. recreateShadowMap(): void;
  68220. /**
  68221. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68222. * @param onCompiled Callback triggered at the and of the effects compilation
  68223. * @param options Sets of optional options forcing the compilation with different modes
  68224. */
  68225. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68226. useInstances: boolean;
  68227. }>): void;
  68228. /**
  68229. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68230. * @param options Sets of optional options forcing the compilation with different modes
  68231. * @returns A promise that resolves when the compilation completes
  68232. */
  68233. forceCompilationAsync(options?: Partial<{
  68234. useInstances: boolean;
  68235. }>): Promise<void>;
  68236. /**
  68237. * Serializes the shadow generator setup to a json object.
  68238. * @returns The serialized JSON object
  68239. */
  68240. serialize(): any;
  68241. /**
  68242. * Disposes the Shadow map and related Textures and effects.
  68243. */
  68244. dispose(): void;
  68245. }
  68246. /**
  68247. * Default implementation IShadowGenerator.
  68248. * This is the main object responsible of generating shadows in the framework.
  68249. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68250. */
  68251. export class ShadowGenerator implements IShadowGenerator {
  68252. /**
  68253. * Shadow generator mode None: no filtering applied.
  68254. */
  68255. static readonly FILTER_NONE: number;
  68256. /**
  68257. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68258. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68259. */
  68260. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  68261. /**
  68262. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  68263. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  68264. */
  68265. static readonly FILTER_POISSONSAMPLING: number;
  68266. /**
  68267. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  68268. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68269. */
  68270. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  68271. /**
  68272. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  68273. * edge artifacts on steep falloff.
  68274. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68275. */
  68276. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  68277. /**
  68278. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  68279. * edge artifacts on steep falloff.
  68280. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68281. */
  68282. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  68283. /**
  68284. * Shadow generator mode PCF: Percentage Closer Filtering
  68285. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68286. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  68287. */
  68288. static readonly FILTER_PCF: number;
  68289. /**
  68290. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  68291. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68292. * Contact Hardening
  68293. */
  68294. static readonly FILTER_PCSS: number;
  68295. /**
  68296. * Reserved for PCF and PCSS
  68297. * Highest Quality.
  68298. *
  68299. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68300. *
  68301. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68302. */
  68303. static readonly QUALITY_HIGH: number;
  68304. /**
  68305. * Reserved for PCF and PCSS
  68306. * Good tradeoff for quality/perf cross devices
  68307. *
  68308. * Execute PCF on a 3*3 kernel.
  68309. *
  68310. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  68311. */
  68312. static readonly QUALITY_MEDIUM: number;
  68313. /**
  68314. * Reserved for PCF and PCSS
  68315. * The lowest quality but the fastest.
  68316. *
  68317. * Execute PCF on a 1*1 kernel.
  68318. *
  68319. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  68320. */
  68321. static readonly QUALITY_LOW: number;
  68322. /** Gets or sets the custom shader name to use */
  68323. customShaderOptions: ICustomShaderOptions;
  68324. /**
  68325. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  68326. */
  68327. onBeforeShadowMapRenderObservable: Observable<Effect>;
  68328. /**
  68329. * Observable triggered before a mesh is rendered in the shadow map.
  68330. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  68331. */
  68332. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  68333. private _bias;
  68334. /**
  68335. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  68336. */
  68337. /**
  68338. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  68339. */
  68340. bias: number;
  68341. private _normalBias;
  68342. /**
  68343. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68344. */
  68345. /**
  68346. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68347. */
  68348. normalBias: number;
  68349. private _blurBoxOffset;
  68350. /**
  68351. * Gets the blur box offset: offset applied during the blur pass.
  68352. * Only useful if useKernelBlur = false
  68353. */
  68354. /**
  68355. * Sets the blur box offset: offset applied during the blur pass.
  68356. * Only useful if useKernelBlur = false
  68357. */
  68358. blurBoxOffset: number;
  68359. private _blurScale;
  68360. /**
  68361. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  68362. * 2 means half of the size.
  68363. */
  68364. /**
  68365. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  68366. * 2 means half of the size.
  68367. */
  68368. blurScale: number;
  68369. private _blurKernel;
  68370. /**
  68371. * Gets the blur kernel: kernel size of the blur pass.
  68372. * Only useful if useKernelBlur = true
  68373. */
  68374. /**
  68375. * Sets the blur kernel: kernel size of the blur pass.
  68376. * Only useful if useKernelBlur = true
  68377. */
  68378. blurKernel: number;
  68379. private _useKernelBlur;
  68380. /**
  68381. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  68382. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68383. */
  68384. /**
  68385. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  68386. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68387. */
  68388. useKernelBlur: boolean;
  68389. private _depthScale;
  68390. /**
  68391. * Gets the depth scale used in ESM mode.
  68392. */
  68393. /**
  68394. * Sets the depth scale used in ESM mode.
  68395. * This can override the scale stored on the light.
  68396. */
  68397. depthScale: number;
  68398. private _filter;
  68399. /**
  68400. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  68401. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68402. */
  68403. /**
  68404. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  68405. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68406. */
  68407. filter: number;
  68408. /**
  68409. * Gets if the current filter is set to Poisson Sampling.
  68410. */
  68411. /**
  68412. * Sets the current filter to Poisson Sampling.
  68413. */
  68414. usePoissonSampling: boolean;
  68415. /**
  68416. * Gets if the current filter is set to ESM.
  68417. */
  68418. /**
  68419. * Sets the current filter is to ESM.
  68420. */
  68421. useExponentialShadowMap: boolean;
  68422. /**
  68423. * Gets if the current filter is set to filtered ESM.
  68424. */
  68425. /**
  68426. * Gets if the current filter is set to filtered ESM.
  68427. */
  68428. useBlurExponentialShadowMap: boolean;
  68429. /**
  68430. * Gets if the current filter is set to "close ESM" (using the inverse of the
  68431. * exponential to prevent steep falloff artifacts).
  68432. */
  68433. /**
  68434. * Sets the current filter to "close ESM" (using the inverse of the
  68435. * exponential to prevent steep falloff artifacts).
  68436. */
  68437. useCloseExponentialShadowMap: boolean;
  68438. /**
  68439. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  68440. * exponential to prevent steep falloff artifacts).
  68441. */
  68442. /**
  68443. * Sets the current filter to filtered "close ESM" (using the inverse of the
  68444. * exponential to prevent steep falloff artifacts).
  68445. */
  68446. useBlurCloseExponentialShadowMap: boolean;
  68447. /**
  68448. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  68449. */
  68450. /**
  68451. * Sets the current filter to "PCF" (percentage closer filtering).
  68452. */
  68453. usePercentageCloserFiltering: boolean;
  68454. private _filteringQuality;
  68455. /**
  68456. * Gets the PCF or PCSS Quality.
  68457. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68458. */
  68459. /**
  68460. * Sets the PCF or PCSS Quality.
  68461. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68462. */
  68463. filteringQuality: number;
  68464. /**
  68465. * Gets if the current filter is set to "PCSS" (contact hardening).
  68466. */
  68467. /**
  68468. * Sets the current filter to "PCSS" (contact hardening).
  68469. */
  68470. useContactHardeningShadow: boolean;
  68471. private _contactHardeningLightSizeUVRatio;
  68472. /**
  68473. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68474. * Using a ratio helps keeping shape stability independently of the map size.
  68475. *
  68476. * It does not account for the light projection as it was having too much
  68477. * instability during the light setup or during light position changes.
  68478. *
  68479. * Only valid if useContactHardeningShadow is true.
  68480. */
  68481. /**
  68482. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68483. * Using a ratio helps keeping shape stability independently of the map size.
  68484. *
  68485. * It does not account for the light projection as it was having too much
  68486. * instability during the light setup or during light position changes.
  68487. *
  68488. * Only valid if useContactHardeningShadow is true.
  68489. */
  68490. contactHardeningLightSizeUVRatio: number;
  68491. private _darkness;
  68492. /**
  68493. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  68494. * 0 means strongest and 1 would means no shadow.
  68495. * @returns the darkness.
  68496. */
  68497. getDarkness(): number;
  68498. /**
  68499. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  68500. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  68501. * @returns the shadow generator allowing fluent coding.
  68502. */
  68503. setDarkness(darkness: number): ShadowGenerator;
  68504. private _transparencyShadow;
  68505. /**
  68506. * Sets the ability to have transparent shadow (boolean).
  68507. * @param transparent True if transparent else False
  68508. * @returns the shadow generator allowing fluent coding
  68509. */
  68510. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  68511. private _shadowMap;
  68512. private _shadowMap2;
  68513. /**
  68514. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68515. * @returns The render target texture if present otherwise, null
  68516. */
  68517. getShadowMap(): Nullable<RenderTargetTexture>;
  68518. /**
  68519. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68520. * @returns The render target texture if the shadow map is present otherwise, null
  68521. */
  68522. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68523. /**
  68524. * Helper function to add a mesh and its descendants to the list of shadow casters.
  68525. * @param mesh Mesh to add
  68526. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  68527. * @returns the Shadow Generator itself
  68528. */
  68529. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68530. /**
  68531. * Helper function to remove a mesh and its descendants from the list of shadow casters
  68532. * @param mesh Mesh to remove
  68533. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  68534. * @returns the Shadow Generator itself
  68535. */
  68536. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68537. /**
  68538. * Controls the extent to which the shadows fade out at the edge of the frustum
  68539. * Used only by directionals and spots
  68540. */
  68541. frustumEdgeFalloff: number;
  68542. private _light;
  68543. /**
  68544. * Returns the associated light object.
  68545. * @returns the light generating the shadow
  68546. */
  68547. getLight(): IShadowLight;
  68548. /**
  68549. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  68550. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  68551. * It might on the other hand introduce peter panning.
  68552. */
  68553. forceBackFacesOnly: boolean;
  68554. private _scene;
  68555. private _lightDirection;
  68556. private _effect;
  68557. private _viewMatrix;
  68558. private _projectionMatrix;
  68559. private _transformMatrix;
  68560. private _cachedPosition;
  68561. private _cachedDirection;
  68562. private _cachedDefines;
  68563. private _currentRenderID;
  68564. private _boxBlurPostprocess;
  68565. private _kernelBlurXPostprocess;
  68566. private _kernelBlurYPostprocess;
  68567. private _blurPostProcesses;
  68568. private _mapSize;
  68569. private _currentFaceIndex;
  68570. private _currentFaceIndexCache;
  68571. private _textureType;
  68572. private _defaultTextureMatrix;
  68573. /** @hidden */
  68574. static _SceneComponentInitialization: (scene: Scene) => void;
  68575. /**
  68576. * Creates a ShadowGenerator object.
  68577. * A ShadowGenerator is the required tool to use the shadows.
  68578. * Each light casting shadows needs to use its own ShadowGenerator.
  68579. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  68580. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  68581. * @param light The light object generating the shadows.
  68582. * @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.
  68583. */
  68584. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  68585. private _initializeGenerator;
  68586. private _initializeShadowMap;
  68587. private _initializeBlurRTTAndPostProcesses;
  68588. private _renderForShadowMap;
  68589. private _renderSubMeshForShadowMap;
  68590. private _applyFilterValues;
  68591. /**
  68592. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68593. * @param onCompiled Callback triggered at the and of the effects compilation
  68594. * @param options Sets of optional options forcing the compilation with different modes
  68595. */
  68596. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68597. useInstances: boolean;
  68598. }>): void;
  68599. /**
  68600. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68601. * @param options Sets of optional options forcing the compilation with different modes
  68602. * @returns A promise that resolves when the compilation completes
  68603. */
  68604. forceCompilationAsync(options?: Partial<{
  68605. useInstances: boolean;
  68606. }>): Promise<void>;
  68607. /**
  68608. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68609. * @param subMesh The submesh we want to render in the shadow map
  68610. * @param useInstances Defines wether will draw in the map using instances
  68611. * @returns true if ready otherwise, false
  68612. */
  68613. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68614. /**
  68615. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68616. * @param defines Defines of the material we want to update
  68617. * @param lightIndex Index of the light in the enabled light list of the material
  68618. */
  68619. prepareDefines(defines: any, lightIndex: number): void;
  68620. /**
  68621. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68622. * defined in the generator but impacting the effect).
  68623. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68624. * @param effect The effect we are binfing the information for
  68625. */
  68626. bindShadowLight(lightIndex: string, effect: Effect): void;
  68627. /**
  68628. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68629. * (eq to shadow prjection matrix * light transform matrix)
  68630. * @returns The transform matrix used to create the shadow map
  68631. */
  68632. getTransformMatrix(): Matrix;
  68633. /**
  68634. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68635. * Cube and 2D textures for instance.
  68636. */
  68637. recreateShadowMap(): void;
  68638. private _disposeBlurPostProcesses;
  68639. private _disposeRTTandPostProcesses;
  68640. /**
  68641. * Disposes the ShadowGenerator.
  68642. * Returns nothing.
  68643. */
  68644. dispose(): void;
  68645. /**
  68646. * Serializes the shadow generator setup to a json object.
  68647. * @returns The serialized JSON object
  68648. */
  68649. serialize(): any;
  68650. /**
  68651. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  68652. * @param parsedShadowGenerator The JSON object to parse
  68653. * @param scene The scene to create the shadow map for
  68654. * @returns The parsed shadow generator
  68655. */
  68656. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  68657. }
  68658. }
  68659. declare module BABYLON {
  68660. /**
  68661. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  68662. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  68663. * 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.
  68664. */
  68665. export abstract class Light extends Node {
  68666. /**
  68667. * Falloff Default: light is falling off following the material specification:
  68668. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  68669. */
  68670. static readonly FALLOFF_DEFAULT: number;
  68671. /**
  68672. * Falloff Physical: light is falling off following the inverse squared distance law.
  68673. */
  68674. static readonly FALLOFF_PHYSICAL: number;
  68675. /**
  68676. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  68677. * to enhance interoperability with other engines.
  68678. */
  68679. static readonly FALLOFF_GLTF: number;
  68680. /**
  68681. * Falloff Standard: light is falling off like in the standard material
  68682. * to enhance interoperability with other materials.
  68683. */
  68684. static readonly FALLOFF_STANDARD: number;
  68685. /**
  68686. * If every light affecting the material is in this lightmapMode,
  68687. * material.lightmapTexture adds or multiplies
  68688. * (depends on material.useLightmapAsShadowmap)
  68689. * after every other light calculations.
  68690. */
  68691. static readonly LIGHTMAP_DEFAULT: number;
  68692. /**
  68693. * material.lightmapTexture as only diffuse lighting from this light
  68694. * adds only specular lighting from this light
  68695. * adds dynamic shadows
  68696. */
  68697. static readonly LIGHTMAP_SPECULAR: number;
  68698. /**
  68699. * material.lightmapTexture as only lighting
  68700. * no light calculation from this light
  68701. * only adds dynamic shadows from this light
  68702. */
  68703. static readonly LIGHTMAP_SHADOWSONLY: number;
  68704. /**
  68705. * Each light type uses the default quantity according to its type:
  68706. * point/spot lights use luminous intensity
  68707. * directional lights use illuminance
  68708. */
  68709. static readonly INTENSITYMODE_AUTOMATIC: number;
  68710. /**
  68711. * lumen (lm)
  68712. */
  68713. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  68714. /**
  68715. * candela (lm/sr)
  68716. */
  68717. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  68718. /**
  68719. * lux (lm/m^2)
  68720. */
  68721. static readonly INTENSITYMODE_ILLUMINANCE: number;
  68722. /**
  68723. * nit (cd/m^2)
  68724. */
  68725. static readonly INTENSITYMODE_LUMINANCE: number;
  68726. /**
  68727. * Light type const id of the point light.
  68728. */
  68729. static readonly LIGHTTYPEID_POINTLIGHT: number;
  68730. /**
  68731. * Light type const id of the directional light.
  68732. */
  68733. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  68734. /**
  68735. * Light type const id of the spot light.
  68736. */
  68737. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  68738. /**
  68739. * Light type const id of the hemispheric light.
  68740. */
  68741. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  68742. /**
  68743. * Diffuse gives the basic color to an object.
  68744. */
  68745. diffuse: Color3;
  68746. /**
  68747. * Specular produces a highlight color on an object.
  68748. * Note: This is note affecting PBR materials.
  68749. */
  68750. specular: Color3;
  68751. /**
  68752. * Defines the falloff type for this light. This lets overrriding how punctual light are
  68753. * falling off base on range or angle.
  68754. * This can be set to any values in Light.FALLOFF_x.
  68755. *
  68756. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  68757. * other types of materials.
  68758. */
  68759. falloffType: number;
  68760. /**
  68761. * Strength of the light.
  68762. * Note: By default it is define in the framework own unit.
  68763. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  68764. */
  68765. intensity: number;
  68766. private _range;
  68767. protected _inverseSquaredRange: number;
  68768. /**
  68769. * Defines how far from the source the light is impacting in scene units.
  68770. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68771. */
  68772. /**
  68773. * Defines how far from the source the light is impacting in scene units.
  68774. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68775. */
  68776. range: number;
  68777. /**
  68778. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  68779. * of light.
  68780. */
  68781. private _photometricScale;
  68782. private _intensityMode;
  68783. /**
  68784. * Gets the photometric scale used to interpret the intensity.
  68785. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68786. */
  68787. /**
  68788. * Sets the photometric scale used to interpret the intensity.
  68789. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68790. */
  68791. intensityMode: number;
  68792. private _radius;
  68793. /**
  68794. * Gets the light radius used by PBR Materials to simulate soft area lights.
  68795. */
  68796. /**
  68797. * sets the light radius used by PBR Materials to simulate soft area lights.
  68798. */
  68799. radius: number;
  68800. private _renderPriority;
  68801. /**
  68802. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  68803. * exceeding the number allowed of the materials.
  68804. */
  68805. renderPriority: number;
  68806. private _shadowEnabled;
  68807. /**
  68808. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68809. * the current shadow generator.
  68810. */
  68811. /**
  68812. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68813. * the current shadow generator.
  68814. */
  68815. shadowEnabled: boolean;
  68816. private _includedOnlyMeshes;
  68817. /**
  68818. * Gets the only meshes impacted by this light.
  68819. */
  68820. /**
  68821. * Sets the only meshes impacted by this light.
  68822. */
  68823. includedOnlyMeshes: AbstractMesh[];
  68824. private _excludedMeshes;
  68825. /**
  68826. * Gets the meshes not impacted by this light.
  68827. */
  68828. /**
  68829. * Sets the meshes not impacted by this light.
  68830. */
  68831. excludedMeshes: AbstractMesh[];
  68832. private _excludeWithLayerMask;
  68833. /**
  68834. * Gets the layer id use to find what meshes are not impacted by the light.
  68835. * Inactive if 0
  68836. */
  68837. /**
  68838. * Sets the layer id use to find what meshes are not impacted by the light.
  68839. * Inactive if 0
  68840. */
  68841. excludeWithLayerMask: number;
  68842. private _includeOnlyWithLayerMask;
  68843. /**
  68844. * Gets the layer id use to find what meshes are impacted by the light.
  68845. * Inactive if 0
  68846. */
  68847. /**
  68848. * Sets the layer id use to find what meshes are impacted by the light.
  68849. * Inactive if 0
  68850. */
  68851. includeOnlyWithLayerMask: number;
  68852. private _lightmapMode;
  68853. /**
  68854. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68855. */
  68856. /**
  68857. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68858. */
  68859. lightmapMode: number;
  68860. /**
  68861. * Shadow generator associted to the light.
  68862. * @hidden Internal use only.
  68863. */
  68864. _shadowGenerator: Nullable<IShadowGenerator>;
  68865. /**
  68866. * @hidden Internal use only.
  68867. */
  68868. _excludedMeshesIds: string[];
  68869. /**
  68870. * @hidden Internal use only.
  68871. */
  68872. _includedOnlyMeshesIds: string[];
  68873. /**
  68874. * The current light unifom buffer.
  68875. * @hidden Internal use only.
  68876. */
  68877. _uniformBuffer: UniformBuffer;
  68878. /**
  68879. * Creates a Light object in the scene.
  68880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  68881. * @param name The firendly name of the light
  68882. * @param scene The scene the light belongs too
  68883. */
  68884. constructor(name: string, scene: Scene);
  68885. protected abstract _buildUniformLayout(): void;
  68886. /**
  68887. * Sets the passed Effect "effect" with the Light information.
  68888. * @param effect The effect to update
  68889. * @param lightIndex The index of the light in the effect to update
  68890. * @returns The light
  68891. */
  68892. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  68893. /**
  68894. * Returns the string "Light".
  68895. * @returns the class name
  68896. */
  68897. getClassName(): string;
  68898. /** @hidden */
  68899. readonly _isLight: boolean;
  68900. /**
  68901. * Converts the light information to a readable string for debug purpose.
  68902. * @param fullDetails Supports for multiple levels of logging within scene loading
  68903. * @returns the human readable light info
  68904. */
  68905. toString(fullDetails?: boolean): string;
  68906. /** @hidden */
  68907. protected _syncParentEnabledState(): void;
  68908. /**
  68909. * Set the enabled state of this node.
  68910. * @param value - the new enabled state
  68911. */
  68912. setEnabled(value: boolean): void;
  68913. /**
  68914. * Returns the Light associated shadow generator if any.
  68915. * @return the associated shadow generator.
  68916. */
  68917. getShadowGenerator(): Nullable<IShadowGenerator>;
  68918. /**
  68919. * Returns a Vector3, the absolute light position in the World.
  68920. * @returns the world space position of the light
  68921. */
  68922. getAbsolutePosition(): Vector3;
  68923. /**
  68924. * Specifies if the light will affect the passed mesh.
  68925. * @param mesh The mesh to test against the light
  68926. * @return true the mesh is affected otherwise, false.
  68927. */
  68928. canAffectMesh(mesh: AbstractMesh): boolean;
  68929. /**
  68930. * Sort function to order lights for rendering.
  68931. * @param a First Light object to compare to second.
  68932. * @param b Second Light object to compare first.
  68933. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  68934. */
  68935. static CompareLightsPriority(a: Light, b: Light): number;
  68936. /**
  68937. * Releases resources associated with this node.
  68938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  68939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  68940. */
  68941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  68942. /**
  68943. * Returns the light type ID (integer).
  68944. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68945. */
  68946. getTypeID(): number;
  68947. /**
  68948. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  68949. * @returns the scaled intensity in intensity mode unit
  68950. */
  68951. getScaledIntensity(): number;
  68952. /**
  68953. * Returns a new Light object, named "name", from the current one.
  68954. * @param name The name of the cloned light
  68955. * @returns the new created light
  68956. */
  68957. clone(name: string): Nullable<Light>;
  68958. /**
  68959. * Serializes the current light into a Serialization object.
  68960. * @returns the serialized object.
  68961. */
  68962. serialize(): any;
  68963. /**
  68964. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68965. * This new light is named "name" and added to the passed scene.
  68966. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68967. * @param name The friendly name of the light
  68968. * @param scene The scene the new light will belong to
  68969. * @returns the constructor function
  68970. */
  68971. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68972. /**
  68973. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68974. * @param parsedLight The JSON representation of the light
  68975. * @param scene The scene to create the parsed light in
  68976. * @returns the created light after parsing
  68977. */
  68978. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68979. private _hookArrayForExcluded;
  68980. private _hookArrayForIncludedOnly;
  68981. private _resyncMeshes;
  68982. /**
  68983. * Forces the meshes to update their light related information in their rendering used effects
  68984. * @hidden Internal Use Only
  68985. */
  68986. _markMeshesAsLightDirty(): void;
  68987. /**
  68988. * Recomputes the cached photometric scale if needed.
  68989. */
  68990. private _computePhotometricScale;
  68991. /**
  68992. * Returns the Photometric Scale according to the light type and intensity mode.
  68993. */
  68994. private _getPhotometricScale;
  68995. /**
  68996. * Reorder the light in the scene according to their defined priority.
  68997. * @hidden Internal Use Only
  68998. */
  68999. _reorderLightsInScene(): void;
  69000. /**
  69001. * Prepares the list of defines specific to the light type.
  69002. * @param defines the list of defines
  69003. * @param lightIndex defines the index of the light for the effect
  69004. */
  69005. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69006. }
  69007. }
  69008. declare module BABYLON {
  69009. /**
  69010. * Interface used to define Action
  69011. */
  69012. export interface IAction {
  69013. /**
  69014. * Trigger for the action
  69015. */
  69016. trigger: number;
  69017. /** Options of the trigger */
  69018. triggerOptions: any;
  69019. /**
  69020. * Gets the trigger parameters
  69021. * @returns the trigger parameters
  69022. */
  69023. getTriggerParameter(): any;
  69024. /**
  69025. * Internal only - executes current action event
  69026. * @hidden
  69027. */
  69028. _executeCurrent(evt?: ActionEvent): void;
  69029. /**
  69030. * Serialize placeholder for child classes
  69031. * @param parent of child
  69032. * @returns the serialized object
  69033. */
  69034. serialize(parent: any): any;
  69035. /**
  69036. * Internal only
  69037. * @hidden
  69038. */
  69039. _prepare(): void;
  69040. /**
  69041. * Internal only - manager for action
  69042. * @hidden
  69043. */
  69044. _actionManager: AbstractActionManager;
  69045. }
  69046. /**
  69047. * The action to be carried out following a trigger
  69048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69049. */
  69050. export class Action implements IAction {
  69051. /** the trigger, with or without parameters, for the action */
  69052. triggerOptions: any;
  69053. /**
  69054. * Trigger for the action
  69055. */
  69056. trigger: number;
  69057. /**
  69058. * Internal only - manager for action
  69059. * @hidden
  69060. */
  69061. _actionManager: ActionManager;
  69062. private _nextActiveAction;
  69063. private _child;
  69064. private _condition?;
  69065. private _triggerParameter;
  69066. /**
  69067. * An event triggered prior to action being executed.
  69068. */
  69069. onBeforeExecuteObservable: Observable<Action>;
  69070. /**
  69071. * Creates a new Action
  69072. * @param triggerOptions the trigger, with or without parameters, for the action
  69073. * @param condition an optional determinant of action
  69074. */
  69075. constructor(
  69076. /** the trigger, with or without parameters, for the action */
  69077. triggerOptions: any, condition?: Condition);
  69078. /**
  69079. * Internal only
  69080. * @hidden
  69081. */
  69082. _prepare(): void;
  69083. /**
  69084. * Gets the trigger parameters
  69085. * @returns the trigger parameters
  69086. */
  69087. getTriggerParameter(): any;
  69088. /**
  69089. * Internal only - executes current action event
  69090. * @hidden
  69091. */
  69092. _executeCurrent(evt?: ActionEvent): void;
  69093. /**
  69094. * Execute placeholder for child classes
  69095. * @param evt optional action event
  69096. */
  69097. execute(evt?: ActionEvent): void;
  69098. /**
  69099. * Skips to next active action
  69100. */
  69101. skipToNextActiveAction(): void;
  69102. /**
  69103. * Adds action to chain of actions, may be a DoNothingAction
  69104. * @param action defines the next action to execute
  69105. * @returns The action passed in
  69106. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69107. */
  69108. then(action: Action): Action;
  69109. /**
  69110. * Internal only
  69111. * @hidden
  69112. */
  69113. _getProperty(propertyPath: string): string;
  69114. /**
  69115. * Internal only
  69116. * @hidden
  69117. */
  69118. _getEffectiveTarget(target: any, propertyPath: string): any;
  69119. /**
  69120. * Serialize placeholder for child classes
  69121. * @param parent of child
  69122. * @returns the serialized object
  69123. */
  69124. serialize(parent: any): any;
  69125. /**
  69126. * Internal only called by serialize
  69127. * @hidden
  69128. */
  69129. protected _serialize(serializedAction: any, parent?: any): any;
  69130. /**
  69131. * Internal only
  69132. * @hidden
  69133. */
  69134. static _SerializeValueAsString: (value: any) => string;
  69135. /**
  69136. * Internal only
  69137. * @hidden
  69138. */
  69139. static _GetTargetProperty: (target: Scene | Node) => {
  69140. name: string;
  69141. targetType: string;
  69142. value: string;
  69143. };
  69144. }
  69145. }
  69146. declare module BABYLON {
  69147. /**
  69148. * A Condition applied to an Action
  69149. */
  69150. export class Condition {
  69151. /**
  69152. * Internal only - manager for action
  69153. * @hidden
  69154. */
  69155. _actionManager: ActionManager;
  69156. /**
  69157. * Internal only
  69158. * @hidden
  69159. */
  69160. _evaluationId: number;
  69161. /**
  69162. * Internal only
  69163. * @hidden
  69164. */
  69165. _currentResult: boolean;
  69166. /**
  69167. * Creates a new Condition
  69168. * @param actionManager the manager of the action the condition is applied to
  69169. */
  69170. constructor(actionManager: ActionManager);
  69171. /**
  69172. * Check if the current condition is valid
  69173. * @returns a boolean
  69174. */
  69175. isValid(): boolean;
  69176. /**
  69177. * Internal only
  69178. * @hidden
  69179. */
  69180. _getProperty(propertyPath: string): string;
  69181. /**
  69182. * Internal only
  69183. * @hidden
  69184. */
  69185. _getEffectiveTarget(target: any, propertyPath: string): any;
  69186. /**
  69187. * Serialize placeholder for child classes
  69188. * @returns the serialized object
  69189. */
  69190. serialize(): any;
  69191. /**
  69192. * Internal only
  69193. * @hidden
  69194. */
  69195. protected _serialize(serializedCondition: any): any;
  69196. }
  69197. /**
  69198. * Defines specific conditional operators as extensions of Condition
  69199. */
  69200. export class ValueCondition extends Condition {
  69201. /** path to specify the property of the target the conditional operator uses */
  69202. propertyPath: string;
  69203. /** the value compared by the conditional operator against the current value of the property */
  69204. value: any;
  69205. /** the conditional operator, default ValueCondition.IsEqual */
  69206. operator: number;
  69207. /**
  69208. * Internal only
  69209. * @hidden
  69210. */
  69211. private static _IsEqual;
  69212. /**
  69213. * Internal only
  69214. * @hidden
  69215. */
  69216. private static _IsDifferent;
  69217. /**
  69218. * Internal only
  69219. * @hidden
  69220. */
  69221. private static _IsGreater;
  69222. /**
  69223. * Internal only
  69224. * @hidden
  69225. */
  69226. private static _IsLesser;
  69227. /**
  69228. * returns the number for IsEqual
  69229. */
  69230. static readonly IsEqual: number;
  69231. /**
  69232. * Returns the number for IsDifferent
  69233. */
  69234. static readonly IsDifferent: number;
  69235. /**
  69236. * Returns the number for IsGreater
  69237. */
  69238. static readonly IsGreater: number;
  69239. /**
  69240. * Returns the number for IsLesser
  69241. */
  69242. static readonly IsLesser: number;
  69243. /**
  69244. * Internal only The action manager for the condition
  69245. * @hidden
  69246. */
  69247. _actionManager: ActionManager;
  69248. /**
  69249. * Internal only
  69250. * @hidden
  69251. */
  69252. private _target;
  69253. /**
  69254. * Internal only
  69255. * @hidden
  69256. */
  69257. private _effectiveTarget;
  69258. /**
  69259. * Internal only
  69260. * @hidden
  69261. */
  69262. private _property;
  69263. /**
  69264. * Creates a new ValueCondition
  69265. * @param actionManager manager for the action the condition applies to
  69266. * @param target for the action
  69267. * @param propertyPath path to specify the property of the target the conditional operator uses
  69268. * @param value the value compared by the conditional operator against the current value of the property
  69269. * @param operator the conditional operator, default ValueCondition.IsEqual
  69270. */
  69271. constructor(actionManager: ActionManager, target: any,
  69272. /** path to specify the property of the target the conditional operator uses */
  69273. propertyPath: string,
  69274. /** the value compared by the conditional operator against the current value of the property */
  69275. value: any,
  69276. /** the conditional operator, default ValueCondition.IsEqual */
  69277. operator?: number);
  69278. /**
  69279. * Compares the given value with the property value for the specified conditional operator
  69280. * @returns the result of the comparison
  69281. */
  69282. isValid(): boolean;
  69283. /**
  69284. * Serialize the ValueCondition into a JSON compatible object
  69285. * @returns serialization object
  69286. */
  69287. serialize(): any;
  69288. /**
  69289. * Gets the name of the conditional operator for the ValueCondition
  69290. * @param operator the conditional operator
  69291. * @returns the name
  69292. */
  69293. static GetOperatorName(operator: number): string;
  69294. }
  69295. /**
  69296. * Defines a predicate condition as an extension of Condition
  69297. */
  69298. export class PredicateCondition extends Condition {
  69299. /** defines the predicate function used to validate the condition */
  69300. predicate: () => boolean;
  69301. /**
  69302. * Internal only - manager for action
  69303. * @hidden
  69304. */
  69305. _actionManager: ActionManager;
  69306. /**
  69307. * Creates a new PredicateCondition
  69308. * @param actionManager manager for the action the condition applies to
  69309. * @param predicate defines the predicate function used to validate the condition
  69310. */
  69311. constructor(actionManager: ActionManager,
  69312. /** defines the predicate function used to validate the condition */
  69313. predicate: () => boolean);
  69314. /**
  69315. * @returns the validity of the predicate condition
  69316. */
  69317. isValid(): boolean;
  69318. }
  69319. /**
  69320. * Defines a state condition as an extension of Condition
  69321. */
  69322. export class StateCondition extends Condition {
  69323. /** Value to compare with target state */
  69324. value: string;
  69325. /**
  69326. * Internal only - manager for action
  69327. * @hidden
  69328. */
  69329. _actionManager: ActionManager;
  69330. /**
  69331. * Internal only
  69332. * @hidden
  69333. */
  69334. private _target;
  69335. /**
  69336. * Creates a new StateCondition
  69337. * @param actionManager manager for the action the condition applies to
  69338. * @param target of the condition
  69339. * @param value to compare with target state
  69340. */
  69341. constructor(actionManager: ActionManager, target: any,
  69342. /** Value to compare with target state */
  69343. value: string);
  69344. /**
  69345. * Gets a boolean indicating if the current condition is met
  69346. * @returns the validity of the state
  69347. */
  69348. isValid(): boolean;
  69349. /**
  69350. * Serialize the StateCondition into a JSON compatible object
  69351. * @returns serialization object
  69352. */
  69353. serialize(): any;
  69354. }
  69355. }
  69356. declare module BABYLON {
  69357. /**
  69358. * This defines an action responsible to toggle a boolean once triggered.
  69359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69360. */
  69361. export class SwitchBooleanAction extends Action {
  69362. /**
  69363. * The path to the boolean property in the target object
  69364. */
  69365. propertyPath: string;
  69366. private _target;
  69367. private _effectiveTarget;
  69368. private _property;
  69369. /**
  69370. * Instantiate the action
  69371. * @param triggerOptions defines the trigger options
  69372. * @param target defines the object containing the boolean
  69373. * @param propertyPath defines the path to the boolean property in the target object
  69374. * @param condition defines the trigger related conditions
  69375. */
  69376. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  69377. /** @hidden */
  69378. _prepare(): void;
  69379. /**
  69380. * Execute the action toggle the boolean value.
  69381. */
  69382. execute(): void;
  69383. /**
  69384. * Serializes the actions and its related information.
  69385. * @param parent defines the object to serialize in
  69386. * @returns the serialized object
  69387. */
  69388. serialize(parent: any): any;
  69389. }
  69390. /**
  69391. * This defines an action responsible to set a the state field of the target
  69392. * to a desired value once triggered.
  69393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69394. */
  69395. export class SetStateAction extends Action {
  69396. /**
  69397. * The value to store in the state field.
  69398. */
  69399. value: string;
  69400. private _target;
  69401. /**
  69402. * Instantiate the action
  69403. * @param triggerOptions defines the trigger options
  69404. * @param target defines the object containing the state property
  69405. * @param value defines the value to store in the state field
  69406. * @param condition defines the trigger related conditions
  69407. */
  69408. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  69409. /**
  69410. * Execute the action and store the value on the target state property.
  69411. */
  69412. execute(): void;
  69413. /**
  69414. * Serializes the actions and its related information.
  69415. * @param parent defines the object to serialize in
  69416. * @returns the serialized object
  69417. */
  69418. serialize(parent: any): any;
  69419. }
  69420. /**
  69421. * This defines an action responsible to set a property of the target
  69422. * to a desired value once triggered.
  69423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69424. */
  69425. export class SetValueAction extends Action {
  69426. /**
  69427. * The path of the property to set in the target.
  69428. */
  69429. propertyPath: string;
  69430. /**
  69431. * The value to set in the property
  69432. */
  69433. value: any;
  69434. private _target;
  69435. private _effectiveTarget;
  69436. private _property;
  69437. /**
  69438. * Instantiate the action
  69439. * @param triggerOptions defines the trigger options
  69440. * @param target defines the object containing the property
  69441. * @param propertyPath defines the path of the property to set in the target
  69442. * @param value defines the value to set in the property
  69443. * @param condition defines the trigger related conditions
  69444. */
  69445. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69446. /** @hidden */
  69447. _prepare(): void;
  69448. /**
  69449. * Execute the action and set the targetted property to the desired value.
  69450. */
  69451. execute(): void;
  69452. /**
  69453. * Serializes the actions and its related information.
  69454. * @param parent defines the object to serialize in
  69455. * @returns the serialized object
  69456. */
  69457. serialize(parent: any): any;
  69458. }
  69459. /**
  69460. * This defines an action responsible to increment the target value
  69461. * to a desired value once triggered.
  69462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69463. */
  69464. export class IncrementValueAction extends Action {
  69465. /**
  69466. * The path of the property to increment in the target.
  69467. */
  69468. propertyPath: string;
  69469. /**
  69470. * The value we should increment the property by.
  69471. */
  69472. value: any;
  69473. private _target;
  69474. private _effectiveTarget;
  69475. private _property;
  69476. /**
  69477. * Instantiate the action
  69478. * @param triggerOptions defines the trigger options
  69479. * @param target defines the object containing the property
  69480. * @param propertyPath defines the path of the property to increment in the target
  69481. * @param value defines the value value we should increment the property by
  69482. * @param condition defines the trigger related conditions
  69483. */
  69484. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69485. /** @hidden */
  69486. _prepare(): void;
  69487. /**
  69488. * Execute the action and increment the target of the value amount.
  69489. */
  69490. execute(): void;
  69491. /**
  69492. * Serializes the actions and its related information.
  69493. * @param parent defines the object to serialize in
  69494. * @returns the serialized object
  69495. */
  69496. serialize(parent: any): any;
  69497. }
  69498. /**
  69499. * This defines an action responsible to start an animation once triggered.
  69500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69501. */
  69502. export class PlayAnimationAction extends Action {
  69503. /**
  69504. * Where the animation should start (animation frame)
  69505. */
  69506. from: number;
  69507. /**
  69508. * Where the animation should stop (animation frame)
  69509. */
  69510. to: number;
  69511. /**
  69512. * Define if the animation should loop or stop after the first play.
  69513. */
  69514. loop?: boolean;
  69515. private _target;
  69516. /**
  69517. * Instantiate the action
  69518. * @param triggerOptions defines the trigger options
  69519. * @param target defines the target animation or animation name
  69520. * @param from defines from where the animation should start (animation frame)
  69521. * @param end defines where the animation should stop (animation frame)
  69522. * @param loop defines if the animation should loop or stop after the first play
  69523. * @param condition defines the trigger related conditions
  69524. */
  69525. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  69526. /** @hidden */
  69527. _prepare(): void;
  69528. /**
  69529. * Execute the action and play the animation.
  69530. */
  69531. execute(): void;
  69532. /**
  69533. * Serializes the actions and its related information.
  69534. * @param parent defines the object to serialize in
  69535. * @returns the serialized object
  69536. */
  69537. serialize(parent: any): any;
  69538. }
  69539. /**
  69540. * This defines an action responsible to stop an animation once triggered.
  69541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69542. */
  69543. export class StopAnimationAction extends Action {
  69544. private _target;
  69545. /**
  69546. * Instantiate the action
  69547. * @param triggerOptions defines the trigger options
  69548. * @param target defines the target animation or animation name
  69549. * @param condition defines the trigger related conditions
  69550. */
  69551. constructor(triggerOptions: any, target: any, condition?: Condition);
  69552. /** @hidden */
  69553. _prepare(): void;
  69554. /**
  69555. * Execute the action and stop the animation.
  69556. */
  69557. execute(): void;
  69558. /**
  69559. * Serializes the actions and its related information.
  69560. * @param parent defines the object to serialize in
  69561. * @returns the serialized object
  69562. */
  69563. serialize(parent: any): any;
  69564. }
  69565. /**
  69566. * This defines an action responsible that does nothing once triggered.
  69567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69568. */
  69569. export class DoNothingAction extends Action {
  69570. /**
  69571. * Instantiate the action
  69572. * @param triggerOptions defines the trigger options
  69573. * @param condition defines the trigger related conditions
  69574. */
  69575. constructor(triggerOptions?: any, condition?: Condition);
  69576. /**
  69577. * Execute the action and do nothing.
  69578. */
  69579. execute(): void;
  69580. /**
  69581. * Serializes the actions and its related information.
  69582. * @param parent defines the object to serialize in
  69583. * @returns the serialized object
  69584. */
  69585. serialize(parent: any): any;
  69586. }
  69587. /**
  69588. * This defines an action responsible to trigger several actions once triggered.
  69589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69590. */
  69591. export class CombineAction extends Action {
  69592. /**
  69593. * The list of aggregated animations to run.
  69594. */
  69595. children: Action[];
  69596. /**
  69597. * Instantiate the action
  69598. * @param triggerOptions defines the trigger options
  69599. * @param children defines the list of aggregated animations to run
  69600. * @param condition defines the trigger related conditions
  69601. */
  69602. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  69603. /** @hidden */
  69604. _prepare(): void;
  69605. /**
  69606. * Execute the action and executes all the aggregated actions.
  69607. */
  69608. execute(evt: ActionEvent): void;
  69609. /**
  69610. * Serializes the actions and its related information.
  69611. * @param parent defines the object to serialize in
  69612. * @returns the serialized object
  69613. */
  69614. serialize(parent: any): any;
  69615. }
  69616. /**
  69617. * This defines an action responsible to run code (external event) once triggered.
  69618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69619. */
  69620. export class ExecuteCodeAction extends Action {
  69621. /**
  69622. * The callback function to run.
  69623. */
  69624. func: (evt: ActionEvent) => void;
  69625. /**
  69626. * Instantiate the action
  69627. * @param triggerOptions defines the trigger options
  69628. * @param func defines the callback function to run
  69629. * @param condition defines the trigger related conditions
  69630. */
  69631. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  69632. /**
  69633. * Execute the action and run the attached code.
  69634. */
  69635. execute(evt: ActionEvent): void;
  69636. }
  69637. /**
  69638. * This defines an action responsible to set the parent property of the target once triggered.
  69639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69640. */
  69641. export class SetParentAction extends Action {
  69642. private _parent;
  69643. private _target;
  69644. /**
  69645. * Instantiate the action
  69646. * @param triggerOptions defines the trigger options
  69647. * @param target defines the target containing the parent property
  69648. * @param parent defines from where the animation should start (animation frame)
  69649. * @param condition defines the trigger related conditions
  69650. */
  69651. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  69652. /** @hidden */
  69653. _prepare(): void;
  69654. /**
  69655. * Execute the action and set the parent property.
  69656. */
  69657. execute(): void;
  69658. /**
  69659. * Serializes the actions and its related information.
  69660. * @param parent defines the object to serialize in
  69661. * @returns the serialized object
  69662. */
  69663. serialize(parent: any): any;
  69664. }
  69665. }
  69666. declare module BABYLON {
  69667. /**
  69668. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  69669. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  69670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69671. */
  69672. export class ActionManager extends AbstractActionManager {
  69673. /**
  69674. * Nothing
  69675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69676. */
  69677. static readonly NothingTrigger: number;
  69678. /**
  69679. * On pick
  69680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69681. */
  69682. static readonly OnPickTrigger: number;
  69683. /**
  69684. * On left pick
  69685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69686. */
  69687. static readonly OnLeftPickTrigger: number;
  69688. /**
  69689. * On right pick
  69690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69691. */
  69692. static readonly OnRightPickTrigger: number;
  69693. /**
  69694. * On center pick
  69695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69696. */
  69697. static readonly OnCenterPickTrigger: number;
  69698. /**
  69699. * On pick down
  69700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69701. */
  69702. static readonly OnPickDownTrigger: number;
  69703. /**
  69704. * On double pick
  69705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69706. */
  69707. static readonly OnDoublePickTrigger: number;
  69708. /**
  69709. * On pick up
  69710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69711. */
  69712. static readonly OnPickUpTrigger: number;
  69713. /**
  69714. * On pick out.
  69715. * This trigger will only be raised if you also declared a OnPickDown
  69716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69717. */
  69718. static readonly OnPickOutTrigger: number;
  69719. /**
  69720. * On long press
  69721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69722. */
  69723. static readonly OnLongPressTrigger: number;
  69724. /**
  69725. * On pointer over
  69726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69727. */
  69728. static readonly OnPointerOverTrigger: number;
  69729. /**
  69730. * On pointer out
  69731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69732. */
  69733. static readonly OnPointerOutTrigger: number;
  69734. /**
  69735. * On every frame
  69736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69737. */
  69738. static readonly OnEveryFrameTrigger: number;
  69739. /**
  69740. * On intersection enter
  69741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69742. */
  69743. static readonly OnIntersectionEnterTrigger: number;
  69744. /**
  69745. * On intersection exit
  69746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69747. */
  69748. static readonly OnIntersectionExitTrigger: number;
  69749. /**
  69750. * On key down
  69751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69752. */
  69753. static readonly OnKeyDownTrigger: number;
  69754. /**
  69755. * On key up
  69756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69757. */
  69758. static readonly OnKeyUpTrigger: number;
  69759. private _scene;
  69760. /**
  69761. * Creates a new action manager
  69762. * @param scene defines the hosting scene
  69763. */
  69764. constructor(scene: Scene);
  69765. /**
  69766. * Releases all associated resources
  69767. */
  69768. dispose(): void;
  69769. /**
  69770. * Gets hosting scene
  69771. * @returns the hosting scene
  69772. */
  69773. getScene(): Scene;
  69774. /**
  69775. * Does this action manager handles actions of any of the given triggers
  69776. * @param triggers defines the triggers to be tested
  69777. * @return a boolean indicating whether one (or more) of the triggers is handled
  69778. */
  69779. hasSpecificTriggers(triggers: number[]): boolean;
  69780. /**
  69781. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  69782. * speed.
  69783. * @param triggerA defines the trigger to be tested
  69784. * @param triggerB defines the trigger to be tested
  69785. * @return a boolean indicating whether one (or more) of the triggers is handled
  69786. */
  69787. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  69788. /**
  69789. * Does this action manager handles actions of a given trigger
  69790. * @param trigger defines the trigger to be tested
  69791. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  69792. * @return whether the trigger is handled
  69793. */
  69794. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  69795. /**
  69796. * Does this action manager has pointer triggers
  69797. */
  69798. readonly hasPointerTriggers: boolean;
  69799. /**
  69800. * Does this action manager has pick triggers
  69801. */
  69802. readonly hasPickTriggers: boolean;
  69803. /**
  69804. * Registers an action to this action manager
  69805. * @param action defines the action to be registered
  69806. * @return the action amended (prepared) after registration
  69807. */
  69808. registerAction(action: IAction): Nullable<IAction>;
  69809. /**
  69810. * Unregisters an action to this action manager
  69811. * @param action defines the action to be unregistered
  69812. * @return a boolean indicating whether the action has been unregistered
  69813. */
  69814. unregisterAction(action: IAction): Boolean;
  69815. /**
  69816. * Process a specific trigger
  69817. * @param trigger defines the trigger to process
  69818. * @param evt defines the event details to be processed
  69819. */
  69820. processTrigger(trigger: number, evt?: IActionEvent): void;
  69821. /** @hidden */
  69822. _getEffectiveTarget(target: any, propertyPath: string): any;
  69823. /** @hidden */
  69824. _getProperty(propertyPath: string): string;
  69825. /**
  69826. * Serialize this manager to a JSON object
  69827. * @param name defines the property name to store this manager
  69828. * @returns a JSON representation of this manager
  69829. */
  69830. serialize(name: string): any;
  69831. /**
  69832. * Creates a new ActionManager from a JSON data
  69833. * @param parsedActions defines the JSON data to read from
  69834. * @param object defines the hosting mesh
  69835. * @param scene defines the hosting scene
  69836. */
  69837. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  69838. /**
  69839. * Get a trigger name by index
  69840. * @param trigger defines the trigger index
  69841. * @returns a trigger name
  69842. */
  69843. static GetTriggerName(trigger: number): string;
  69844. }
  69845. }
  69846. declare module BABYLON {
  69847. /**
  69848. * Class representing a ray with position and direction
  69849. */
  69850. export class Ray {
  69851. /** origin point */
  69852. origin: Vector3;
  69853. /** direction */
  69854. direction: Vector3;
  69855. /** length of the ray */
  69856. length: number;
  69857. private static readonly TmpVector3;
  69858. private _tmpRay;
  69859. /**
  69860. * Creates a new ray
  69861. * @param origin origin point
  69862. * @param direction direction
  69863. * @param length length of the ray
  69864. */
  69865. constructor(
  69866. /** origin point */
  69867. origin: Vector3,
  69868. /** direction */
  69869. direction: Vector3,
  69870. /** length of the ray */
  69871. length?: number);
  69872. /**
  69873. * Checks if the ray intersects a box
  69874. * @param minimum bound of the box
  69875. * @param maximum bound of the box
  69876. * @param intersectionTreshold extra extend to be added to the box in all direction
  69877. * @returns if the box was hit
  69878. */
  69879. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  69880. /**
  69881. * Checks if the ray intersects a box
  69882. * @param box the bounding box to check
  69883. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  69884. * @returns if the box was hit
  69885. */
  69886. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  69887. /**
  69888. * If the ray hits a sphere
  69889. * @param sphere the bounding sphere to check
  69890. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  69891. * @returns true if it hits the sphere
  69892. */
  69893. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  69894. /**
  69895. * If the ray hits a triange
  69896. * @param vertex0 triangle vertex
  69897. * @param vertex1 triangle vertex
  69898. * @param vertex2 triangle vertex
  69899. * @returns intersection information if hit
  69900. */
  69901. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  69902. /**
  69903. * Checks if ray intersects a plane
  69904. * @param plane the plane to check
  69905. * @returns the distance away it was hit
  69906. */
  69907. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  69908. /**
  69909. * Checks if ray intersects a mesh
  69910. * @param mesh the mesh to check
  69911. * @param fastCheck if only the bounding box should checked
  69912. * @returns picking info of the intersecton
  69913. */
  69914. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  69915. /**
  69916. * Checks if ray intersects a mesh
  69917. * @param meshes the meshes to check
  69918. * @param fastCheck if only the bounding box should checked
  69919. * @param results array to store result in
  69920. * @returns Array of picking infos
  69921. */
  69922. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  69923. private _comparePickingInfo;
  69924. private static smallnum;
  69925. private static rayl;
  69926. /**
  69927. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  69928. * @param sega the first point of the segment to test the intersection against
  69929. * @param segb the second point of the segment to test the intersection against
  69930. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  69931. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  69932. */
  69933. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  69934. /**
  69935. * Update the ray from viewport position
  69936. * @param x position
  69937. * @param y y position
  69938. * @param viewportWidth viewport width
  69939. * @param viewportHeight viewport height
  69940. * @param world world matrix
  69941. * @param view view matrix
  69942. * @param projection projection matrix
  69943. * @returns this ray updated
  69944. */
  69945. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69946. /**
  69947. * Creates a ray with origin and direction of 0,0,0
  69948. * @returns the new ray
  69949. */
  69950. static Zero(): Ray;
  69951. /**
  69952. * Creates a new ray from screen space and viewport
  69953. * @param x position
  69954. * @param y y position
  69955. * @param viewportWidth viewport width
  69956. * @param viewportHeight viewport height
  69957. * @param world world matrix
  69958. * @param view view matrix
  69959. * @param projection projection matrix
  69960. * @returns new ray
  69961. */
  69962. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69963. /**
  69964. * 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
  69965. * transformed to the given world matrix.
  69966. * @param origin The origin point
  69967. * @param end The end point
  69968. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69969. * @returns the new ray
  69970. */
  69971. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69972. /**
  69973. * Transforms a ray by a matrix
  69974. * @param ray ray to transform
  69975. * @param matrix matrix to apply
  69976. * @returns the resulting new ray
  69977. */
  69978. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69979. /**
  69980. * Transforms a ray by a matrix
  69981. * @param ray ray to transform
  69982. * @param matrix matrix to apply
  69983. * @param result ray to store result in
  69984. */
  69985. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69986. /**
  69987. * Unproject a ray from screen space to object space
  69988. * @param sourceX defines the screen space x coordinate to use
  69989. * @param sourceY defines the screen space y coordinate to use
  69990. * @param viewportWidth defines the current width of the viewport
  69991. * @param viewportHeight defines the current height of the viewport
  69992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69993. * @param view defines the view matrix to use
  69994. * @param projection defines the projection matrix to use
  69995. */
  69996. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69997. }
  69998. /**
  69999. * Type used to define predicate used to select faces when a mesh intersection is detected
  70000. */
  70001. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70002. interface Scene {
  70003. /** @hidden */
  70004. _tempPickingRay: Nullable<Ray>;
  70005. /** @hidden */
  70006. _cachedRayForTransform: Ray;
  70007. /** @hidden */
  70008. _pickWithRayInverseMatrix: Matrix;
  70009. /** @hidden */
  70010. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70011. /** @hidden */
  70012. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70013. }
  70014. }
  70015. declare module BABYLON {
  70016. /**
  70017. * Groups all the scene component constants in one place to ease maintenance.
  70018. * @hidden
  70019. */
  70020. export class SceneComponentConstants {
  70021. static readonly NAME_EFFECTLAYER: string;
  70022. static readonly NAME_LAYER: string;
  70023. static readonly NAME_LENSFLARESYSTEM: string;
  70024. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70025. static readonly NAME_PARTICLESYSTEM: string;
  70026. static readonly NAME_GAMEPAD: string;
  70027. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70028. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70029. static readonly NAME_DEPTHRENDERER: string;
  70030. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70031. static readonly NAME_SPRITE: string;
  70032. static readonly NAME_OUTLINERENDERER: string;
  70033. static readonly NAME_PROCEDURALTEXTURE: string;
  70034. static readonly NAME_SHADOWGENERATOR: string;
  70035. static readonly NAME_OCTREE: string;
  70036. static readonly NAME_PHYSICSENGINE: string;
  70037. static readonly NAME_AUDIO: string;
  70038. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70039. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70040. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70041. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70042. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70043. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70044. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70045. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70046. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70047. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70048. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70049. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70050. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70051. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70052. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70053. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70054. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70055. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70056. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70057. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70058. static readonly STEP_AFTERRENDER_AUDIO: number;
  70059. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70060. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70061. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70062. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70063. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70064. static readonly STEP_POINTERMOVE_SPRITE: number;
  70065. static readonly STEP_POINTERDOWN_SPRITE: number;
  70066. static readonly STEP_POINTERUP_SPRITE: number;
  70067. }
  70068. /**
  70069. * This represents a scene component.
  70070. *
  70071. * This is used to decouple the dependency the scene is having on the different workloads like
  70072. * layers, post processes...
  70073. */
  70074. export interface ISceneComponent {
  70075. /**
  70076. * The name of the component. Each component must have a unique name.
  70077. */
  70078. name: string;
  70079. /**
  70080. * The scene the component belongs to.
  70081. */
  70082. scene: Scene;
  70083. /**
  70084. * Register the component to one instance of a scene.
  70085. */
  70086. register(): void;
  70087. /**
  70088. * Rebuilds the elements related to this component in case of
  70089. * context lost for instance.
  70090. */
  70091. rebuild(): void;
  70092. /**
  70093. * Disposes the component and the associated ressources.
  70094. */
  70095. dispose(): void;
  70096. }
  70097. /**
  70098. * This represents a SERIALIZABLE scene component.
  70099. *
  70100. * This extends Scene Component to add Serialization methods on top.
  70101. */
  70102. export interface ISceneSerializableComponent extends ISceneComponent {
  70103. /**
  70104. * Adds all the element from the container to the scene
  70105. * @param container the container holding the elements
  70106. */
  70107. addFromContainer(container: AbstractScene): void;
  70108. /**
  70109. * Removes all the elements in the container from the scene
  70110. * @param container contains the elements to remove
  70111. * @param dispose if the removed element should be disposed (default: false)
  70112. */
  70113. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70114. /**
  70115. * Serializes the component data to the specified json object
  70116. * @param serializationObject The object to serialize to
  70117. */
  70118. serialize(serializationObject: any): void;
  70119. }
  70120. /**
  70121. * Strong typing of a Mesh related stage step action
  70122. */
  70123. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70124. /**
  70125. * Strong typing of a Evaluate Sub Mesh related stage step action
  70126. */
  70127. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70128. /**
  70129. * Strong typing of a Active Mesh related stage step action
  70130. */
  70131. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70132. /**
  70133. * Strong typing of a Camera related stage step action
  70134. */
  70135. export type CameraStageAction = (camera: Camera) => void;
  70136. /**
  70137. * Strong typing of a Render Target related stage step action
  70138. */
  70139. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70140. /**
  70141. * Strong typing of a RenderingGroup related stage step action
  70142. */
  70143. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70144. /**
  70145. * Strong typing of a Mesh Render related stage step action
  70146. */
  70147. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70148. /**
  70149. * Strong typing of a simple stage step action
  70150. */
  70151. export type SimpleStageAction = () => void;
  70152. /**
  70153. * Strong typing of a render target action.
  70154. */
  70155. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70156. /**
  70157. * Strong typing of a pointer move action.
  70158. */
  70159. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70160. /**
  70161. * Strong typing of a pointer up/down action.
  70162. */
  70163. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70164. /**
  70165. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70166. * @hidden
  70167. */
  70168. export class Stage<T extends Function> extends Array<{
  70169. index: number;
  70170. component: ISceneComponent;
  70171. action: T;
  70172. }> {
  70173. /**
  70174. * Hide ctor from the rest of the world.
  70175. * @param items The items to add.
  70176. */
  70177. private constructor();
  70178. /**
  70179. * Creates a new Stage.
  70180. * @returns A new instance of a Stage
  70181. */
  70182. static Create<T extends Function>(): Stage<T>;
  70183. /**
  70184. * Registers a step in an ordered way in the targeted stage.
  70185. * @param index Defines the position to register the step in
  70186. * @param component Defines the component attached to the step
  70187. * @param action Defines the action to launch during the step
  70188. */
  70189. registerStep(index: number, component: ISceneComponent, action: T): void;
  70190. /**
  70191. * Clears all the steps from the stage.
  70192. */
  70193. clear(): void;
  70194. }
  70195. }
  70196. declare module BABYLON {
  70197. interface Scene {
  70198. /** @hidden */
  70199. _pointerOverSprite: Nullable<Sprite>;
  70200. /** @hidden */
  70201. _pickedDownSprite: Nullable<Sprite>;
  70202. /** @hidden */
  70203. _tempSpritePickingRay: Nullable<Ray>;
  70204. /**
  70205. * All of the sprite managers added to this scene
  70206. * @see http://doc.babylonjs.com/babylon101/sprites
  70207. */
  70208. spriteManagers: Array<ISpriteManager>;
  70209. /**
  70210. * An event triggered when sprites rendering is about to start
  70211. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70212. */
  70213. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70214. /**
  70215. * An event triggered when sprites rendering is done
  70216. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70217. */
  70218. onAfterSpritesRenderingObservable: Observable<Scene>;
  70219. /** @hidden */
  70220. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70221. /** Launch a ray to try to pick a sprite in the scene
  70222. * @param x position on screen
  70223. * @param y position on screen
  70224. * @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
  70225. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70226. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70227. * @returns a PickingInfo
  70228. */
  70229. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70230. /** Use the given ray to pick a sprite in the scene
  70231. * @param ray The ray (in world space) to use to pick meshes
  70232. * @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
  70233. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70234. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70235. * @returns a PickingInfo
  70236. */
  70237. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70238. /**
  70239. * Force the sprite under the pointer
  70240. * @param sprite defines the sprite to use
  70241. */
  70242. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70243. /**
  70244. * Gets the sprite under the pointer
  70245. * @returns a Sprite or null if no sprite is under the pointer
  70246. */
  70247. getPointerOverSprite(): Nullable<Sprite>;
  70248. }
  70249. /**
  70250. * Defines the sprite scene component responsible to manage sprites
  70251. * in a given scene.
  70252. */
  70253. export class SpriteSceneComponent implements ISceneComponent {
  70254. /**
  70255. * The component name helpfull to identify the component in the list of scene components.
  70256. */
  70257. readonly name: string;
  70258. /**
  70259. * The scene the component belongs to.
  70260. */
  70261. scene: Scene;
  70262. /** @hidden */
  70263. private _spritePredicate;
  70264. /**
  70265. * Creates a new instance of the component for the given scene
  70266. * @param scene Defines the scene to register the component in
  70267. */
  70268. constructor(scene: Scene);
  70269. /**
  70270. * Registers the component in a given scene
  70271. */
  70272. register(): void;
  70273. /**
  70274. * Rebuilds the elements related to this component in case of
  70275. * context lost for instance.
  70276. */
  70277. rebuild(): void;
  70278. /**
  70279. * Disposes the component and the associated ressources.
  70280. */
  70281. dispose(): void;
  70282. private _pickSpriteButKeepRay;
  70283. private _pointerMove;
  70284. private _pointerDown;
  70285. private _pointerUp;
  70286. }
  70287. }
  70288. declare module BABYLON {
  70289. /** @hidden */
  70290. export var fogFragmentDeclaration: {
  70291. name: string;
  70292. shader: string;
  70293. };
  70294. }
  70295. declare module BABYLON {
  70296. /** @hidden */
  70297. export var fogFragment: {
  70298. name: string;
  70299. shader: string;
  70300. };
  70301. }
  70302. declare module BABYLON {
  70303. /** @hidden */
  70304. export var spritesPixelShader: {
  70305. name: string;
  70306. shader: string;
  70307. };
  70308. }
  70309. declare module BABYLON {
  70310. /** @hidden */
  70311. export var fogVertexDeclaration: {
  70312. name: string;
  70313. shader: string;
  70314. };
  70315. }
  70316. declare module BABYLON {
  70317. /** @hidden */
  70318. export var spritesVertexShader: {
  70319. name: string;
  70320. shader: string;
  70321. };
  70322. }
  70323. declare module BABYLON {
  70324. /**
  70325. * Defines the minimum interface to fullfil in order to be a sprite manager.
  70326. */
  70327. export interface ISpriteManager extends IDisposable {
  70328. /**
  70329. * Restricts the camera to viewing objects with the same layerMask.
  70330. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  70331. */
  70332. layerMask: number;
  70333. /**
  70334. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  70335. */
  70336. isPickable: boolean;
  70337. /**
  70338. * Specifies the rendering group id for this mesh (0 by default)
  70339. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  70340. */
  70341. renderingGroupId: number;
  70342. /**
  70343. * Defines the list of sprites managed by the manager.
  70344. */
  70345. sprites: Array<Sprite>;
  70346. /**
  70347. * Tests the intersection of a sprite with a specific ray.
  70348. * @param ray The ray we are sending to test the collision
  70349. * @param camera The camera space we are sending rays in
  70350. * @param predicate A predicate allowing excluding sprites from the list of object to test
  70351. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  70352. * @returns picking info or null.
  70353. */
  70354. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70355. /**
  70356. * Renders the list of sprites on screen.
  70357. */
  70358. render(): void;
  70359. }
  70360. /**
  70361. * Class used to manage multiple sprites on the same spritesheet
  70362. * @see http://doc.babylonjs.com/babylon101/sprites
  70363. */
  70364. export class SpriteManager implements ISpriteManager {
  70365. /** defines the manager's name */
  70366. name: string;
  70367. /** Gets the list of sprites */
  70368. sprites: Sprite[];
  70369. /** Gets or sets the rendering group id (0 by default) */
  70370. renderingGroupId: number;
  70371. /** Gets or sets camera layer mask */
  70372. layerMask: number;
  70373. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  70374. fogEnabled: boolean;
  70375. /** Gets or sets a boolean indicating if the sprites are pickable */
  70376. isPickable: boolean;
  70377. /** Defines the default width of a cell in the spritesheet */
  70378. cellWidth: number;
  70379. /** Defines the default height of a cell in the spritesheet */
  70380. cellHeight: number;
  70381. /**
  70382. * An event triggered when the manager is disposed.
  70383. */
  70384. onDisposeObservable: Observable<SpriteManager>;
  70385. private _onDisposeObserver;
  70386. /**
  70387. * Callback called when the manager is disposed
  70388. */
  70389. onDispose: () => void;
  70390. private _capacity;
  70391. private _spriteTexture;
  70392. private _epsilon;
  70393. private _scene;
  70394. private _vertexData;
  70395. private _buffer;
  70396. private _vertexBuffers;
  70397. private _indexBuffer;
  70398. private _effectBase;
  70399. private _effectFog;
  70400. /**
  70401. * Gets or sets the spritesheet texture
  70402. */
  70403. texture: Texture;
  70404. /**
  70405. * Creates a new sprite manager
  70406. * @param name defines the manager's name
  70407. * @param imgUrl defines the sprite sheet url
  70408. * @param capacity defines the maximum allowed number of sprites
  70409. * @param cellSize defines the size of a sprite cell
  70410. * @param scene defines the hosting scene
  70411. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70412. * @param samplingMode defines the smapling mode to use with spritesheet
  70413. */
  70414. constructor(
  70415. /** defines the manager's name */
  70416. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  70417. private _appendSpriteVertex;
  70418. /**
  70419. * Intersects the sprites with a ray
  70420. * @param ray defines the ray to intersect with
  70421. * @param camera defines the current active camera
  70422. * @param predicate defines a predicate used to select candidate sprites
  70423. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  70424. * @returns null if no hit or a PickingInfo
  70425. */
  70426. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70427. /**
  70428. * Render all child sprites
  70429. */
  70430. render(): void;
  70431. /**
  70432. * Release associated resources
  70433. */
  70434. dispose(): void;
  70435. }
  70436. }
  70437. declare module BABYLON {
  70438. /**
  70439. * Class used to represent a sprite
  70440. * @see http://doc.babylonjs.com/babylon101/sprites
  70441. */
  70442. export class Sprite {
  70443. /** defines the name */
  70444. name: string;
  70445. /** Gets or sets the current world position */
  70446. position: Vector3;
  70447. /** Gets or sets the main color */
  70448. color: Color4;
  70449. /** Gets or sets the width */
  70450. width: number;
  70451. /** Gets or sets the height */
  70452. height: number;
  70453. /** Gets or sets rotation angle */
  70454. angle: number;
  70455. /** Gets or sets the cell index in the sprite sheet */
  70456. cellIndex: number;
  70457. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  70458. invertU: number;
  70459. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  70460. invertV: number;
  70461. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  70462. disposeWhenFinishedAnimating: boolean;
  70463. /** Gets the list of attached animations */
  70464. animations: Animation[];
  70465. /** Gets or sets a boolean indicating if the sprite can be picked */
  70466. isPickable: boolean;
  70467. /**
  70468. * Gets or sets the associated action manager
  70469. */
  70470. actionManager: Nullable<ActionManager>;
  70471. private _animationStarted;
  70472. private _loopAnimation;
  70473. private _fromIndex;
  70474. private _toIndex;
  70475. private _delay;
  70476. private _direction;
  70477. private _manager;
  70478. private _time;
  70479. private _onAnimationEnd;
  70480. /**
  70481. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  70482. */
  70483. isVisible: boolean;
  70484. /**
  70485. * Gets or sets the sprite size
  70486. */
  70487. size: number;
  70488. /**
  70489. * Creates a new Sprite
  70490. * @param name defines the name
  70491. * @param manager defines the manager
  70492. */
  70493. constructor(
  70494. /** defines the name */
  70495. name: string, manager: ISpriteManager);
  70496. /**
  70497. * Starts an animation
  70498. * @param from defines the initial key
  70499. * @param to defines the end key
  70500. * @param loop defines if the animation must loop
  70501. * @param delay defines the start delay (in ms)
  70502. * @param onAnimationEnd defines a callback to call when animation ends
  70503. */
  70504. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  70505. /** Stops current animation (if any) */
  70506. stopAnimation(): void;
  70507. /** @hidden */
  70508. _animate(deltaTime: number): void;
  70509. /** Release associated resources */
  70510. dispose(): void;
  70511. }
  70512. }
  70513. declare module BABYLON {
  70514. /**
  70515. * Information about the result of picking within a scene
  70516. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  70517. */
  70518. export class PickingInfo {
  70519. /** @hidden */
  70520. _pickingUnavailable: boolean;
  70521. /**
  70522. * If the pick collided with an object
  70523. */
  70524. hit: boolean;
  70525. /**
  70526. * Distance away where the pick collided
  70527. */
  70528. distance: number;
  70529. /**
  70530. * The location of pick collision
  70531. */
  70532. pickedPoint: Nullable<Vector3>;
  70533. /**
  70534. * The mesh corresponding the the pick collision
  70535. */
  70536. pickedMesh: Nullable<AbstractMesh>;
  70537. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  70538. bu: number;
  70539. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  70540. bv: number;
  70541. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  70542. faceId: number;
  70543. /** Id of the the submesh that was picked */
  70544. subMeshId: number;
  70545. /** If a sprite was picked, this will be the sprite the pick collided with */
  70546. pickedSprite: Nullable<Sprite>;
  70547. /**
  70548. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  70549. */
  70550. originMesh: Nullable<AbstractMesh>;
  70551. /**
  70552. * The ray that was used to perform the picking.
  70553. */
  70554. ray: Nullable<Ray>;
  70555. /**
  70556. * Gets the normal correspodning to the face the pick collided with
  70557. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  70558. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  70559. * @returns The normal correspodning to the face the pick collided with
  70560. */
  70561. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  70562. /**
  70563. * Gets the texture coordinates of where the pick occured
  70564. * @returns the vector containing the coordnates of the texture
  70565. */
  70566. getTextureCoordinates(): Nullable<Vector2>;
  70567. }
  70568. }
  70569. declare module BABYLON {
  70570. /**
  70571. * Gather the list of pointer event types as constants.
  70572. */
  70573. export class PointerEventTypes {
  70574. /**
  70575. * 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.
  70576. */
  70577. static readonly POINTERDOWN: number;
  70578. /**
  70579. * The pointerup event is fired when a pointer is no longer active.
  70580. */
  70581. static readonly POINTERUP: number;
  70582. /**
  70583. * The pointermove event is fired when a pointer changes coordinates.
  70584. */
  70585. static readonly POINTERMOVE: number;
  70586. /**
  70587. * The pointerwheel event is fired when a mouse wheel has been rotated.
  70588. */
  70589. static readonly POINTERWHEEL: number;
  70590. /**
  70591. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  70592. */
  70593. static readonly POINTERPICK: number;
  70594. /**
  70595. * The pointertap event is fired when a the object has been touched and released without drag.
  70596. */
  70597. static readonly POINTERTAP: number;
  70598. /**
  70599. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  70600. */
  70601. static readonly POINTERDOUBLETAP: number;
  70602. }
  70603. /**
  70604. * Base class of pointer info types.
  70605. */
  70606. export class PointerInfoBase {
  70607. /**
  70608. * Defines the type of event (PointerEventTypes)
  70609. */
  70610. type: number;
  70611. /**
  70612. * Defines the related dom event
  70613. */
  70614. event: PointerEvent | MouseWheelEvent;
  70615. /**
  70616. * Instantiates the base class of pointers info.
  70617. * @param type Defines the type of event (PointerEventTypes)
  70618. * @param event Defines the related dom event
  70619. */
  70620. constructor(
  70621. /**
  70622. * Defines the type of event (PointerEventTypes)
  70623. */
  70624. type: number,
  70625. /**
  70626. * Defines the related dom event
  70627. */
  70628. event: PointerEvent | MouseWheelEvent);
  70629. }
  70630. /**
  70631. * This class is used to store pointer related info for the onPrePointerObservable event.
  70632. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  70633. */
  70634. export class PointerInfoPre extends PointerInfoBase {
  70635. /**
  70636. * Ray from a pointer if availible (eg. 6dof controller)
  70637. */
  70638. ray: Nullable<Ray>;
  70639. /**
  70640. * Defines the local position of the pointer on the canvas.
  70641. */
  70642. localPosition: Vector2;
  70643. /**
  70644. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  70645. */
  70646. skipOnPointerObservable: boolean;
  70647. /**
  70648. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  70649. * @param type Defines the type of event (PointerEventTypes)
  70650. * @param event Defines the related dom event
  70651. * @param localX Defines the local x coordinates of the pointer when the event occured
  70652. * @param localY Defines the local y coordinates of the pointer when the event occured
  70653. */
  70654. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  70655. }
  70656. /**
  70657. * This type contains all the data related to a pointer event in Babylon.js.
  70658. * 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.
  70659. */
  70660. export class PointerInfo extends PointerInfoBase {
  70661. /**
  70662. * Defines the picking info associated to the info (if any)\
  70663. */
  70664. pickInfo: Nullable<PickingInfo>;
  70665. /**
  70666. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  70667. * @param type Defines the type of event (PointerEventTypes)
  70668. * @param event Defines the related dom event
  70669. * @param pickInfo Defines the picking info associated to the info (if any)\
  70670. */
  70671. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  70672. /**
  70673. * Defines the picking info associated to the info (if any)\
  70674. */
  70675. pickInfo: Nullable<PickingInfo>);
  70676. }
  70677. /**
  70678. * Data relating to a touch event on the screen.
  70679. */
  70680. export interface PointerTouch {
  70681. /**
  70682. * X coordinate of touch.
  70683. */
  70684. x: number;
  70685. /**
  70686. * Y coordinate of touch.
  70687. */
  70688. y: number;
  70689. /**
  70690. * Id of touch. Unique for each finger.
  70691. */
  70692. pointerId: number;
  70693. /**
  70694. * Event type passed from DOM.
  70695. */
  70696. type: any;
  70697. }
  70698. }
  70699. declare module BABYLON {
  70700. /**
  70701. * Manage the mouse inputs to control the movement of a free camera.
  70702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70703. */
  70704. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  70705. /**
  70706. * Define if touch is enabled in the mouse input
  70707. */
  70708. touchEnabled: boolean;
  70709. /**
  70710. * Defines the camera the input is attached to.
  70711. */
  70712. camera: FreeCamera;
  70713. /**
  70714. * Defines the buttons associated with the input to handle camera move.
  70715. */
  70716. buttons: number[];
  70717. /**
  70718. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  70719. */
  70720. angularSensibility: number;
  70721. private _pointerInput;
  70722. private _onMouseMove;
  70723. private _observer;
  70724. private previousPosition;
  70725. /**
  70726. * Manage the mouse inputs to control the movement of a free camera.
  70727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70728. * @param touchEnabled Defines if touch is enabled or not
  70729. */
  70730. constructor(
  70731. /**
  70732. * Define if touch is enabled in the mouse input
  70733. */
  70734. touchEnabled?: boolean);
  70735. /**
  70736. * Attach the input controls to a specific dom element to get the input from.
  70737. * @param element Defines the element the controls should be listened from
  70738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70739. */
  70740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70741. /**
  70742. * Called on JS contextmenu event.
  70743. * Override this method to provide functionality.
  70744. */
  70745. protected onContextMenu(evt: PointerEvent): void;
  70746. /**
  70747. * Detach the current controls from the specified dom element.
  70748. * @param element Defines the element to stop listening the inputs from
  70749. */
  70750. detachControl(element: Nullable<HTMLElement>): void;
  70751. /**
  70752. * Gets the class name of the current intput.
  70753. * @returns the class name
  70754. */
  70755. getClassName(): string;
  70756. /**
  70757. * Get the friendly name associated with the input class.
  70758. * @returns the input friendly name
  70759. */
  70760. getSimpleName(): string;
  70761. }
  70762. }
  70763. declare module BABYLON {
  70764. /**
  70765. * Manage the touch inputs to control the movement of a free camera.
  70766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70767. */
  70768. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  70769. /**
  70770. * Defines the camera the input is attached to.
  70771. */
  70772. camera: FreeCamera;
  70773. /**
  70774. * Defines the touch sensibility for rotation.
  70775. * The higher the faster.
  70776. */
  70777. touchAngularSensibility: number;
  70778. /**
  70779. * Defines the touch sensibility for move.
  70780. * The higher the faster.
  70781. */
  70782. touchMoveSensibility: number;
  70783. private _offsetX;
  70784. private _offsetY;
  70785. private _pointerPressed;
  70786. private _pointerInput;
  70787. private _observer;
  70788. private _onLostFocus;
  70789. /**
  70790. * Attach the input controls to a specific dom element to get the input from.
  70791. * @param element Defines the element the controls should be listened from
  70792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70793. */
  70794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70795. /**
  70796. * Detach the current controls from the specified dom element.
  70797. * @param element Defines the element to stop listening the inputs from
  70798. */
  70799. detachControl(element: Nullable<HTMLElement>): void;
  70800. /**
  70801. * Update the current camera state depending on the inputs that have been used this frame.
  70802. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70803. */
  70804. checkInputs(): void;
  70805. /**
  70806. * Gets the class name of the current intput.
  70807. * @returns the class name
  70808. */
  70809. getClassName(): string;
  70810. /**
  70811. * Get the friendly name associated with the input class.
  70812. * @returns the input friendly name
  70813. */
  70814. getSimpleName(): string;
  70815. }
  70816. }
  70817. declare module BABYLON {
  70818. /**
  70819. * Default Inputs manager for the FreeCamera.
  70820. * It groups all the default supported inputs for ease of use.
  70821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70822. */
  70823. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  70824. /**
  70825. * Instantiates a new FreeCameraInputsManager.
  70826. * @param camera Defines the camera the inputs belong to
  70827. */
  70828. constructor(camera: FreeCamera);
  70829. /**
  70830. * Add keyboard input support to the input manager.
  70831. * @returns the current input manager
  70832. */
  70833. addKeyboard(): FreeCameraInputsManager;
  70834. /**
  70835. * Add mouse input support to the input manager.
  70836. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  70837. * @returns the current input manager
  70838. */
  70839. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  70840. /**
  70841. * Add touch input support to the input manager.
  70842. * @returns the current input manager
  70843. */
  70844. addTouch(): FreeCameraInputsManager;
  70845. }
  70846. }
  70847. declare module BABYLON {
  70848. /**
  70849. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70850. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  70851. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70852. */
  70853. export class FreeCamera extends TargetCamera {
  70854. /**
  70855. * Define the collision ellipsoid of the camera.
  70856. * This is helpful to simulate a camera body like the player body around the camera
  70857. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  70858. */
  70859. ellipsoid: Vector3;
  70860. /**
  70861. * Define an offset for the position of the ellipsoid around the camera.
  70862. * This can be helpful to determine the center of the body near the gravity center of the body
  70863. * instead of its head.
  70864. */
  70865. ellipsoidOffset: Vector3;
  70866. /**
  70867. * Enable or disable collisions of the camera with the rest of the scene objects.
  70868. */
  70869. checkCollisions: boolean;
  70870. /**
  70871. * Enable or disable gravity on the camera.
  70872. */
  70873. applyGravity: boolean;
  70874. /**
  70875. * Define the input manager associated to the camera.
  70876. */
  70877. inputs: FreeCameraInputsManager;
  70878. /**
  70879. * Gets the input sensibility for a mouse input. (default is 2000.0)
  70880. * Higher values reduce sensitivity.
  70881. */
  70882. /**
  70883. * Sets the input sensibility for a mouse input. (default is 2000.0)
  70884. * Higher values reduce sensitivity.
  70885. */
  70886. angularSensibility: number;
  70887. /**
  70888. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70889. */
  70890. keysUp: number[];
  70891. /**
  70892. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70893. */
  70894. keysDown: number[];
  70895. /**
  70896. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70897. */
  70898. keysLeft: number[];
  70899. /**
  70900. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70901. */
  70902. keysRight: number[];
  70903. /**
  70904. * Event raised when the camera collide with a mesh in the scene.
  70905. */
  70906. onCollide: (collidedMesh: AbstractMesh) => void;
  70907. private _collider;
  70908. private _needMoveForGravity;
  70909. private _oldPosition;
  70910. private _diffPosition;
  70911. private _newPosition;
  70912. /** @hidden */
  70913. _localDirection: Vector3;
  70914. /** @hidden */
  70915. _transformedDirection: Vector3;
  70916. /**
  70917. * Instantiates a Free Camera.
  70918. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70919. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  70920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70921. * @param name Define the name of the camera in the scene
  70922. * @param position Define the start position of the camera in the scene
  70923. * @param scene Define the scene the camera belongs to
  70924. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70925. */
  70926. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70927. /**
  70928. * Attached controls to the current camera.
  70929. * @param element Defines the element the controls should be listened from
  70930. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70931. */
  70932. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70933. /**
  70934. * Detach the current controls from the camera.
  70935. * The camera will stop reacting to inputs.
  70936. * @param element Defines the element to stop listening the inputs from
  70937. */
  70938. detachControl(element: HTMLElement): void;
  70939. private _collisionMask;
  70940. /**
  70941. * Define a collision mask to limit the list of object the camera can collide with
  70942. */
  70943. collisionMask: number;
  70944. /** @hidden */
  70945. _collideWithWorld(displacement: Vector3): void;
  70946. private _onCollisionPositionChange;
  70947. /** @hidden */
  70948. _checkInputs(): void;
  70949. /** @hidden */
  70950. _decideIfNeedsToMove(): boolean;
  70951. /** @hidden */
  70952. _updatePosition(): void;
  70953. /**
  70954. * Destroy the camera and release the current resources hold by it.
  70955. */
  70956. dispose(): void;
  70957. /**
  70958. * Gets the current object class name.
  70959. * @return the class name
  70960. */
  70961. getClassName(): string;
  70962. }
  70963. }
  70964. declare module BABYLON {
  70965. /**
  70966. * Represents a gamepad control stick position
  70967. */
  70968. export class StickValues {
  70969. /**
  70970. * The x component of the control stick
  70971. */
  70972. x: number;
  70973. /**
  70974. * The y component of the control stick
  70975. */
  70976. y: number;
  70977. /**
  70978. * Initializes the gamepad x and y control stick values
  70979. * @param x The x component of the gamepad control stick value
  70980. * @param y The y component of the gamepad control stick value
  70981. */
  70982. constructor(
  70983. /**
  70984. * The x component of the control stick
  70985. */
  70986. x: number,
  70987. /**
  70988. * The y component of the control stick
  70989. */
  70990. y: number);
  70991. }
  70992. /**
  70993. * An interface which manages callbacks for gamepad button changes
  70994. */
  70995. export interface GamepadButtonChanges {
  70996. /**
  70997. * Called when a gamepad has been changed
  70998. */
  70999. changed: boolean;
  71000. /**
  71001. * Called when a gamepad press event has been triggered
  71002. */
  71003. pressChanged: boolean;
  71004. /**
  71005. * Called when a touch event has been triggered
  71006. */
  71007. touchChanged: boolean;
  71008. /**
  71009. * Called when a value has changed
  71010. */
  71011. valueChanged: boolean;
  71012. }
  71013. /**
  71014. * Represents a gamepad
  71015. */
  71016. export class Gamepad {
  71017. /**
  71018. * The id of the gamepad
  71019. */
  71020. id: string;
  71021. /**
  71022. * The index of the gamepad
  71023. */
  71024. index: number;
  71025. /**
  71026. * The browser gamepad
  71027. */
  71028. browserGamepad: any;
  71029. /**
  71030. * Specifies what type of gamepad this represents
  71031. */
  71032. type: number;
  71033. private _leftStick;
  71034. private _rightStick;
  71035. /** @hidden */
  71036. _isConnected: boolean;
  71037. private _leftStickAxisX;
  71038. private _leftStickAxisY;
  71039. private _rightStickAxisX;
  71040. private _rightStickAxisY;
  71041. /**
  71042. * Triggered when the left control stick has been changed
  71043. */
  71044. private _onleftstickchanged;
  71045. /**
  71046. * Triggered when the right control stick has been changed
  71047. */
  71048. private _onrightstickchanged;
  71049. /**
  71050. * Represents a gamepad controller
  71051. */
  71052. static GAMEPAD: number;
  71053. /**
  71054. * Represents a generic controller
  71055. */
  71056. static GENERIC: number;
  71057. /**
  71058. * Represents an XBox controller
  71059. */
  71060. static XBOX: number;
  71061. /**
  71062. * Represents a pose-enabled controller
  71063. */
  71064. static POSE_ENABLED: number;
  71065. /**
  71066. * Specifies whether the left control stick should be Y-inverted
  71067. */
  71068. protected _invertLeftStickY: boolean;
  71069. /**
  71070. * Specifies if the gamepad has been connected
  71071. */
  71072. readonly isConnected: boolean;
  71073. /**
  71074. * Initializes the gamepad
  71075. * @param id The id of the gamepad
  71076. * @param index The index of the gamepad
  71077. * @param browserGamepad The browser gamepad
  71078. * @param leftStickX The x component of the left joystick
  71079. * @param leftStickY The y component of the left joystick
  71080. * @param rightStickX The x component of the right joystick
  71081. * @param rightStickY The y component of the right joystick
  71082. */
  71083. constructor(
  71084. /**
  71085. * The id of the gamepad
  71086. */
  71087. id: string,
  71088. /**
  71089. * The index of the gamepad
  71090. */
  71091. index: number,
  71092. /**
  71093. * The browser gamepad
  71094. */
  71095. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71096. /**
  71097. * Callback triggered when the left joystick has changed
  71098. * @param callback
  71099. */
  71100. onleftstickchanged(callback: (values: StickValues) => void): void;
  71101. /**
  71102. * Callback triggered when the right joystick has changed
  71103. * @param callback
  71104. */
  71105. onrightstickchanged(callback: (values: StickValues) => void): void;
  71106. /**
  71107. * Gets the left joystick
  71108. */
  71109. /**
  71110. * Sets the left joystick values
  71111. */
  71112. leftStick: StickValues;
  71113. /**
  71114. * Gets the right joystick
  71115. */
  71116. /**
  71117. * Sets the right joystick value
  71118. */
  71119. rightStick: StickValues;
  71120. /**
  71121. * Updates the gamepad joystick positions
  71122. */
  71123. update(): void;
  71124. /**
  71125. * Disposes the gamepad
  71126. */
  71127. dispose(): void;
  71128. }
  71129. /**
  71130. * Represents a generic gamepad
  71131. */
  71132. export class GenericPad extends Gamepad {
  71133. private _buttons;
  71134. private _onbuttondown;
  71135. private _onbuttonup;
  71136. /**
  71137. * Observable triggered when a button has been pressed
  71138. */
  71139. onButtonDownObservable: Observable<number>;
  71140. /**
  71141. * Observable triggered when a button has been released
  71142. */
  71143. onButtonUpObservable: Observable<number>;
  71144. /**
  71145. * Callback triggered when a button has been pressed
  71146. * @param callback Called when a button has been pressed
  71147. */
  71148. onbuttondown(callback: (buttonPressed: number) => void): void;
  71149. /**
  71150. * Callback triggered when a button has been released
  71151. * @param callback Called when a button has been released
  71152. */
  71153. onbuttonup(callback: (buttonReleased: number) => void): void;
  71154. /**
  71155. * Initializes the generic gamepad
  71156. * @param id The id of the generic gamepad
  71157. * @param index The index of the generic gamepad
  71158. * @param browserGamepad The browser gamepad
  71159. */
  71160. constructor(id: string, index: number, browserGamepad: any);
  71161. private _setButtonValue;
  71162. /**
  71163. * Updates the generic gamepad
  71164. */
  71165. update(): void;
  71166. /**
  71167. * Disposes the generic gamepad
  71168. */
  71169. dispose(): void;
  71170. }
  71171. }
  71172. declare module BABYLON {
  71173. /**
  71174. * Defines the types of pose enabled controllers that are supported
  71175. */
  71176. export enum PoseEnabledControllerType {
  71177. /**
  71178. * HTC Vive
  71179. */
  71180. VIVE = 0,
  71181. /**
  71182. * Oculus Rift
  71183. */
  71184. OCULUS = 1,
  71185. /**
  71186. * Windows mixed reality
  71187. */
  71188. WINDOWS = 2,
  71189. /**
  71190. * Samsung gear VR
  71191. */
  71192. GEAR_VR = 3,
  71193. /**
  71194. * Google Daydream
  71195. */
  71196. DAYDREAM = 4,
  71197. /**
  71198. * Generic
  71199. */
  71200. GENERIC = 5
  71201. }
  71202. /**
  71203. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71204. */
  71205. export interface MutableGamepadButton {
  71206. /**
  71207. * Value of the button/trigger
  71208. */
  71209. value: number;
  71210. /**
  71211. * If the button/trigger is currently touched
  71212. */
  71213. touched: boolean;
  71214. /**
  71215. * If the button/trigger is currently pressed
  71216. */
  71217. pressed: boolean;
  71218. }
  71219. /**
  71220. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71221. * @hidden
  71222. */
  71223. export interface ExtendedGamepadButton extends GamepadButton {
  71224. /**
  71225. * If the button/trigger is currently pressed
  71226. */
  71227. readonly pressed: boolean;
  71228. /**
  71229. * If the button/trigger is currently touched
  71230. */
  71231. readonly touched: boolean;
  71232. /**
  71233. * Value of the button/trigger
  71234. */
  71235. readonly value: number;
  71236. }
  71237. /** @hidden */
  71238. export interface _GamePadFactory {
  71239. /**
  71240. * Returns wether or not the current gamepad can be created for this type of controller.
  71241. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71242. * @returns true if it can be created, otherwise false
  71243. */
  71244. canCreate(gamepadInfo: any): boolean;
  71245. /**
  71246. * Creates a new instance of the Gamepad.
  71247. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71248. * @returns the new gamepad instance
  71249. */
  71250. create(gamepadInfo: any): Gamepad;
  71251. }
  71252. /**
  71253. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71254. */
  71255. export class PoseEnabledControllerHelper {
  71256. /** @hidden */
  71257. static _ControllerFactories: _GamePadFactory[];
  71258. /** @hidden */
  71259. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  71260. /**
  71261. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71262. * @param vrGamepad the gamepad to initialized
  71263. * @returns a vr controller of the type the gamepad identified as
  71264. */
  71265. static InitiateController(vrGamepad: any): Gamepad;
  71266. }
  71267. /**
  71268. * Defines the PoseEnabledController object that contains state of a vr capable controller
  71269. */
  71270. export class PoseEnabledController extends Gamepad implements PoseControlled {
  71271. private _deviceRoomPosition;
  71272. private _deviceRoomRotationQuaternion;
  71273. /**
  71274. * The device position in babylon space
  71275. */
  71276. devicePosition: Vector3;
  71277. /**
  71278. * The device rotation in babylon space
  71279. */
  71280. deviceRotationQuaternion: Quaternion;
  71281. /**
  71282. * The scale factor of the device in babylon space
  71283. */
  71284. deviceScaleFactor: number;
  71285. /**
  71286. * (Likely devicePosition should be used instead) The device position in its room space
  71287. */
  71288. position: Vector3;
  71289. /**
  71290. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  71291. */
  71292. rotationQuaternion: Quaternion;
  71293. /**
  71294. * The type of controller (Eg. Windows mixed reality)
  71295. */
  71296. controllerType: PoseEnabledControllerType;
  71297. protected _calculatedPosition: Vector3;
  71298. private _calculatedRotation;
  71299. /**
  71300. * The raw pose from the device
  71301. */
  71302. rawPose: DevicePose;
  71303. private _trackPosition;
  71304. private _maxRotationDistFromHeadset;
  71305. private _draggedRoomRotation;
  71306. /**
  71307. * @hidden
  71308. */
  71309. _disableTrackPosition(fixedPosition: Vector3): void;
  71310. /**
  71311. * Internal, the mesh attached to the controller
  71312. * @hidden
  71313. */
  71314. _mesh: Nullable<AbstractMesh>;
  71315. private _poseControlledCamera;
  71316. private _leftHandSystemQuaternion;
  71317. /**
  71318. * Internal, matrix used to convert room space to babylon space
  71319. * @hidden
  71320. */
  71321. _deviceToWorld: Matrix;
  71322. /**
  71323. * Node to be used when casting a ray from the controller
  71324. * @hidden
  71325. */
  71326. _pointingPoseNode: Nullable<TransformNode>;
  71327. /**
  71328. * Name of the child mesh that can be used to cast a ray from the controller
  71329. */
  71330. static readonly POINTING_POSE: string;
  71331. /**
  71332. * Creates a new PoseEnabledController from a gamepad
  71333. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  71334. */
  71335. constructor(browserGamepad: any);
  71336. private _workingMatrix;
  71337. /**
  71338. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  71339. */
  71340. update(): void;
  71341. /**
  71342. * Updates only the pose device and mesh without doing any button event checking
  71343. */
  71344. protected _updatePoseAndMesh(): void;
  71345. /**
  71346. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  71347. * @param poseData raw pose fromthe device
  71348. */
  71349. updateFromDevice(poseData: DevicePose): void;
  71350. /**
  71351. * @hidden
  71352. */
  71353. _meshAttachedObservable: Observable<AbstractMesh>;
  71354. /**
  71355. * Attaches a mesh to the controller
  71356. * @param mesh the mesh to be attached
  71357. */
  71358. attachToMesh(mesh: AbstractMesh): void;
  71359. /**
  71360. * Attaches the controllers mesh to a camera
  71361. * @param camera the camera the mesh should be attached to
  71362. */
  71363. attachToPoseControlledCamera(camera: TargetCamera): void;
  71364. /**
  71365. * Disposes of the controller
  71366. */
  71367. dispose(): void;
  71368. /**
  71369. * The mesh that is attached to the controller
  71370. */
  71371. readonly mesh: Nullable<AbstractMesh>;
  71372. /**
  71373. * Gets the ray of the controller in the direction the controller is pointing
  71374. * @param length the length the resulting ray should be
  71375. * @returns a ray in the direction the controller is pointing
  71376. */
  71377. getForwardRay(length?: number): Ray;
  71378. }
  71379. }
  71380. declare module BABYLON {
  71381. /**
  71382. * Defines the WebVRController object that represents controllers tracked in 3D space
  71383. */
  71384. export abstract class WebVRController extends PoseEnabledController {
  71385. /**
  71386. * Internal, the default controller model for the controller
  71387. */
  71388. protected _defaultModel: AbstractMesh;
  71389. /**
  71390. * Fired when the trigger state has changed
  71391. */
  71392. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  71393. /**
  71394. * Fired when the main button state has changed
  71395. */
  71396. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71397. /**
  71398. * Fired when the secondary button state has changed
  71399. */
  71400. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71401. /**
  71402. * Fired when the pad state has changed
  71403. */
  71404. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  71405. /**
  71406. * Fired when controllers stick values have changed
  71407. */
  71408. onPadValuesChangedObservable: Observable<StickValues>;
  71409. /**
  71410. * Array of button availible on the controller
  71411. */
  71412. protected _buttons: Array<MutableGamepadButton>;
  71413. private _onButtonStateChange;
  71414. /**
  71415. * Fired when a controller button's state has changed
  71416. * @param callback the callback containing the button that was modified
  71417. */
  71418. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  71419. /**
  71420. * X and Y axis corrisponding to the controllers joystick
  71421. */
  71422. pad: StickValues;
  71423. /**
  71424. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  71425. */
  71426. hand: string;
  71427. /**
  71428. * The default controller model for the controller
  71429. */
  71430. readonly defaultModel: AbstractMesh;
  71431. /**
  71432. * Creates a new WebVRController from a gamepad
  71433. * @param vrGamepad the gamepad that the WebVRController should be created from
  71434. */
  71435. constructor(vrGamepad: any);
  71436. /**
  71437. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  71438. */
  71439. update(): void;
  71440. /**
  71441. * Function to be called when a button is modified
  71442. */
  71443. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  71444. /**
  71445. * Loads a mesh and attaches it to the controller
  71446. * @param scene the scene the mesh should be added to
  71447. * @param meshLoaded callback for when the mesh has been loaded
  71448. */
  71449. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  71450. private _setButtonValue;
  71451. private _changes;
  71452. private _checkChanges;
  71453. /**
  71454. * Disposes of th webVRCOntroller
  71455. */
  71456. dispose(): void;
  71457. }
  71458. }
  71459. declare module BABYLON {
  71460. /**
  71461. * The HemisphericLight simulates the ambient environment light,
  71462. * so the passed direction is the light reflection direction, not the incoming direction.
  71463. */
  71464. export class HemisphericLight extends Light {
  71465. /**
  71466. * The groundColor is the light in the opposite direction to the one specified during creation.
  71467. * 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.
  71468. */
  71469. groundColor: Color3;
  71470. /**
  71471. * The light reflection direction, not the incoming direction.
  71472. */
  71473. direction: Vector3;
  71474. /**
  71475. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  71476. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  71477. * The HemisphericLight can't cast shadows.
  71478. * Documentation : https://doc.babylonjs.com/babylon101/lights
  71479. * @param name The friendly name of the light
  71480. * @param direction The direction of the light reflection
  71481. * @param scene The scene the light belongs to
  71482. */
  71483. constructor(name: string, direction: Vector3, scene: Scene);
  71484. protected _buildUniformLayout(): void;
  71485. /**
  71486. * Returns the string "HemisphericLight".
  71487. * @return The class name
  71488. */
  71489. getClassName(): string;
  71490. /**
  71491. * Sets the HemisphericLight direction towards the passed target (Vector3).
  71492. * Returns the updated direction.
  71493. * @param target The target the direction should point to
  71494. * @return The computed direction
  71495. */
  71496. setDirectionToTarget(target: Vector3): Vector3;
  71497. /**
  71498. * Returns the shadow generator associated to the light.
  71499. * @returns Always null for hemispheric lights because it does not support shadows.
  71500. */
  71501. getShadowGenerator(): Nullable<IShadowGenerator>;
  71502. /**
  71503. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  71504. * @param effect The effect to update
  71505. * @param lightIndex The index of the light in the effect to update
  71506. * @returns The hemispheric light
  71507. */
  71508. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  71509. /**
  71510. * Computes the world matrix of the node
  71511. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71512. * @param useWasUpdatedFlag defines a reserved property
  71513. * @returns the world matrix
  71514. */
  71515. computeWorldMatrix(): Matrix;
  71516. /**
  71517. * Returns the integer 3.
  71518. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  71519. */
  71520. getTypeID(): number;
  71521. /**
  71522. * Prepares the list of defines specific to the light type.
  71523. * @param defines the list of defines
  71524. * @param lightIndex defines the index of the light for the effect
  71525. */
  71526. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  71527. }
  71528. }
  71529. declare module BABYLON {
  71530. /**
  71531. * This represents all the required metrics to create a VR camera.
  71532. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  71533. */
  71534. export class VRCameraMetrics {
  71535. /**
  71536. * Define the horizontal resolution off the screen.
  71537. */
  71538. hResolution: number;
  71539. /**
  71540. * Define the vertical resolution off the screen.
  71541. */
  71542. vResolution: number;
  71543. /**
  71544. * Define the horizontal screen size.
  71545. */
  71546. hScreenSize: number;
  71547. /**
  71548. * Define the vertical screen size.
  71549. */
  71550. vScreenSize: number;
  71551. /**
  71552. * Define the vertical screen center position.
  71553. */
  71554. vScreenCenter: number;
  71555. /**
  71556. * Define the distance of the eyes to the screen.
  71557. */
  71558. eyeToScreenDistance: number;
  71559. /**
  71560. * Define the distance between both lenses
  71561. */
  71562. lensSeparationDistance: number;
  71563. /**
  71564. * Define the distance between both viewer's eyes.
  71565. */
  71566. interpupillaryDistance: number;
  71567. /**
  71568. * Define the distortion factor of the VR postprocess.
  71569. * Please, touch with care.
  71570. */
  71571. distortionK: number[];
  71572. /**
  71573. * Define the chromatic aberration correction factors for the VR post process.
  71574. */
  71575. chromaAbCorrection: number[];
  71576. /**
  71577. * Define the scale factor of the post process.
  71578. * The smaller the better but the slower.
  71579. */
  71580. postProcessScaleFactor: number;
  71581. /**
  71582. * Define an offset for the lens center.
  71583. */
  71584. lensCenterOffset: number;
  71585. /**
  71586. * Define if the current vr camera should compensate the distortion of the lense or not.
  71587. */
  71588. compensateDistortion: boolean;
  71589. /**
  71590. * Defines if multiview should be enabled when rendering (Default: false)
  71591. */
  71592. multiviewEnabled: boolean;
  71593. /**
  71594. * Gets the rendering aspect ratio based on the provided resolutions.
  71595. */
  71596. readonly aspectRatio: number;
  71597. /**
  71598. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  71599. */
  71600. readonly aspectRatioFov: number;
  71601. /**
  71602. * @hidden
  71603. */
  71604. readonly leftHMatrix: Matrix;
  71605. /**
  71606. * @hidden
  71607. */
  71608. readonly rightHMatrix: Matrix;
  71609. /**
  71610. * @hidden
  71611. */
  71612. readonly leftPreViewMatrix: Matrix;
  71613. /**
  71614. * @hidden
  71615. */
  71616. readonly rightPreViewMatrix: Matrix;
  71617. /**
  71618. * Get the default VRMetrics based on the most generic setup.
  71619. * @returns the default vr metrics
  71620. */
  71621. static GetDefault(): VRCameraMetrics;
  71622. }
  71623. }
  71624. declare module BABYLON {
  71625. /** @hidden */
  71626. export var vrDistortionCorrectionPixelShader: {
  71627. name: string;
  71628. shader: string;
  71629. };
  71630. }
  71631. declare module BABYLON {
  71632. /**
  71633. * VRDistortionCorrectionPostProcess used for mobile VR
  71634. */
  71635. export class VRDistortionCorrectionPostProcess extends PostProcess {
  71636. private _isRightEye;
  71637. private _distortionFactors;
  71638. private _postProcessScaleFactor;
  71639. private _lensCenterOffset;
  71640. private _scaleIn;
  71641. private _scaleFactor;
  71642. private _lensCenter;
  71643. /**
  71644. * Initializes the VRDistortionCorrectionPostProcess
  71645. * @param name The name of the effect.
  71646. * @param camera The camera to apply the render pass to.
  71647. * @param isRightEye If this is for the right eye distortion
  71648. * @param vrMetrics All the required metrics for the VR camera
  71649. */
  71650. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  71651. }
  71652. /**
  71653. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  71654. * This will not be used for webXR as it supports displaying texture arrays directly
  71655. */
  71656. export class VRMultiviewToSingleview extends PostProcess {
  71657. /**
  71658. * Initializes a VRMultiviewToSingleview
  71659. * @param name name of the post process
  71660. * @param camera camera to be applied to
  71661. * @param scaleFactor scaling factor to the size of the output texture
  71662. */
  71663. constructor(name: string, camera: Camera, scaleFactor: number);
  71664. }
  71665. }
  71666. declare module BABYLON {
  71667. /**
  71668. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  71669. * IMPORTANT!! The data is right-hand data.
  71670. * @export
  71671. * @interface DevicePose
  71672. */
  71673. export interface DevicePose {
  71674. /**
  71675. * The position of the device, values in array are [x,y,z].
  71676. */
  71677. readonly position: Nullable<Float32Array>;
  71678. /**
  71679. * The linearVelocity of the device, values in array are [x,y,z].
  71680. */
  71681. readonly linearVelocity: Nullable<Float32Array>;
  71682. /**
  71683. * The linearAcceleration of the device, values in array are [x,y,z].
  71684. */
  71685. readonly linearAcceleration: Nullable<Float32Array>;
  71686. /**
  71687. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  71688. */
  71689. readonly orientation: Nullable<Float32Array>;
  71690. /**
  71691. * The angularVelocity of the device, values in array are [x,y,z].
  71692. */
  71693. readonly angularVelocity: Nullable<Float32Array>;
  71694. /**
  71695. * The angularAcceleration of the device, values in array are [x,y,z].
  71696. */
  71697. readonly angularAcceleration: Nullable<Float32Array>;
  71698. }
  71699. /**
  71700. * Interface representing a pose controlled object in Babylon.
  71701. * A pose controlled object has both regular pose values as well as pose values
  71702. * from an external device such as a VR head mounted display
  71703. */
  71704. export interface PoseControlled {
  71705. /**
  71706. * The position of the object in babylon space.
  71707. */
  71708. position: Vector3;
  71709. /**
  71710. * The rotation quaternion of the object in babylon space.
  71711. */
  71712. rotationQuaternion: Quaternion;
  71713. /**
  71714. * The position of the device in babylon space.
  71715. */
  71716. devicePosition?: Vector3;
  71717. /**
  71718. * The rotation quaternion of the device in babylon space.
  71719. */
  71720. deviceRotationQuaternion: Quaternion;
  71721. /**
  71722. * The raw pose coming from the device.
  71723. */
  71724. rawPose: Nullable<DevicePose>;
  71725. /**
  71726. * The scale of the device to be used when translating from device space to babylon space.
  71727. */
  71728. deviceScaleFactor: number;
  71729. /**
  71730. * Updates the poseControlled values based on the input device pose.
  71731. * @param poseData the pose data to update the object with
  71732. */
  71733. updateFromDevice(poseData: DevicePose): void;
  71734. }
  71735. /**
  71736. * Set of options to customize the webVRCamera
  71737. */
  71738. export interface WebVROptions {
  71739. /**
  71740. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  71741. */
  71742. trackPosition?: boolean;
  71743. /**
  71744. * Sets the scale of the vrDevice in babylon space. (default: 1)
  71745. */
  71746. positionScale?: number;
  71747. /**
  71748. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  71749. */
  71750. displayName?: string;
  71751. /**
  71752. * Should the native controller meshes be initialized. (default: true)
  71753. */
  71754. controllerMeshes?: boolean;
  71755. /**
  71756. * Creating a default HemiLight only on controllers. (default: true)
  71757. */
  71758. defaultLightingOnControllers?: boolean;
  71759. /**
  71760. * If you don't want to use the default VR button of the helper. (default: false)
  71761. */
  71762. useCustomVRButton?: boolean;
  71763. /**
  71764. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  71765. */
  71766. customVRButton?: HTMLButtonElement;
  71767. /**
  71768. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  71769. */
  71770. rayLength?: number;
  71771. /**
  71772. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  71773. */
  71774. defaultHeight?: number;
  71775. /**
  71776. * If multiview should be used if availible (default: false)
  71777. */
  71778. useMultiview?: boolean;
  71779. }
  71780. /**
  71781. * This represents a WebVR camera.
  71782. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  71783. * @example http://doc.babylonjs.com/how_to/webvr_camera
  71784. */
  71785. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  71786. private webVROptions;
  71787. /**
  71788. * @hidden
  71789. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  71790. */
  71791. _vrDevice: any;
  71792. /**
  71793. * The rawPose of the vrDevice.
  71794. */
  71795. rawPose: Nullable<DevicePose>;
  71796. private _onVREnabled;
  71797. private _specsVersion;
  71798. private _attached;
  71799. private _frameData;
  71800. protected _descendants: Array<Node>;
  71801. private _deviceRoomPosition;
  71802. /** @hidden */
  71803. _deviceRoomRotationQuaternion: Quaternion;
  71804. private _standingMatrix;
  71805. /**
  71806. * Represents device position in babylon space.
  71807. */
  71808. devicePosition: Vector3;
  71809. /**
  71810. * Represents device rotation in babylon space.
  71811. */
  71812. deviceRotationQuaternion: Quaternion;
  71813. /**
  71814. * The scale of the device to be used when translating from device space to babylon space.
  71815. */
  71816. deviceScaleFactor: number;
  71817. private _deviceToWorld;
  71818. private _worldToDevice;
  71819. /**
  71820. * References to the webVR controllers for the vrDevice.
  71821. */
  71822. controllers: Array<WebVRController>;
  71823. /**
  71824. * Emits an event when a controller is attached.
  71825. */
  71826. onControllersAttachedObservable: Observable<WebVRController[]>;
  71827. /**
  71828. * Emits an event when a controller's mesh has been loaded;
  71829. */
  71830. onControllerMeshLoadedObservable: Observable<WebVRController>;
  71831. /**
  71832. * Emits an event when the HMD's pose has been updated.
  71833. */
  71834. onPoseUpdatedFromDeviceObservable: Observable<any>;
  71835. private _poseSet;
  71836. /**
  71837. * If the rig cameras be used as parent instead of this camera.
  71838. */
  71839. rigParenting: boolean;
  71840. private _lightOnControllers;
  71841. private _defaultHeight?;
  71842. /**
  71843. * Instantiates a WebVRFreeCamera.
  71844. * @param name The name of the WebVRFreeCamera
  71845. * @param position The starting anchor position for the camera
  71846. * @param scene The scene the camera belongs to
  71847. * @param webVROptions a set of customizable options for the webVRCamera
  71848. */
  71849. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  71850. /**
  71851. * Gets the device distance from the ground in meters.
  71852. * @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.
  71853. */
  71854. deviceDistanceToRoomGround(): number;
  71855. /**
  71856. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71857. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  71858. */
  71859. useStandingMatrix(callback?: (bool: boolean) => void): void;
  71860. /**
  71861. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71862. * @returns A promise with a boolean set to if the standing matrix is supported.
  71863. */
  71864. useStandingMatrixAsync(): Promise<boolean>;
  71865. /**
  71866. * Disposes the camera
  71867. */
  71868. dispose(): void;
  71869. /**
  71870. * Gets a vrController by name.
  71871. * @param name The name of the controller to retreive
  71872. * @returns the controller matching the name specified or null if not found
  71873. */
  71874. getControllerByName(name: string): Nullable<WebVRController>;
  71875. private _leftController;
  71876. /**
  71877. * The controller corrisponding to the users left hand.
  71878. */
  71879. readonly leftController: Nullable<WebVRController>;
  71880. private _rightController;
  71881. /**
  71882. * The controller corrisponding to the users right hand.
  71883. */
  71884. readonly rightController: Nullable<WebVRController>;
  71885. /**
  71886. * Casts a ray forward from the vrCamera's gaze.
  71887. * @param length Length of the ray (default: 100)
  71888. * @returns the ray corrisponding to the gaze
  71889. */
  71890. getForwardRay(length?: number): Ray;
  71891. /**
  71892. * @hidden
  71893. * Updates the camera based on device's frame data
  71894. */
  71895. _checkInputs(): void;
  71896. /**
  71897. * Updates the poseControlled values based on the input device pose.
  71898. * @param poseData Pose coming from the device
  71899. */
  71900. updateFromDevice(poseData: DevicePose): void;
  71901. private _htmlElementAttached;
  71902. private _detachIfAttached;
  71903. /**
  71904. * WebVR's attach control will start broadcasting frames to the device.
  71905. * Note that in certain browsers (chrome for example) this function must be called
  71906. * within a user-interaction callback. Example:
  71907. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  71908. *
  71909. * @param element html element to attach the vrDevice to
  71910. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  71911. */
  71912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71913. /**
  71914. * Detaches the camera from the html element and disables VR
  71915. *
  71916. * @param element html element to detach from
  71917. */
  71918. detachControl(element: HTMLElement): void;
  71919. /**
  71920. * @returns the name of this class
  71921. */
  71922. getClassName(): string;
  71923. /**
  71924. * Calls resetPose on the vrDisplay
  71925. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  71926. */
  71927. resetToCurrentRotation(): void;
  71928. /**
  71929. * @hidden
  71930. * Updates the rig cameras (left and right eye)
  71931. */
  71932. _updateRigCameras(): void;
  71933. private _workingVector;
  71934. private _oneVector;
  71935. private _workingMatrix;
  71936. private updateCacheCalled;
  71937. private _correctPositionIfNotTrackPosition;
  71938. /**
  71939. * @hidden
  71940. * Updates the cached values of the camera
  71941. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  71942. */
  71943. _updateCache(ignoreParentClass?: boolean): void;
  71944. /**
  71945. * @hidden
  71946. * Get current device position in babylon world
  71947. */
  71948. _computeDevicePosition(): void;
  71949. /**
  71950. * Updates the current device position and rotation in the babylon world
  71951. */
  71952. update(): void;
  71953. /**
  71954. * @hidden
  71955. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  71956. * @returns an identity matrix
  71957. */
  71958. _getViewMatrix(): Matrix;
  71959. private _tmpMatrix;
  71960. /**
  71961. * This function is called by the two RIG cameras.
  71962. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  71963. * @hidden
  71964. */
  71965. _getWebVRViewMatrix(): Matrix;
  71966. /** @hidden */
  71967. _getWebVRProjectionMatrix(): Matrix;
  71968. private _onGamepadConnectedObserver;
  71969. private _onGamepadDisconnectedObserver;
  71970. private _updateCacheWhenTrackingDisabledObserver;
  71971. /**
  71972. * Initializes the controllers and their meshes
  71973. */
  71974. initControllers(): void;
  71975. }
  71976. }
  71977. declare module BABYLON {
  71978. /**
  71979. * Size options for a post process
  71980. */
  71981. export type PostProcessOptions = {
  71982. width: number;
  71983. height: number;
  71984. };
  71985. /**
  71986. * PostProcess can be used to apply a shader to a texture after it has been rendered
  71987. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71988. */
  71989. export class PostProcess {
  71990. /** Name of the PostProcess. */
  71991. name: string;
  71992. /**
  71993. * Gets or sets the unique id of the post process
  71994. */
  71995. uniqueId: number;
  71996. /**
  71997. * Width of the texture to apply the post process on
  71998. */
  71999. width: number;
  72000. /**
  72001. * Height of the texture to apply the post process on
  72002. */
  72003. height: number;
  72004. /**
  72005. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72006. * @hidden
  72007. */
  72008. _outputTexture: Nullable<InternalTexture>;
  72009. /**
  72010. * Sampling mode used by the shader
  72011. * See https://doc.babylonjs.com/classes/3.1/texture
  72012. */
  72013. renderTargetSamplingMode: number;
  72014. /**
  72015. * Clear color to use when screen clearing
  72016. */
  72017. clearColor: Color4;
  72018. /**
  72019. * If the buffer needs to be cleared before applying the post process. (default: true)
  72020. * Should be set to false if shader will overwrite all previous pixels.
  72021. */
  72022. autoClear: boolean;
  72023. /**
  72024. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72025. */
  72026. alphaMode: number;
  72027. /**
  72028. * Sets the setAlphaBlendConstants of the babylon engine
  72029. */
  72030. alphaConstants: Color4;
  72031. /**
  72032. * Animations to be used for the post processing
  72033. */
  72034. animations: Animation[];
  72035. /**
  72036. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72037. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72038. */
  72039. enablePixelPerfectMode: boolean;
  72040. /**
  72041. * Force the postprocess to be applied without taking in account viewport
  72042. */
  72043. forceFullscreenViewport: boolean;
  72044. /**
  72045. * List of inspectable custom properties (used by the Inspector)
  72046. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72047. */
  72048. inspectableCustomProperties: IInspectable[];
  72049. /**
  72050. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72051. *
  72052. * | Value | Type | Description |
  72053. * | ----- | ----------------------------------- | ----------- |
  72054. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72055. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72056. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72057. *
  72058. */
  72059. scaleMode: number;
  72060. /**
  72061. * Force textures to be a power of two (default: false)
  72062. */
  72063. alwaysForcePOT: boolean;
  72064. private _samples;
  72065. /**
  72066. * Number of sample textures (default: 1)
  72067. */
  72068. samples: number;
  72069. /**
  72070. * Modify the scale of the post process to be the same as the viewport (default: false)
  72071. */
  72072. adaptScaleToCurrentViewport: boolean;
  72073. private _camera;
  72074. private _scene;
  72075. private _engine;
  72076. private _options;
  72077. private _reusable;
  72078. private _textureType;
  72079. /**
  72080. * Smart array of input and output textures for the post process.
  72081. * @hidden
  72082. */
  72083. _textures: SmartArray<InternalTexture>;
  72084. /**
  72085. * The index in _textures that corresponds to the output texture.
  72086. * @hidden
  72087. */
  72088. _currentRenderTextureInd: number;
  72089. private _effect;
  72090. private _samplers;
  72091. private _fragmentUrl;
  72092. private _vertexUrl;
  72093. private _parameters;
  72094. private _scaleRatio;
  72095. protected _indexParameters: any;
  72096. private _shareOutputWithPostProcess;
  72097. private _texelSize;
  72098. private _forcedOutputTexture;
  72099. /**
  72100. * Returns the fragment url or shader name used in the post process.
  72101. * @returns the fragment url or name in the shader store.
  72102. */
  72103. getEffectName(): string;
  72104. /**
  72105. * An event triggered when the postprocess is activated.
  72106. */
  72107. onActivateObservable: Observable<Camera>;
  72108. private _onActivateObserver;
  72109. /**
  72110. * A function that is added to the onActivateObservable
  72111. */
  72112. onActivate: Nullable<(camera: Camera) => void>;
  72113. /**
  72114. * An event triggered when the postprocess changes its size.
  72115. */
  72116. onSizeChangedObservable: Observable<PostProcess>;
  72117. private _onSizeChangedObserver;
  72118. /**
  72119. * A function that is added to the onSizeChangedObservable
  72120. */
  72121. onSizeChanged: (postProcess: PostProcess) => void;
  72122. /**
  72123. * An event triggered when the postprocess applies its effect.
  72124. */
  72125. onApplyObservable: Observable<Effect>;
  72126. private _onApplyObserver;
  72127. /**
  72128. * A function that is added to the onApplyObservable
  72129. */
  72130. onApply: (effect: Effect) => void;
  72131. /**
  72132. * An event triggered before rendering the postprocess
  72133. */
  72134. onBeforeRenderObservable: Observable<Effect>;
  72135. private _onBeforeRenderObserver;
  72136. /**
  72137. * A function that is added to the onBeforeRenderObservable
  72138. */
  72139. onBeforeRender: (effect: Effect) => void;
  72140. /**
  72141. * An event triggered after rendering the postprocess
  72142. */
  72143. onAfterRenderObservable: Observable<Effect>;
  72144. private _onAfterRenderObserver;
  72145. /**
  72146. * A function that is added to the onAfterRenderObservable
  72147. */
  72148. onAfterRender: (efect: Effect) => void;
  72149. /**
  72150. * 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
  72151. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72152. */
  72153. inputTexture: InternalTexture;
  72154. /**
  72155. * Gets the camera which post process is applied to.
  72156. * @returns The camera the post process is applied to.
  72157. */
  72158. getCamera(): Camera;
  72159. /**
  72160. * Gets the texel size of the postprocess.
  72161. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72162. */
  72163. readonly texelSize: Vector2;
  72164. /**
  72165. * Creates a new instance PostProcess
  72166. * @param name The name of the PostProcess.
  72167. * @param fragmentUrl The url of the fragment shader to be used.
  72168. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72169. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72170. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72171. * @param camera The camera to apply the render pass to.
  72172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72173. * @param engine The engine which the post process will be applied. (default: current engine)
  72174. * @param reusable If the post process can be reused on the same frame. (default: false)
  72175. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72176. * @param textureType Type of textures used when performing the post process. (default: 0)
  72177. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72178. * @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
  72179. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72180. */
  72181. constructor(
  72182. /** Name of the PostProcess. */
  72183. 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);
  72184. /**
  72185. * Gets a string idenfifying the name of the class
  72186. * @returns "PostProcess" string
  72187. */
  72188. getClassName(): string;
  72189. /**
  72190. * Gets the engine which this post process belongs to.
  72191. * @returns The engine the post process was enabled with.
  72192. */
  72193. getEngine(): Engine;
  72194. /**
  72195. * The effect that is created when initializing the post process.
  72196. * @returns The created effect corrisponding the the postprocess.
  72197. */
  72198. getEffect(): Effect;
  72199. /**
  72200. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72201. * @param postProcess The post process to share the output with.
  72202. * @returns This post process.
  72203. */
  72204. shareOutputWith(postProcess: PostProcess): PostProcess;
  72205. /**
  72206. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72207. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72208. */
  72209. useOwnOutput(): void;
  72210. /**
  72211. * Updates the effect with the current post process compile time values and recompiles the shader.
  72212. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72213. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72214. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72215. * @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
  72216. * @param onCompiled Called when the shader has been compiled.
  72217. * @param onError Called if there is an error when compiling a shader.
  72218. */
  72219. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72220. /**
  72221. * The post process is reusable if it can be used multiple times within one frame.
  72222. * @returns If the post process is reusable
  72223. */
  72224. isReusable(): boolean;
  72225. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72226. markTextureDirty(): void;
  72227. /**
  72228. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72229. * 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.
  72230. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72231. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  72232. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  72233. * @returns The target texture that was bound to be written to.
  72234. */
  72235. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  72236. /**
  72237. * If the post process is supported.
  72238. */
  72239. readonly isSupported: boolean;
  72240. /**
  72241. * The aspect ratio of the output texture.
  72242. */
  72243. readonly aspectRatio: number;
  72244. /**
  72245. * Get a value indicating if the post-process is ready to be used
  72246. * @returns true if the post-process is ready (shader is compiled)
  72247. */
  72248. isReady(): boolean;
  72249. /**
  72250. * Binds all textures and uniforms to the shader, this will be run on every pass.
  72251. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  72252. */
  72253. apply(): Nullable<Effect>;
  72254. private _disposeTextures;
  72255. /**
  72256. * Disposes the post process.
  72257. * @param camera The camera to dispose the post process on.
  72258. */
  72259. dispose(camera?: Camera): void;
  72260. }
  72261. }
  72262. declare module BABYLON {
  72263. /**
  72264. * PostProcessManager is used to manage one or more post processes or post process pipelines
  72265. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72266. */
  72267. export class PostProcessManager {
  72268. private _scene;
  72269. private _indexBuffer;
  72270. private _vertexBuffers;
  72271. /**
  72272. * Creates a new instance PostProcess
  72273. * @param scene The scene that the post process is associated with.
  72274. */
  72275. constructor(scene: Scene);
  72276. private _prepareBuffers;
  72277. private _buildIndexBuffer;
  72278. /**
  72279. * Rebuilds the vertex buffers of the manager.
  72280. * @hidden
  72281. */
  72282. _rebuild(): void;
  72283. /**
  72284. * Prepares a frame to be run through a post process.
  72285. * @param sourceTexture The input texture to the post procesess. (default: null)
  72286. * @param postProcesses An array of post processes to be run. (default: null)
  72287. * @returns True if the post processes were able to be run.
  72288. * @hidden
  72289. */
  72290. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  72291. /**
  72292. * Manually render a set of post processes to a texture.
  72293. * @param postProcesses An array of post processes to be run.
  72294. * @param targetTexture The target texture to render to.
  72295. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  72296. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  72297. * @param lodLevel defines which lod of the texture to render to
  72298. */
  72299. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  72300. /**
  72301. * Finalize the result of the output of the postprocesses.
  72302. * @param doNotPresent If true the result will not be displayed to the screen.
  72303. * @param targetTexture The target texture to render to.
  72304. * @param faceIndex The index of the face to bind the target texture to.
  72305. * @param postProcesses The array of post processes to render.
  72306. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  72307. * @hidden
  72308. */
  72309. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  72310. /**
  72311. * Disposes of the post process manager.
  72312. */
  72313. dispose(): void;
  72314. }
  72315. }
  72316. declare module BABYLON {
  72317. interface AbstractScene {
  72318. /**
  72319. * The list of layers (background and foreground) of the scene
  72320. */
  72321. layers: Array<Layer>;
  72322. }
  72323. /**
  72324. * Defines the layer scene component responsible to manage any layers
  72325. * in a given scene.
  72326. */
  72327. export class LayerSceneComponent implements ISceneComponent {
  72328. /**
  72329. * The component name helpfull to identify the component in the list of scene components.
  72330. */
  72331. readonly name: string;
  72332. /**
  72333. * The scene the component belongs to.
  72334. */
  72335. scene: Scene;
  72336. private _engine;
  72337. /**
  72338. * Creates a new instance of the component for the given scene
  72339. * @param scene Defines the scene to register the component in
  72340. */
  72341. constructor(scene: Scene);
  72342. /**
  72343. * Registers the component in a given scene
  72344. */
  72345. register(): void;
  72346. /**
  72347. * Rebuilds the elements related to this component in case of
  72348. * context lost for instance.
  72349. */
  72350. rebuild(): void;
  72351. /**
  72352. * Disposes the component and the associated ressources.
  72353. */
  72354. dispose(): void;
  72355. private _draw;
  72356. private _drawCameraPredicate;
  72357. private _drawCameraBackground;
  72358. private _drawCameraForeground;
  72359. private _drawRenderTargetPredicate;
  72360. private _drawRenderTargetBackground;
  72361. private _drawRenderTargetForeground;
  72362. }
  72363. }
  72364. declare module BABYLON {
  72365. /** @hidden */
  72366. export var layerPixelShader: {
  72367. name: string;
  72368. shader: string;
  72369. };
  72370. }
  72371. declare module BABYLON {
  72372. /** @hidden */
  72373. export var layerVertexShader: {
  72374. name: string;
  72375. shader: string;
  72376. };
  72377. }
  72378. declare module BABYLON {
  72379. /**
  72380. * This represents a full screen 2d layer.
  72381. * This can be useful to display a picture in the background of your scene for instance.
  72382. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72383. */
  72384. export class Layer {
  72385. /**
  72386. * Define the name of the layer.
  72387. */
  72388. name: string;
  72389. /**
  72390. * Define the texture the layer should display.
  72391. */
  72392. texture: Nullable<Texture>;
  72393. /**
  72394. * Is the layer in background or foreground.
  72395. */
  72396. isBackground: boolean;
  72397. /**
  72398. * Define the color of the layer (instead of texture).
  72399. */
  72400. color: Color4;
  72401. /**
  72402. * Define the scale of the layer in order to zoom in out of the texture.
  72403. */
  72404. scale: Vector2;
  72405. /**
  72406. * Define an offset for the layer in order to shift the texture.
  72407. */
  72408. offset: Vector2;
  72409. /**
  72410. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  72411. */
  72412. alphaBlendingMode: number;
  72413. /**
  72414. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  72415. * Alpha test will not mix with the background color in case of transparency.
  72416. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  72417. */
  72418. alphaTest: boolean;
  72419. /**
  72420. * Define a mask to restrict the layer to only some of the scene cameras.
  72421. */
  72422. layerMask: number;
  72423. /**
  72424. * Define the list of render target the layer is visible into.
  72425. */
  72426. renderTargetTextures: RenderTargetTexture[];
  72427. /**
  72428. * Define if the layer is only used in renderTarget or if it also
  72429. * renders in the main frame buffer of the canvas.
  72430. */
  72431. renderOnlyInRenderTargetTextures: boolean;
  72432. private _scene;
  72433. private _vertexBuffers;
  72434. private _indexBuffer;
  72435. private _effect;
  72436. private _alphaTestEffect;
  72437. /**
  72438. * An event triggered when the layer is disposed.
  72439. */
  72440. onDisposeObservable: Observable<Layer>;
  72441. private _onDisposeObserver;
  72442. /**
  72443. * Back compatibility with callback before the onDisposeObservable existed.
  72444. * The set callback will be triggered when the layer has been disposed.
  72445. */
  72446. onDispose: () => void;
  72447. /**
  72448. * An event triggered before rendering the scene
  72449. */
  72450. onBeforeRenderObservable: Observable<Layer>;
  72451. private _onBeforeRenderObserver;
  72452. /**
  72453. * Back compatibility with callback before the onBeforeRenderObservable existed.
  72454. * The set callback will be triggered just before rendering the layer.
  72455. */
  72456. onBeforeRender: () => void;
  72457. /**
  72458. * An event triggered after rendering the scene
  72459. */
  72460. onAfterRenderObservable: Observable<Layer>;
  72461. private _onAfterRenderObserver;
  72462. /**
  72463. * Back compatibility with callback before the onAfterRenderObservable existed.
  72464. * The set callback will be triggered just after rendering the layer.
  72465. */
  72466. onAfterRender: () => void;
  72467. /**
  72468. * Instantiates a new layer.
  72469. * This represents a full screen 2d layer.
  72470. * This can be useful to display a picture in the background of your scene for instance.
  72471. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72472. * @param name Define the name of the layer in the scene
  72473. * @param imgUrl Define the url of the texture to display in the layer
  72474. * @param scene Define the scene the layer belongs to
  72475. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  72476. * @param color Defines a color for the layer
  72477. */
  72478. constructor(
  72479. /**
  72480. * Define the name of the layer.
  72481. */
  72482. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  72483. private _createIndexBuffer;
  72484. /** @hidden */
  72485. _rebuild(): void;
  72486. /**
  72487. * Renders the layer in the scene.
  72488. */
  72489. render(): void;
  72490. /**
  72491. * Disposes and releases the associated ressources.
  72492. */
  72493. dispose(): void;
  72494. }
  72495. }
  72496. declare module BABYLON {
  72497. interface AbstractScene {
  72498. /**
  72499. * The list of procedural textures added to the scene
  72500. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72501. */
  72502. proceduralTextures: Array<ProceduralTexture>;
  72503. }
  72504. /**
  72505. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  72506. * in a given scene.
  72507. */
  72508. export class ProceduralTextureSceneComponent implements ISceneComponent {
  72509. /**
  72510. * The component name helpfull to identify the component in the list of scene components.
  72511. */
  72512. readonly name: string;
  72513. /**
  72514. * The scene the component belongs to.
  72515. */
  72516. scene: Scene;
  72517. /**
  72518. * Creates a new instance of the component for the given scene
  72519. * @param scene Defines the scene to register the component in
  72520. */
  72521. constructor(scene: Scene);
  72522. /**
  72523. * Registers the component in a given scene
  72524. */
  72525. register(): void;
  72526. /**
  72527. * Rebuilds the elements related to this component in case of
  72528. * context lost for instance.
  72529. */
  72530. rebuild(): void;
  72531. /**
  72532. * Disposes the component and the associated ressources.
  72533. */
  72534. dispose(): void;
  72535. private _beforeClear;
  72536. }
  72537. }
  72538. declare module BABYLON {
  72539. /** @hidden */
  72540. export var proceduralVertexShader: {
  72541. name: string;
  72542. shader: string;
  72543. };
  72544. }
  72545. declare module BABYLON {
  72546. /**
  72547. * 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.
  72548. * This is the base class of any Procedural texture and contains most of the shareable code.
  72549. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72550. */
  72551. export class ProceduralTexture extends Texture {
  72552. isCube: boolean;
  72553. /**
  72554. * Define if the texture is enabled or not (disabled texture will not render)
  72555. */
  72556. isEnabled: boolean;
  72557. /**
  72558. * Define if the texture must be cleared before rendering (default is true)
  72559. */
  72560. autoClear: boolean;
  72561. /**
  72562. * Callback called when the texture is generated
  72563. */
  72564. onGenerated: () => void;
  72565. /**
  72566. * Event raised when the texture is generated
  72567. */
  72568. onGeneratedObservable: Observable<ProceduralTexture>;
  72569. /** @hidden */
  72570. _generateMipMaps: boolean;
  72571. /** @hidden **/
  72572. _effect: Effect;
  72573. /** @hidden */
  72574. _textures: {
  72575. [key: string]: Texture;
  72576. };
  72577. private _size;
  72578. private _currentRefreshId;
  72579. private _refreshRate;
  72580. private _vertexBuffers;
  72581. private _indexBuffer;
  72582. private _uniforms;
  72583. private _samplers;
  72584. private _fragment;
  72585. private _floats;
  72586. private _ints;
  72587. private _floatsArrays;
  72588. private _colors3;
  72589. private _colors4;
  72590. private _vectors2;
  72591. private _vectors3;
  72592. private _matrices;
  72593. private _fallbackTexture;
  72594. private _fallbackTextureUsed;
  72595. private _engine;
  72596. private _cachedDefines;
  72597. private _contentUpdateId;
  72598. private _contentData;
  72599. /**
  72600. * Instantiates a new procedural texture.
  72601. * 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.
  72602. * This is the base class of any Procedural texture and contains most of the shareable code.
  72603. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72604. * @param name Define the name of the texture
  72605. * @param size Define the size of the texture to create
  72606. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  72607. * @param scene Define the scene the texture belongs to
  72608. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  72609. * @param generateMipMaps Define if the texture should creates mip maps or not
  72610. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  72611. */
  72612. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  72613. /**
  72614. * The effect that is created when initializing the post process.
  72615. * @returns The created effect corrisponding the the postprocess.
  72616. */
  72617. getEffect(): Effect;
  72618. /**
  72619. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  72620. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  72621. */
  72622. getContent(): Nullable<ArrayBufferView>;
  72623. private _createIndexBuffer;
  72624. /** @hidden */
  72625. _rebuild(): void;
  72626. /**
  72627. * Resets the texture in order to recreate its associated resources.
  72628. * This can be called in case of context loss
  72629. */
  72630. reset(): void;
  72631. protected _getDefines(): string;
  72632. /**
  72633. * Is the texture ready to be used ? (rendered at least once)
  72634. * @returns true if ready, otherwise, false.
  72635. */
  72636. isReady(): boolean;
  72637. /**
  72638. * Resets the refresh counter of the texture and start bak from scratch.
  72639. * Could be useful to regenerate the texture if it is setup to render only once.
  72640. */
  72641. resetRefreshCounter(): void;
  72642. /**
  72643. * Set the fragment shader to use in order to render the texture.
  72644. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  72645. */
  72646. setFragment(fragment: any): void;
  72647. /**
  72648. * Define the refresh rate of the texture or the rendering frequency.
  72649. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  72650. */
  72651. refreshRate: number;
  72652. /** @hidden */
  72653. _shouldRender(): boolean;
  72654. /**
  72655. * Get the size the texture is rendering at.
  72656. * @returns the size (texture is always squared)
  72657. */
  72658. getRenderSize(): number;
  72659. /**
  72660. * Resize the texture to new value.
  72661. * @param size Define the new size the texture should have
  72662. * @param generateMipMaps Define whether the new texture should create mip maps
  72663. */
  72664. resize(size: number, generateMipMaps: boolean): void;
  72665. private _checkUniform;
  72666. /**
  72667. * Set a texture in the shader program used to render.
  72668. * @param name Define the name of the uniform samplers as defined in the shader
  72669. * @param texture Define the texture to bind to this sampler
  72670. * @return the texture itself allowing "fluent" like uniform updates
  72671. */
  72672. setTexture(name: string, texture: Texture): ProceduralTexture;
  72673. /**
  72674. * Set a float in the shader.
  72675. * @param name Define the name of the uniform as defined in the shader
  72676. * @param value Define the value to give to the uniform
  72677. * @return the texture itself allowing "fluent" like uniform updates
  72678. */
  72679. setFloat(name: string, value: number): ProceduralTexture;
  72680. /**
  72681. * Set a int in the shader.
  72682. * @param name Define the name of the uniform as defined in the shader
  72683. * @param value Define the value to give to the uniform
  72684. * @return the texture itself allowing "fluent" like uniform updates
  72685. */
  72686. setInt(name: string, value: number): ProceduralTexture;
  72687. /**
  72688. * Set an array of floats in the shader.
  72689. * @param name Define the name of the uniform as defined in the shader
  72690. * @param value Define the value to give to the uniform
  72691. * @return the texture itself allowing "fluent" like uniform updates
  72692. */
  72693. setFloats(name: string, value: number[]): ProceduralTexture;
  72694. /**
  72695. * Set a vec3 in the shader from a Color3.
  72696. * @param name Define the name of the uniform as defined in the shader
  72697. * @param value Define the value to give to the uniform
  72698. * @return the texture itself allowing "fluent" like uniform updates
  72699. */
  72700. setColor3(name: string, value: Color3): ProceduralTexture;
  72701. /**
  72702. * Set a vec4 in the shader from a Color4.
  72703. * @param name Define the name of the uniform as defined in the shader
  72704. * @param value Define the value to give to the uniform
  72705. * @return the texture itself allowing "fluent" like uniform updates
  72706. */
  72707. setColor4(name: string, value: Color4): ProceduralTexture;
  72708. /**
  72709. * Set a vec2 in the shader from a Vector2.
  72710. * @param name Define the name of the uniform as defined in the shader
  72711. * @param value Define the value to give to the uniform
  72712. * @return the texture itself allowing "fluent" like uniform updates
  72713. */
  72714. setVector2(name: string, value: Vector2): ProceduralTexture;
  72715. /**
  72716. * Set a vec3 in the shader from a Vector3.
  72717. * @param name Define the name of the uniform as defined in the shader
  72718. * @param value Define the value to give to the uniform
  72719. * @return the texture itself allowing "fluent" like uniform updates
  72720. */
  72721. setVector3(name: string, value: Vector3): ProceduralTexture;
  72722. /**
  72723. * Set a mat4 in the shader from a MAtrix.
  72724. * @param name Define the name of the uniform as defined in the shader
  72725. * @param value Define the value to give to the uniform
  72726. * @return the texture itself allowing "fluent" like uniform updates
  72727. */
  72728. setMatrix(name: string, value: Matrix): ProceduralTexture;
  72729. /**
  72730. * Render the texture to its associated render target.
  72731. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  72732. */
  72733. render(useCameraPostProcess?: boolean): void;
  72734. /**
  72735. * Clone the texture.
  72736. * @returns the cloned texture
  72737. */
  72738. clone(): ProceduralTexture;
  72739. /**
  72740. * Dispose the texture and release its asoociated resources.
  72741. */
  72742. dispose(): void;
  72743. }
  72744. }
  72745. declare module BABYLON {
  72746. /**
  72747. * This represents the base class for particle system in Babylon.
  72748. * 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.
  72749. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72750. * @example https://doc.babylonjs.com/babylon101/particles
  72751. */
  72752. export class BaseParticleSystem {
  72753. /**
  72754. * Source color is added to the destination color without alpha affecting the result
  72755. */
  72756. static BLENDMODE_ONEONE: number;
  72757. /**
  72758. * Blend current color and particle color using particle’s alpha
  72759. */
  72760. static BLENDMODE_STANDARD: number;
  72761. /**
  72762. * Add current color and particle color multiplied by particle’s alpha
  72763. */
  72764. static BLENDMODE_ADD: number;
  72765. /**
  72766. * Multiply current color with particle color
  72767. */
  72768. static BLENDMODE_MULTIPLY: number;
  72769. /**
  72770. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  72771. */
  72772. static BLENDMODE_MULTIPLYADD: number;
  72773. /**
  72774. * List of animations used by the particle system.
  72775. */
  72776. animations: Animation[];
  72777. /**
  72778. * The id of the Particle system.
  72779. */
  72780. id: string;
  72781. /**
  72782. * The friendly name of the Particle system.
  72783. */
  72784. name: string;
  72785. /**
  72786. * The rendering group used by the Particle system to chose when to render.
  72787. */
  72788. renderingGroupId: number;
  72789. /**
  72790. * The emitter represents the Mesh or position we are attaching the particle system to.
  72791. */
  72792. emitter: Nullable<AbstractMesh | Vector3>;
  72793. /**
  72794. * The maximum number of particles to emit per frame
  72795. */
  72796. emitRate: number;
  72797. /**
  72798. * If you want to launch only a few particles at once, that can be done, as well.
  72799. */
  72800. manualEmitCount: number;
  72801. /**
  72802. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72803. */
  72804. updateSpeed: number;
  72805. /**
  72806. * The amount of time the particle system is running (depends of the overall update speed).
  72807. */
  72808. targetStopDuration: number;
  72809. /**
  72810. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72811. */
  72812. disposeOnStop: boolean;
  72813. /**
  72814. * Minimum power of emitting particles.
  72815. */
  72816. minEmitPower: number;
  72817. /**
  72818. * Maximum power of emitting particles.
  72819. */
  72820. maxEmitPower: number;
  72821. /**
  72822. * Minimum life time of emitting particles.
  72823. */
  72824. minLifeTime: number;
  72825. /**
  72826. * Maximum life time of emitting particles.
  72827. */
  72828. maxLifeTime: number;
  72829. /**
  72830. * Minimum Size of emitting particles.
  72831. */
  72832. minSize: number;
  72833. /**
  72834. * Maximum Size of emitting particles.
  72835. */
  72836. maxSize: number;
  72837. /**
  72838. * Minimum scale of emitting particles on X axis.
  72839. */
  72840. minScaleX: number;
  72841. /**
  72842. * Maximum scale of emitting particles on X axis.
  72843. */
  72844. maxScaleX: number;
  72845. /**
  72846. * Minimum scale of emitting particles on Y axis.
  72847. */
  72848. minScaleY: number;
  72849. /**
  72850. * Maximum scale of emitting particles on Y axis.
  72851. */
  72852. maxScaleY: number;
  72853. /**
  72854. * Gets or sets the minimal initial rotation in radians.
  72855. */
  72856. minInitialRotation: number;
  72857. /**
  72858. * Gets or sets the maximal initial rotation in radians.
  72859. */
  72860. maxInitialRotation: number;
  72861. /**
  72862. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72863. */
  72864. minAngularSpeed: number;
  72865. /**
  72866. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72867. */
  72868. maxAngularSpeed: number;
  72869. /**
  72870. * The texture used to render each particle. (this can be a spritesheet)
  72871. */
  72872. particleTexture: Nullable<Texture>;
  72873. /**
  72874. * The layer mask we are rendering the particles through.
  72875. */
  72876. layerMask: number;
  72877. /**
  72878. * This can help using your own shader to render the particle system.
  72879. * The according effect will be created
  72880. */
  72881. customShader: any;
  72882. /**
  72883. * By default particle system starts as soon as they are created. This prevents the
  72884. * automatic start to happen and let you decide when to start emitting particles.
  72885. */
  72886. preventAutoStart: boolean;
  72887. private _noiseTexture;
  72888. /**
  72889. * Gets or sets a texture used to add random noise to particle positions
  72890. */
  72891. noiseTexture: Nullable<ProceduralTexture>;
  72892. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72893. noiseStrength: Vector3;
  72894. /**
  72895. * Callback triggered when the particle animation is ending.
  72896. */
  72897. onAnimationEnd: Nullable<() => void>;
  72898. /**
  72899. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  72900. */
  72901. blendMode: number;
  72902. /**
  72903. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72904. * to override the particles.
  72905. */
  72906. forceDepthWrite: boolean;
  72907. /** 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 */
  72908. preWarmCycles: number;
  72909. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  72910. preWarmStepOffset: number;
  72911. /**
  72912. * 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)
  72913. */
  72914. spriteCellChangeSpeed: number;
  72915. /**
  72916. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72917. */
  72918. startSpriteCellID: number;
  72919. /**
  72920. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72921. */
  72922. endSpriteCellID: number;
  72923. /**
  72924. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72925. */
  72926. spriteCellWidth: number;
  72927. /**
  72928. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72929. */
  72930. spriteCellHeight: number;
  72931. /**
  72932. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72933. */
  72934. spriteRandomStartCell: boolean;
  72935. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72936. translationPivot: Vector2;
  72937. /** @hidden */
  72938. protected _isAnimationSheetEnabled: boolean;
  72939. /**
  72940. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72941. */
  72942. beginAnimationOnStart: boolean;
  72943. /**
  72944. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72945. */
  72946. beginAnimationFrom: number;
  72947. /**
  72948. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72949. */
  72950. beginAnimationTo: number;
  72951. /**
  72952. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72953. */
  72954. beginAnimationLoop: boolean;
  72955. /**
  72956. * Gets or sets a world offset applied to all particles
  72957. */
  72958. worldOffset: Vector3;
  72959. /**
  72960. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  72961. */
  72962. isAnimationSheetEnabled: boolean;
  72963. /**
  72964. * Get hosting scene
  72965. * @returns the scene
  72966. */
  72967. getScene(): Scene;
  72968. /**
  72969. * You can use gravity if you want to give an orientation to your particles.
  72970. */
  72971. gravity: Vector3;
  72972. protected _colorGradients: Nullable<Array<ColorGradient>>;
  72973. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  72974. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  72975. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  72976. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  72977. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  72978. protected _dragGradients: Nullable<Array<FactorGradient>>;
  72979. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  72980. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  72981. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  72982. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  72983. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  72984. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  72985. /**
  72986. * Defines the delay in milliseconds before starting the system (0 by default)
  72987. */
  72988. startDelay: number;
  72989. /**
  72990. * Gets the current list of drag gradients.
  72991. * You must use addDragGradient and removeDragGradient to udpate this list
  72992. * @returns the list of drag gradients
  72993. */
  72994. getDragGradients(): Nullable<Array<FactorGradient>>;
  72995. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72996. limitVelocityDamping: number;
  72997. /**
  72998. * Gets the current list of limit velocity gradients.
  72999. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73000. * @returns the list of limit velocity gradients
  73001. */
  73002. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73003. /**
  73004. * Gets the current list of color gradients.
  73005. * You must use addColorGradient and removeColorGradient to udpate this list
  73006. * @returns the list of color gradients
  73007. */
  73008. getColorGradients(): Nullable<Array<ColorGradient>>;
  73009. /**
  73010. * Gets the current list of size gradients.
  73011. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73012. * @returns the list of size gradients
  73013. */
  73014. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73015. /**
  73016. * Gets the current list of color remap gradients.
  73017. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73018. * @returns the list of color remap gradients
  73019. */
  73020. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73021. /**
  73022. * Gets the current list of alpha remap gradients.
  73023. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73024. * @returns the list of alpha remap gradients
  73025. */
  73026. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73027. /**
  73028. * Gets the current list of life time gradients.
  73029. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73030. * @returns the list of life time gradients
  73031. */
  73032. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73033. /**
  73034. * Gets the current list of angular speed gradients.
  73035. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73036. * @returns the list of angular speed gradients
  73037. */
  73038. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73039. /**
  73040. * Gets the current list of velocity gradients.
  73041. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73042. * @returns the list of velocity gradients
  73043. */
  73044. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73045. /**
  73046. * Gets the current list of start size gradients.
  73047. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73048. * @returns the list of start size gradients
  73049. */
  73050. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73051. /**
  73052. * Gets the current list of emit rate gradients.
  73053. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73054. * @returns the list of emit rate gradients
  73055. */
  73056. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73057. /**
  73058. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73059. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73060. */
  73061. direction1: Vector3;
  73062. /**
  73063. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73064. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73065. */
  73066. direction2: Vector3;
  73067. /**
  73068. * 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.
  73069. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73070. */
  73071. minEmitBox: Vector3;
  73072. /**
  73073. * 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.
  73074. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73075. */
  73076. maxEmitBox: Vector3;
  73077. /**
  73078. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73079. */
  73080. color1: Color4;
  73081. /**
  73082. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73083. */
  73084. color2: Color4;
  73085. /**
  73086. * Color the particle will have at the end of its lifetime
  73087. */
  73088. colorDead: Color4;
  73089. /**
  73090. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73091. */
  73092. textureMask: Color4;
  73093. /**
  73094. * The particle emitter type defines the emitter used by the particle system.
  73095. * It can be for example box, sphere, or cone...
  73096. */
  73097. particleEmitterType: IParticleEmitterType;
  73098. /** @hidden */
  73099. _isSubEmitter: boolean;
  73100. /**
  73101. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73102. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73103. */
  73104. billboardMode: number;
  73105. protected _isBillboardBased: boolean;
  73106. /**
  73107. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73108. */
  73109. isBillboardBased: boolean;
  73110. /**
  73111. * The scene the particle system belongs to.
  73112. */
  73113. protected _scene: Scene;
  73114. /**
  73115. * Local cache of defines for image processing.
  73116. */
  73117. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73118. /**
  73119. * Default configuration related to image processing available in the standard Material.
  73120. */
  73121. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73122. /**
  73123. * Gets the image processing configuration used either in this material.
  73124. */
  73125. /**
  73126. * Sets the Default image processing configuration used either in the this material.
  73127. *
  73128. * If sets to null, the scene one is in use.
  73129. */
  73130. imageProcessingConfiguration: ImageProcessingConfiguration;
  73131. /**
  73132. * Attaches a new image processing configuration to the Standard Material.
  73133. * @param configuration
  73134. */
  73135. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73136. /** @hidden */
  73137. protected _reset(): void;
  73138. /** @hidden */
  73139. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73140. /**
  73141. * Instantiates a particle system.
  73142. * 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.
  73143. * @param name The name of the particle system
  73144. */
  73145. constructor(name: string);
  73146. /**
  73147. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73148. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73149. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73150. * @returns the emitter
  73151. */
  73152. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73153. /**
  73154. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73155. * @param radius The radius of the hemisphere to emit from
  73156. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73157. * @returns the emitter
  73158. */
  73159. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73160. /**
  73161. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73162. * @param radius The radius of the sphere to emit from
  73163. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73164. * @returns the emitter
  73165. */
  73166. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73167. /**
  73168. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73169. * @param radius The radius of the sphere to emit from
  73170. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73171. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73172. * @returns the emitter
  73173. */
  73174. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73175. /**
  73176. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73177. * @param radius The radius of the emission cylinder
  73178. * @param height The height of the emission cylinder
  73179. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73180. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73181. * @returns the emitter
  73182. */
  73183. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73184. /**
  73185. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73186. * @param radius The radius of the cylinder to emit from
  73187. * @param height The height of the emission cylinder
  73188. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73189. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73190. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73191. * @returns the emitter
  73192. */
  73193. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73194. /**
  73195. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73196. * @param radius The radius of the cone to emit from
  73197. * @param angle The base angle of the cone
  73198. * @returns the emitter
  73199. */
  73200. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73201. /**
  73202. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73203. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73204. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73205. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73206. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73207. * @returns the emitter
  73208. */
  73209. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73210. }
  73211. }
  73212. declare module BABYLON {
  73213. /**
  73214. * Type of sub emitter
  73215. */
  73216. export enum SubEmitterType {
  73217. /**
  73218. * Attached to the particle over it's lifetime
  73219. */
  73220. ATTACHED = 0,
  73221. /**
  73222. * Created when the particle dies
  73223. */
  73224. END = 1
  73225. }
  73226. /**
  73227. * Sub emitter class used to emit particles from an existing particle
  73228. */
  73229. export class SubEmitter {
  73230. /**
  73231. * the particle system to be used by the sub emitter
  73232. */
  73233. particleSystem: ParticleSystem;
  73234. /**
  73235. * Type of the submitter (Default: END)
  73236. */
  73237. type: SubEmitterType;
  73238. /**
  73239. * 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)
  73240. * Note: This only is supported when using an emitter of type Mesh
  73241. */
  73242. inheritDirection: boolean;
  73243. /**
  73244. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  73245. */
  73246. inheritedVelocityAmount: number;
  73247. /**
  73248. * Creates a sub emitter
  73249. * @param particleSystem the particle system to be used by the sub emitter
  73250. */
  73251. constructor(
  73252. /**
  73253. * the particle system to be used by the sub emitter
  73254. */
  73255. particleSystem: ParticleSystem);
  73256. /**
  73257. * Clones the sub emitter
  73258. * @returns the cloned sub emitter
  73259. */
  73260. clone(): SubEmitter;
  73261. /**
  73262. * Serialize current object to a JSON object
  73263. * @returns the serialized object
  73264. */
  73265. serialize(): any;
  73266. /** @hidden */
  73267. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  73268. /**
  73269. * Creates a new SubEmitter from a serialized JSON version
  73270. * @param serializationObject defines the JSON object to read from
  73271. * @param scene defines the hosting scene
  73272. * @param rootUrl defines the rootUrl for data loading
  73273. * @returns a new SubEmitter
  73274. */
  73275. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  73276. /** Release associated resources */
  73277. dispose(): void;
  73278. }
  73279. }
  73280. declare module BABYLON {
  73281. /** @hidden */
  73282. export var clipPlaneFragmentDeclaration: {
  73283. name: string;
  73284. shader: string;
  73285. };
  73286. }
  73287. declare module BABYLON {
  73288. /** @hidden */
  73289. export var imageProcessingDeclaration: {
  73290. name: string;
  73291. shader: string;
  73292. };
  73293. }
  73294. declare module BABYLON {
  73295. /** @hidden */
  73296. export var imageProcessingFunctions: {
  73297. name: string;
  73298. shader: string;
  73299. };
  73300. }
  73301. declare module BABYLON {
  73302. /** @hidden */
  73303. export var clipPlaneFragment: {
  73304. name: string;
  73305. shader: string;
  73306. };
  73307. }
  73308. declare module BABYLON {
  73309. /** @hidden */
  73310. export var particlesPixelShader: {
  73311. name: string;
  73312. shader: string;
  73313. };
  73314. }
  73315. declare module BABYLON {
  73316. /** @hidden */
  73317. export var clipPlaneVertexDeclaration: {
  73318. name: string;
  73319. shader: string;
  73320. };
  73321. }
  73322. declare module BABYLON {
  73323. /** @hidden */
  73324. export var clipPlaneVertex: {
  73325. name: string;
  73326. shader: string;
  73327. };
  73328. }
  73329. declare module BABYLON {
  73330. /** @hidden */
  73331. export var particlesVertexShader: {
  73332. name: string;
  73333. shader: string;
  73334. };
  73335. }
  73336. declare module BABYLON {
  73337. /**
  73338. * This represents a particle system in Babylon.
  73339. * 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.
  73340. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73341. * @example https://doc.babylonjs.com/babylon101/particles
  73342. */
  73343. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  73344. /**
  73345. * Billboard mode will only apply to Y axis
  73346. */
  73347. static readonly BILLBOARDMODE_Y: number;
  73348. /**
  73349. * Billboard mode will apply to all axes
  73350. */
  73351. static readonly BILLBOARDMODE_ALL: number;
  73352. /**
  73353. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73354. */
  73355. static readonly BILLBOARDMODE_STRETCHED: number;
  73356. /**
  73357. * This function can be defined to provide custom update for active particles.
  73358. * This function will be called instead of regular update (age, position, color, etc.).
  73359. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  73360. */
  73361. updateFunction: (particles: Particle[]) => void;
  73362. private _emitterWorldMatrix;
  73363. /**
  73364. * This function can be defined to specify initial direction for every new particle.
  73365. * It by default use the emitterType defined function
  73366. */
  73367. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  73368. /**
  73369. * This function can be defined to specify initial position for every new particle.
  73370. * It by default use the emitterType defined function
  73371. */
  73372. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  73373. /**
  73374. * @hidden
  73375. */
  73376. _inheritedVelocityOffset: Vector3;
  73377. /**
  73378. * An event triggered when the system is disposed
  73379. */
  73380. onDisposeObservable: Observable<ParticleSystem>;
  73381. private _onDisposeObserver;
  73382. /**
  73383. * Sets a callback that will be triggered when the system is disposed
  73384. */
  73385. onDispose: () => void;
  73386. private _particles;
  73387. private _epsilon;
  73388. private _capacity;
  73389. private _stockParticles;
  73390. private _newPartsExcess;
  73391. private _vertexData;
  73392. private _vertexBuffer;
  73393. private _vertexBuffers;
  73394. private _spriteBuffer;
  73395. private _indexBuffer;
  73396. private _effect;
  73397. private _customEffect;
  73398. private _cachedDefines;
  73399. private _scaledColorStep;
  73400. private _colorDiff;
  73401. private _scaledDirection;
  73402. private _scaledGravity;
  73403. private _currentRenderId;
  73404. private _alive;
  73405. private _useInstancing;
  73406. private _started;
  73407. private _stopped;
  73408. private _actualFrame;
  73409. private _scaledUpdateSpeed;
  73410. private _vertexBufferSize;
  73411. /** @hidden */
  73412. _currentEmitRateGradient: Nullable<FactorGradient>;
  73413. /** @hidden */
  73414. _currentEmitRate1: number;
  73415. /** @hidden */
  73416. _currentEmitRate2: number;
  73417. /** @hidden */
  73418. _currentStartSizeGradient: Nullable<FactorGradient>;
  73419. /** @hidden */
  73420. _currentStartSize1: number;
  73421. /** @hidden */
  73422. _currentStartSize2: number;
  73423. private readonly _rawTextureWidth;
  73424. private _rampGradientsTexture;
  73425. private _useRampGradients;
  73426. /** Gets or sets a boolean indicating that ramp gradients must be used
  73427. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73428. */
  73429. useRampGradients: boolean;
  73430. /**
  73431. * 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.
  73432. * 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: [])
  73433. */
  73434. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  73435. private _subEmitters;
  73436. /**
  73437. * @hidden
  73438. * If the particle systems emitter should be disposed when the particle system is disposed
  73439. */
  73440. _disposeEmitterOnDispose: boolean;
  73441. /**
  73442. * The current active Sub-systems, this property is used by the root particle system only.
  73443. */
  73444. activeSubSystems: Array<ParticleSystem>;
  73445. private _rootParticleSystem;
  73446. /**
  73447. * Gets the current list of active particles
  73448. */
  73449. readonly particles: Particle[];
  73450. /**
  73451. * Returns the string "ParticleSystem"
  73452. * @returns a string containing the class name
  73453. */
  73454. getClassName(): string;
  73455. /**
  73456. * Instantiates a particle system.
  73457. * 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.
  73458. * @param name The name of the particle system
  73459. * @param capacity The max number of particles alive at the same time
  73460. * @param scene The scene the particle system belongs to
  73461. * @param customEffect a custom effect used to change the way particles are rendered by default
  73462. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73463. * @param epsilon Offset used to render the particles
  73464. */
  73465. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  73466. private _addFactorGradient;
  73467. private _removeFactorGradient;
  73468. /**
  73469. * Adds a new life time gradient
  73470. * @param gradient defines the gradient to use (between 0 and 1)
  73471. * @param factor defines the life time factor to affect to the specified gradient
  73472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73473. * @returns the current particle system
  73474. */
  73475. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73476. /**
  73477. * Remove a specific life time gradient
  73478. * @param gradient defines the gradient to remove
  73479. * @returns the current particle system
  73480. */
  73481. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73482. /**
  73483. * Adds a new size gradient
  73484. * @param gradient defines the gradient to use (between 0 and 1)
  73485. * @param factor defines the size factor to affect to the specified gradient
  73486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73487. * @returns the current particle system
  73488. */
  73489. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73490. /**
  73491. * Remove a specific size gradient
  73492. * @param gradient defines the gradient to remove
  73493. * @returns the current particle system
  73494. */
  73495. removeSizeGradient(gradient: number): IParticleSystem;
  73496. /**
  73497. * Adds a new color remap gradient
  73498. * @param gradient defines the gradient to use (between 0 and 1)
  73499. * @param min defines the color remap minimal range
  73500. * @param max defines the color remap maximal range
  73501. * @returns the current particle system
  73502. */
  73503. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73504. /**
  73505. * Remove a specific color remap gradient
  73506. * @param gradient defines the gradient to remove
  73507. * @returns the current particle system
  73508. */
  73509. removeColorRemapGradient(gradient: number): IParticleSystem;
  73510. /**
  73511. * Adds a new alpha remap gradient
  73512. * @param gradient defines the gradient to use (between 0 and 1)
  73513. * @param min defines the alpha remap minimal range
  73514. * @param max defines the alpha remap maximal range
  73515. * @returns the current particle system
  73516. */
  73517. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73518. /**
  73519. * Remove a specific alpha remap gradient
  73520. * @param gradient defines the gradient to remove
  73521. * @returns the current particle system
  73522. */
  73523. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  73524. /**
  73525. * Adds a new angular speed gradient
  73526. * @param gradient defines the gradient to use (between 0 and 1)
  73527. * @param factor defines the angular speed to affect to the specified gradient
  73528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73529. * @returns the current particle system
  73530. */
  73531. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73532. /**
  73533. * Remove a specific angular speed gradient
  73534. * @param gradient defines the gradient to remove
  73535. * @returns the current particle system
  73536. */
  73537. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73538. /**
  73539. * Adds a new velocity gradient
  73540. * @param gradient defines the gradient to use (between 0 and 1)
  73541. * @param factor defines the velocity to affect to the specified gradient
  73542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73543. * @returns the current particle system
  73544. */
  73545. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73546. /**
  73547. * Remove a specific velocity gradient
  73548. * @param gradient defines the gradient to remove
  73549. * @returns the current particle system
  73550. */
  73551. removeVelocityGradient(gradient: number): IParticleSystem;
  73552. /**
  73553. * Adds a new limit velocity gradient
  73554. * @param gradient defines the gradient to use (between 0 and 1)
  73555. * @param factor defines the limit velocity value to affect to the specified gradient
  73556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73557. * @returns the current particle system
  73558. */
  73559. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73560. /**
  73561. * Remove a specific limit velocity gradient
  73562. * @param gradient defines the gradient to remove
  73563. * @returns the current particle system
  73564. */
  73565. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73566. /**
  73567. * Adds a new drag gradient
  73568. * @param gradient defines the gradient to use (between 0 and 1)
  73569. * @param factor defines the drag value to affect to the specified gradient
  73570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73571. * @returns the current particle system
  73572. */
  73573. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73574. /**
  73575. * Remove a specific drag gradient
  73576. * @param gradient defines the gradient to remove
  73577. * @returns the current particle system
  73578. */
  73579. removeDragGradient(gradient: number): IParticleSystem;
  73580. /**
  73581. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73582. * @param gradient defines the gradient to use (between 0 and 1)
  73583. * @param factor defines the emit rate value to affect to the specified gradient
  73584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73585. * @returns the current particle system
  73586. */
  73587. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73588. /**
  73589. * Remove a specific emit rate gradient
  73590. * @param gradient defines the gradient to remove
  73591. * @returns the current particle system
  73592. */
  73593. removeEmitRateGradient(gradient: number): IParticleSystem;
  73594. /**
  73595. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73596. * @param gradient defines the gradient to use (between 0 and 1)
  73597. * @param factor defines the start size value to affect to the specified gradient
  73598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73599. * @returns the current particle system
  73600. */
  73601. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73602. /**
  73603. * Remove a specific start size gradient
  73604. * @param gradient defines the gradient to remove
  73605. * @returns the current particle system
  73606. */
  73607. removeStartSizeGradient(gradient: number): IParticleSystem;
  73608. private _createRampGradientTexture;
  73609. /**
  73610. * Gets the current list of ramp gradients.
  73611. * You must use addRampGradient and removeRampGradient to udpate this list
  73612. * @returns the list of ramp gradients
  73613. */
  73614. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73615. /**
  73616. * Adds a new ramp gradient used to remap particle colors
  73617. * @param gradient defines the gradient to use (between 0 and 1)
  73618. * @param color defines the color to affect to the specified gradient
  73619. * @returns the current particle system
  73620. */
  73621. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  73622. /**
  73623. * Remove a specific ramp gradient
  73624. * @param gradient defines the gradient to remove
  73625. * @returns the current particle system
  73626. */
  73627. removeRampGradient(gradient: number): ParticleSystem;
  73628. /**
  73629. * Adds a new color gradient
  73630. * @param gradient defines the gradient to use (between 0 and 1)
  73631. * @param color1 defines the color to affect to the specified gradient
  73632. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73633. * @returns this particle system
  73634. */
  73635. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73636. /**
  73637. * Remove a specific color gradient
  73638. * @param gradient defines the gradient to remove
  73639. * @returns this particle system
  73640. */
  73641. removeColorGradient(gradient: number): IParticleSystem;
  73642. private _fetchR;
  73643. protected _reset(): void;
  73644. private _resetEffect;
  73645. private _createVertexBuffers;
  73646. private _createIndexBuffer;
  73647. /**
  73648. * Gets the maximum number of particles active at the same time.
  73649. * @returns The max number of active particles.
  73650. */
  73651. getCapacity(): number;
  73652. /**
  73653. * Gets whether there are still active particles in the system.
  73654. * @returns True if it is alive, otherwise false.
  73655. */
  73656. isAlive(): boolean;
  73657. /**
  73658. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73659. * @returns True if it has been started, otherwise false.
  73660. */
  73661. isStarted(): boolean;
  73662. private _prepareSubEmitterInternalArray;
  73663. /**
  73664. * Starts the particle system and begins to emit
  73665. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  73666. */
  73667. start(delay?: number): void;
  73668. /**
  73669. * Stops the particle system.
  73670. * @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.
  73671. */
  73672. stop(stopSubEmitters?: boolean): void;
  73673. /**
  73674. * Remove all active particles
  73675. */
  73676. reset(): void;
  73677. /**
  73678. * @hidden (for internal use only)
  73679. */
  73680. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  73681. /**
  73682. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  73683. * Its lifetime will start back at 0.
  73684. */
  73685. recycleParticle: (particle: Particle) => void;
  73686. private _stopSubEmitters;
  73687. private _createParticle;
  73688. private _removeFromRoot;
  73689. private _emitFromParticle;
  73690. private _update;
  73691. /** @hidden */
  73692. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  73693. /** @hidden */
  73694. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  73695. /** @hidden */
  73696. private _getEffect;
  73697. /**
  73698. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  73699. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  73700. */
  73701. animate(preWarmOnly?: boolean): void;
  73702. private _appendParticleVertices;
  73703. /**
  73704. * Rebuilds the particle system.
  73705. */
  73706. rebuild(): void;
  73707. /**
  73708. * Is this system ready to be used/rendered
  73709. * @return true if the system is ready
  73710. */
  73711. isReady(): boolean;
  73712. private _render;
  73713. /**
  73714. * Renders the particle system in its current state.
  73715. * @returns the current number of particles
  73716. */
  73717. render(): number;
  73718. /**
  73719. * Disposes the particle system and free the associated resources
  73720. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73721. */
  73722. dispose(disposeTexture?: boolean): void;
  73723. /**
  73724. * Clones the particle system.
  73725. * @param name The name of the cloned object
  73726. * @param newEmitter The new emitter to use
  73727. * @returns the cloned particle system
  73728. */
  73729. clone(name: string, newEmitter: any): ParticleSystem;
  73730. /**
  73731. * Serializes the particle system to a JSON object.
  73732. * @returns the JSON object
  73733. */
  73734. serialize(): any;
  73735. /** @hidden */
  73736. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  73737. /** @hidden */
  73738. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  73739. /**
  73740. * Parses a JSON object to create a particle system.
  73741. * @param parsedParticleSystem The JSON object to parse
  73742. * @param scene The scene to create the particle system in
  73743. * @param rootUrl The root url to use to load external dependencies like texture
  73744. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73745. * @returns the Parsed particle system
  73746. */
  73747. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  73748. }
  73749. }
  73750. declare module BABYLON {
  73751. /**
  73752. * A particle represents one of the element emitted by a particle system.
  73753. * This is mainly define by its coordinates, direction, velocity and age.
  73754. */
  73755. export class Particle {
  73756. /**
  73757. * The particle system the particle belongs to.
  73758. */
  73759. particleSystem: ParticleSystem;
  73760. private static _Count;
  73761. /**
  73762. * Unique ID of the particle
  73763. */
  73764. id: number;
  73765. /**
  73766. * The world position of the particle in the scene.
  73767. */
  73768. position: Vector3;
  73769. /**
  73770. * The world direction of the particle in the scene.
  73771. */
  73772. direction: Vector3;
  73773. /**
  73774. * The color of the particle.
  73775. */
  73776. color: Color4;
  73777. /**
  73778. * The color change of the particle per step.
  73779. */
  73780. colorStep: Color4;
  73781. /**
  73782. * Defines how long will the life of the particle be.
  73783. */
  73784. lifeTime: number;
  73785. /**
  73786. * The current age of the particle.
  73787. */
  73788. age: number;
  73789. /**
  73790. * The current size of the particle.
  73791. */
  73792. size: number;
  73793. /**
  73794. * The current scale of the particle.
  73795. */
  73796. scale: Vector2;
  73797. /**
  73798. * The current angle of the particle.
  73799. */
  73800. angle: number;
  73801. /**
  73802. * Defines how fast is the angle changing.
  73803. */
  73804. angularSpeed: number;
  73805. /**
  73806. * Defines the cell index used by the particle to be rendered from a sprite.
  73807. */
  73808. cellIndex: number;
  73809. /**
  73810. * The information required to support color remapping
  73811. */
  73812. remapData: Vector4;
  73813. /** @hidden */
  73814. _randomCellOffset?: number;
  73815. /** @hidden */
  73816. _initialDirection: Nullable<Vector3>;
  73817. /** @hidden */
  73818. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  73819. /** @hidden */
  73820. _initialStartSpriteCellID: number;
  73821. /** @hidden */
  73822. _initialEndSpriteCellID: number;
  73823. /** @hidden */
  73824. _currentColorGradient: Nullable<ColorGradient>;
  73825. /** @hidden */
  73826. _currentColor1: Color4;
  73827. /** @hidden */
  73828. _currentColor2: Color4;
  73829. /** @hidden */
  73830. _currentSizeGradient: Nullable<FactorGradient>;
  73831. /** @hidden */
  73832. _currentSize1: number;
  73833. /** @hidden */
  73834. _currentSize2: number;
  73835. /** @hidden */
  73836. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  73837. /** @hidden */
  73838. _currentAngularSpeed1: number;
  73839. /** @hidden */
  73840. _currentAngularSpeed2: number;
  73841. /** @hidden */
  73842. _currentVelocityGradient: Nullable<FactorGradient>;
  73843. /** @hidden */
  73844. _currentVelocity1: number;
  73845. /** @hidden */
  73846. _currentVelocity2: number;
  73847. /** @hidden */
  73848. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  73849. /** @hidden */
  73850. _currentLimitVelocity1: number;
  73851. /** @hidden */
  73852. _currentLimitVelocity2: number;
  73853. /** @hidden */
  73854. _currentDragGradient: Nullable<FactorGradient>;
  73855. /** @hidden */
  73856. _currentDrag1: number;
  73857. /** @hidden */
  73858. _currentDrag2: number;
  73859. /** @hidden */
  73860. _randomNoiseCoordinates1: Vector3;
  73861. /** @hidden */
  73862. _randomNoiseCoordinates2: Vector3;
  73863. /**
  73864. * Creates a new instance Particle
  73865. * @param particleSystem the particle system the particle belongs to
  73866. */
  73867. constructor(
  73868. /**
  73869. * The particle system the particle belongs to.
  73870. */
  73871. particleSystem: ParticleSystem);
  73872. private updateCellInfoFromSystem;
  73873. /**
  73874. * Defines how the sprite cell index is updated for the particle
  73875. */
  73876. updateCellIndex(): void;
  73877. /** @hidden */
  73878. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  73879. /** @hidden */
  73880. _inheritParticleInfoToSubEmitters(): void;
  73881. /** @hidden */
  73882. _reset(): void;
  73883. /**
  73884. * Copy the properties of particle to another one.
  73885. * @param other the particle to copy the information to.
  73886. */
  73887. copyTo(other: Particle): void;
  73888. }
  73889. }
  73890. declare module BABYLON {
  73891. /**
  73892. * Particle emitter represents a volume emitting particles.
  73893. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  73894. */
  73895. export interface IParticleEmitterType {
  73896. /**
  73897. * Called by the particle System when the direction is computed for the created particle.
  73898. * @param worldMatrix is the world matrix of the particle system
  73899. * @param directionToUpdate is the direction vector to update with the result
  73900. * @param particle is the particle we are computed the direction for
  73901. */
  73902. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73903. /**
  73904. * Called by the particle System when the position is computed for the created particle.
  73905. * @param worldMatrix is the world matrix of the particle system
  73906. * @param positionToUpdate is the position vector to update with the result
  73907. * @param particle is the particle we are computed the position for
  73908. */
  73909. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73910. /**
  73911. * Clones the current emitter and returns a copy of it
  73912. * @returns the new emitter
  73913. */
  73914. clone(): IParticleEmitterType;
  73915. /**
  73916. * Called by the GPUParticleSystem to setup the update shader
  73917. * @param effect defines the update shader
  73918. */
  73919. applyToShader(effect: Effect): void;
  73920. /**
  73921. * Returns a string to use to update the GPU particles update shader
  73922. * @returns the effect defines string
  73923. */
  73924. getEffectDefines(): string;
  73925. /**
  73926. * Returns a string representing the class name
  73927. * @returns a string containing the class name
  73928. */
  73929. getClassName(): string;
  73930. /**
  73931. * Serializes the particle system to a JSON object.
  73932. * @returns the JSON object
  73933. */
  73934. serialize(): any;
  73935. /**
  73936. * Parse properties from a JSON object
  73937. * @param serializationObject defines the JSON object
  73938. */
  73939. parse(serializationObject: any): void;
  73940. }
  73941. }
  73942. declare module BABYLON {
  73943. /**
  73944. * Particle emitter emitting particles from the inside of a box.
  73945. * It emits the particles randomly between 2 given directions.
  73946. */
  73947. export class BoxParticleEmitter implements IParticleEmitterType {
  73948. /**
  73949. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73950. */
  73951. direction1: Vector3;
  73952. /**
  73953. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73954. */
  73955. direction2: Vector3;
  73956. /**
  73957. * 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.
  73958. */
  73959. minEmitBox: Vector3;
  73960. /**
  73961. * 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.
  73962. */
  73963. maxEmitBox: Vector3;
  73964. /**
  73965. * Creates a new instance BoxParticleEmitter
  73966. */
  73967. constructor();
  73968. /**
  73969. * Called by the particle System when the direction is computed for the created particle.
  73970. * @param worldMatrix is the world matrix of the particle system
  73971. * @param directionToUpdate is the direction vector to update with the result
  73972. * @param particle is the particle we are computed the direction for
  73973. */
  73974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73975. /**
  73976. * Called by the particle System when the position is computed for the created particle.
  73977. * @param worldMatrix is the world matrix of the particle system
  73978. * @param positionToUpdate is the position vector to update with the result
  73979. * @param particle is the particle we are computed the position for
  73980. */
  73981. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73982. /**
  73983. * Clones the current emitter and returns a copy of it
  73984. * @returns the new emitter
  73985. */
  73986. clone(): BoxParticleEmitter;
  73987. /**
  73988. * Called by the GPUParticleSystem to setup the update shader
  73989. * @param effect defines the update shader
  73990. */
  73991. applyToShader(effect: Effect): void;
  73992. /**
  73993. * Returns a string to use to update the GPU particles update shader
  73994. * @returns a string containng the defines string
  73995. */
  73996. getEffectDefines(): string;
  73997. /**
  73998. * Returns the string "BoxParticleEmitter"
  73999. * @returns a string containing the class name
  74000. */
  74001. getClassName(): string;
  74002. /**
  74003. * Serializes the particle system to a JSON object.
  74004. * @returns the JSON object
  74005. */
  74006. serialize(): any;
  74007. /**
  74008. * Parse properties from a JSON object
  74009. * @param serializationObject defines the JSON object
  74010. */
  74011. parse(serializationObject: any): void;
  74012. }
  74013. }
  74014. declare module BABYLON {
  74015. /**
  74016. * Particle emitter emitting particles from the inside of a cone.
  74017. * It emits the particles alongside the cone volume from the base to the particle.
  74018. * The emission direction might be randomized.
  74019. */
  74020. export class ConeParticleEmitter implements IParticleEmitterType {
  74021. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74022. directionRandomizer: number;
  74023. private _radius;
  74024. private _angle;
  74025. private _height;
  74026. /**
  74027. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74028. */
  74029. radiusRange: number;
  74030. /**
  74031. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74032. */
  74033. heightRange: number;
  74034. /**
  74035. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74036. */
  74037. emitFromSpawnPointOnly: boolean;
  74038. /**
  74039. * Gets or sets the radius of the emission cone
  74040. */
  74041. radius: number;
  74042. /**
  74043. * Gets or sets the angle of the emission cone
  74044. */
  74045. angle: number;
  74046. private _buildHeight;
  74047. /**
  74048. * Creates a new instance ConeParticleEmitter
  74049. * @param radius the radius of the emission cone (1 by default)
  74050. * @param angle the cone base angle (PI by default)
  74051. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74052. */
  74053. constructor(radius?: number, angle?: number,
  74054. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74055. directionRandomizer?: number);
  74056. /**
  74057. * Called by the particle System when the direction is computed for the created particle.
  74058. * @param worldMatrix is the world matrix of the particle system
  74059. * @param directionToUpdate is the direction vector to update with the result
  74060. * @param particle is the particle we are computed the direction for
  74061. */
  74062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74063. /**
  74064. * Called by the particle System when the position is computed for the created particle.
  74065. * @param worldMatrix is the world matrix of the particle system
  74066. * @param positionToUpdate is the position vector to update with the result
  74067. * @param particle is the particle we are computed the position for
  74068. */
  74069. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74070. /**
  74071. * Clones the current emitter and returns a copy of it
  74072. * @returns the new emitter
  74073. */
  74074. clone(): ConeParticleEmitter;
  74075. /**
  74076. * Called by the GPUParticleSystem to setup the update shader
  74077. * @param effect defines the update shader
  74078. */
  74079. applyToShader(effect: Effect): void;
  74080. /**
  74081. * Returns a string to use to update the GPU particles update shader
  74082. * @returns a string containng the defines string
  74083. */
  74084. getEffectDefines(): string;
  74085. /**
  74086. * Returns the string "ConeParticleEmitter"
  74087. * @returns a string containing the class name
  74088. */
  74089. getClassName(): string;
  74090. /**
  74091. * Serializes the particle system to a JSON object.
  74092. * @returns the JSON object
  74093. */
  74094. serialize(): any;
  74095. /**
  74096. * Parse properties from a JSON object
  74097. * @param serializationObject defines the JSON object
  74098. */
  74099. parse(serializationObject: any): void;
  74100. }
  74101. }
  74102. declare module BABYLON {
  74103. /**
  74104. * Particle emitter emitting particles from the inside of a cylinder.
  74105. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74106. */
  74107. export class CylinderParticleEmitter implements IParticleEmitterType {
  74108. /**
  74109. * The radius of the emission cylinder.
  74110. */
  74111. radius: number;
  74112. /**
  74113. * The height of the emission cylinder.
  74114. */
  74115. height: number;
  74116. /**
  74117. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74118. */
  74119. radiusRange: number;
  74120. /**
  74121. * How much to randomize the particle direction [0-1].
  74122. */
  74123. directionRandomizer: number;
  74124. /**
  74125. * Creates a new instance CylinderParticleEmitter
  74126. * @param radius the radius of the emission cylinder (1 by default)
  74127. * @param height the height of the emission cylinder (1 by default)
  74128. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74129. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74130. */
  74131. constructor(
  74132. /**
  74133. * The radius of the emission cylinder.
  74134. */
  74135. radius?: number,
  74136. /**
  74137. * The height of the emission cylinder.
  74138. */
  74139. height?: number,
  74140. /**
  74141. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74142. */
  74143. radiusRange?: number,
  74144. /**
  74145. * How much to randomize the particle direction [0-1].
  74146. */
  74147. directionRandomizer?: number);
  74148. /**
  74149. * Called by the particle System when the direction is computed for the created particle.
  74150. * @param worldMatrix is the world matrix of the particle system
  74151. * @param directionToUpdate is the direction vector to update with the result
  74152. * @param particle is the particle we are computed the direction for
  74153. */
  74154. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74155. /**
  74156. * Called by the particle System when the position is computed for the created particle.
  74157. * @param worldMatrix is the world matrix of the particle system
  74158. * @param positionToUpdate is the position vector to update with the result
  74159. * @param particle is the particle we are computed the position for
  74160. */
  74161. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74162. /**
  74163. * Clones the current emitter and returns a copy of it
  74164. * @returns the new emitter
  74165. */
  74166. clone(): CylinderParticleEmitter;
  74167. /**
  74168. * Called by the GPUParticleSystem to setup the update shader
  74169. * @param effect defines the update shader
  74170. */
  74171. applyToShader(effect: Effect): void;
  74172. /**
  74173. * Returns a string to use to update the GPU particles update shader
  74174. * @returns a string containng the defines string
  74175. */
  74176. getEffectDefines(): string;
  74177. /**
  74178. * Returns the string "CylinderParticleEmitter"
  74179. * @returns a string containing the class name
  74180. */
  74181. getClassName(): string;
  74182. /**
  74183. * Serializes the particle system to a JSON object.
  74184. * @returns the JSON object
  74185. */
  74186. serialize(): any;
  74187. /**
  74188. * Parse properties from a JSON object
  74189. * @param serializationObject defines the JSON object
  74190. */
  74191. parse(serializationObject: any): void;
  74192. }
  74193. /**
  74194. * Particle emitter emitting particles from the inside of a cylinder.
  74195. * It emits the particles randomly between two vectors.
  74196. */
  74197. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74198. /**
  74199. * The min limit of the emission direction.
  74200. */
  74201. direction1: Vector3;
  74202. /**
  74203. * The max limit of the emission direction.
  74204. */
  74205. direction2: Vector3;
  74206. /**
  74207. * Creates a new instance CylinderDirectedParticleEmitter
  74208. * @param radius the radius of the emission cylinder (1 by default)
  74209. * @param height the height of the emission cylinder (1 by default)
  74210. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74211. * @param direction1 the min limit of the emission direction (up vector by default)
  74212. * @param direction2 the max limit of the emission direction (up vector by default)
  74213. */
  74214. constructor(radius?: number, height?: number, radiusRange?: number,
  74215. /**
  74216. * The min limit of the emission direction.
  74217. */
  74218. direction1?: Vector3,
  74219. /**
  74220. * The max limit of the emission direction.
  74221. */
  74222. direction2?: Vector3);
  74223. /**
  74224. * Called by the particle System when the direction is computed for the created particle.
  74225. * @param worldMatrix is the world matrix of the particle system
  74226. * @param directionToUpdate is the direction vector to update with the result
  74227. * @param particle is the particle we are computed the direction for
  74228. */
  74229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74230. /**
  74231. * Clones the current emitter and returns a copy of it
  74232. * @returns the new emitter
  74233. */
  74234. clone(): CylinderDirectedParticleEmitter;
  74235. /**
  74236. * Called by the GPUParticleSystem to setup the update shader
  74237. * @param effect defines the update shader
  74238. */
  74239. applyToShader(effect: Effect): void;
  74240. /**
  74241. * Returns a string to use to update the GPU particles update shader
  74242. * @returns a string containng the defines string
  74243. */
  74244. getEffectDefines(): string;
  74245. /**
  74246. * Returns the string "CylinderDirectedParticleEmitter"
  74247. * @returns a string containing the class name
  74248. */
  74249. getClassName(): string;
  74250. /**
  74251. * Serializes the particle system to a JSON object.
  74252. * @returns the JSON object
  74253. */
  74254. serialize(): any;
  74255. /**
  74256. * Parse properties from a JSON object
  74257. * @param serializationObject defines the JSON object
  74258. */
  74259. parse(serializationObject: any): void;
  74260. }
  74261. }
  74262. declare module BABYLON {
  74263. /**
  74264. * Particle emitter emitting particles from the inside of a hemisphere.
  74265. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  74266. */
  74267. export class HemisphericParticleEmitter implements IParticleEmitterType {
  74268. /**
  74269. * The radius of the emission hemisphere.
  74270. */
  74271. radius: number;
  74272. /**
  74273. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74274. */
  74275. radiusRange: number;
  74276. /**
  74277. * How much to randomize the particle direction [0-1].
  74278. */
  74279. directionRandomizer: number;
  74280. /**
  74281. * Creates a new instance HemisphericParticleEmitter
  74282. * @param radius the radius of the emission hemisphere (1 by default)
  74283. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74284. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74285. */
  74286. constructor(
  74287. /**
  74288. * The radius of the emission hemisphere.
  74289. */
  74290. radius?: number,
  74291. /**
  74292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74293. */
  74294. radiusRange?: number,
  74295. /**
  74296. * How much to randomize the particle direction [0-1].
  74297. */
  74298. directionRandomizer?: number);
  74299. /**
  74300. * Called by the particle System when the direction is computed for the created particle.
  74301. * @param worldMatrix is the world matrix of the particle system
  74302. * @param directionToUpdate is the direction vector to update with the result
  74303. * @param particle is the particle we are computed the direction for
  74304. */
  74305. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74306. /**
  74307. * Called by the particle System when the position is computed for the created particle.
  74308. * @param worldMatrix is the world matrix of the particle system
  74309. * @param positionToUpdate is the position vector to update with the result
  74310. * @param particle is the particle we are computed the position for
  74311. */
  74312. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74313. /**
  74314. * Clones the current emitter and returns a copy of it
  74315. * @returns the new emitter
  74316. */
  74317. clone(): HemisphericParticleEmitter;
  74318. /**
  74319. * Called by the GPUParticleSystem to setup the update shader
  74320. * @param effect defines the update shader
  74321. */
  74322. applyToShader(effect: Effect): void;
  74323. /**
  74324. * Returns a string to use to update the GPU particles update shader
  74325. * @returns a string containng the defines string
  74326. */
  74327. getEffectDefines(): string;
  74328. /**
  74329. * Returns the string "HemisphericParticleEmitter"
  74330. * @returns a string containing the class name
  74331. */
  74332. getClassName(): string;
  74333. /**
  74334. * Serializes the particle system to a JSON object.
  74335. * @returns the JSON object
  74336. */
  74337. serialize(): any;
  74338. /**
  74339. * Parse properties from a JSON object
  74340. * @param serializationObject defines the JSON object
  74341. */
  74342. parse(serializationObject: any): void;
  74343. }
  74344. }
  74345. declare module BABYLON {
  74346. /**
  74347. * Particle emitter emitting particles from a point.
  74348. * It emits the particles randomly between 2 given directions.
  74349. */
  74350. export class PointParticleEmitter implements IParticleEmitterType {
  74351. /**
  74352. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74353. */
  74354. direction1: Vector3;
  74355. /**
  74356. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74357. */
  74358. direction2: Vector3;
  74359. /**
  74360. * Creates a new instance PointParticleEmitter
  74361. */
  74362. constructor();
  74363. /**
  74364. * Called by the particle System when the direction is computed for the created particle.
  74365. * @param worldMatrix is the world matrix of the particle system
  74366. * @param directionToUpdate is the direction vector to update with the result
  74367. * @param particle is the particle we are computed the direction for
  74368. */
  74369. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74370. /**
  74371. * Called by the particle System when the position is computed for the created particle.
  74372. * @param worldMatrix is the world matrix of the particle system
  74373. * @param positionToUpdate is the position vector to update with the result
  74374. * @param particle is the particle we are computed the position for
  74375. */
  74376. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74377. /**
  74378. * Clones the current emitter and returns a copy of it
  74379. * @returns the new emitter
  74380. */
  74381. clone(): PointParticleEmitter;
  74382. /**
  74383. * Called by the GPUParticleSystem to setup the update shader
  74384. * @param effect defines the update shader
  74385. */
  74386. applyToShader(effect: Effect): void;
  74387. /**
  74388. * Returns a string to use to update the GPU particles update shader
  74389. * @returns a string containng the defines string
  74390. */
  74391. getEffectDefines(): string;
  74392. /**
  74393. * Returns the string "PointParticleEmitter"
  74394. * @returns a string containing the class name
  74395. */
  74396. getClassName(): string;
  74397. /**
  74398. * Serializes the particle system to a JSON object.
  74399. * @returns the JSON object
  74400. */
  74401. serialize(): any;
  74402. /**
  74403. * Parse properties from a JSON object
  74404. * @param serializationObject defines the JSON object
  74405. */
  74406. parse(serializationObject: any): void;
  74407. }
  74408. }
  74409. declare module BABYLON {
  74410. /**
  74411. * Particle emitter emitting particles from the inside of a sphere.
  74412. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  74413. */
  74414. export class SphereParticleEmitter implements IParticleEmitterType {
  74415. /**
  74416. * The radius of the emission sphere.
  74417. */
  74418. radius: number;
  74419. /**
  74420. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74421. */
  74422. radiusRange: number;
  74423. /**
  74424. * How much to randomize the particle direction [0-1].
  74425. */
  74426. directionRandomizer: number;
  74427. /**
  74428. * Creates a new instance SphereParticleEmitter
  74429. * @param radius the radius of the emission sphere (1 by default)
  74430. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74431. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74432. */
  74433. constructor(
  74434. /**
  74435. * The radius of the emission sphere.
  74436. */
  74437. radius?: number,
  74438. /**
  74439. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74440. */
  74441. radiusRange?: number,
  74442. /**
  74443. * How much to randomize the particle direction [0-1].
  74444. */
  74445. directionRandomizer?: number);
  74446. /**
  74447. * Called by the particle System when the direction is computed for the created particle.
  74448. * @param worldMatrix is the world matrix of the particle system
  74449. * @param directionToUpdate is the direction vector to update with the result
  74450. * @param particle is the particle we are computed the direction for
  74451. */
  74452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74453. /**
  74454. * Called by the particle System when the position is computed for the created particle.
  74455. * @param worldMatrix is the world matrix of the particle system
  74456. * @param positionToUpdate is the position vector to update with the result
  74457. * @param particle is the particle we are computed the position for
  74458. */
  74459. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74460. /**
  74461. * Clones the current emitter and returns a copy of it
  74462. * @returns the new emitter
  74463. */
  74464. clone(): SphereParticleEmitter;
  74465. /**
  74466. * Called by the GPUParticleSystem to setup the update shader
  74467. * @param effect defines the update shader
  74468. */
  74469. applyToShader(effect: Effect): void;
  74470. /**
  74471. * Returns a string to use to update the GPU particles update shader
  74472. * @returns a string containng the defines string
  74473. */
  74474. getEffectDefines(): string;
  74475. /**
  74476. * Returns the string "SphereParticleEmitter"
  74477. * @returns a string containing the class name
  74478. */
  74479. getClassName(): string;
  74480. /**
  74481. * Serializes the particle system to a JSON object.
  74482. * @returns the JSON object
  74483. */
  74484. serialize(): any;
  74485. /**
  74486. * Parse properties from a JSON object
  74487. * @param serializationObject defines the JSON object
  74488. */
  74489. parse(serializationObject: any): void;
  74490. }
  74491. /**
  74492. * Particle emitter emitting particles from the inside of a sphere.
  74493. * It emits the particles randomly between two vectors.
  74494. */
  74495. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  74496. /**
  74497. * The min limit of the emission direction.
  74498. */
  74499. direction1: Vector3;
  74500. /**
  74501. * The max limit of the emission direction.
  74502. */
  74503. direction2: Vector3;
  74504. /**
  74505. * Creates a new instance SphereDirectedParticleEmitter
  74506. * @param radius the radius of the emission sphere (1 by default)
  74507. * @param direction1 the min limit of the emission direction (up vector by default)
  74508. * @param direction2 the max limit of the emission direction (up vector by default)
  74509. */
  74510. constructor(radius?: number,
  74511. /**
  74512. * The min limit of the emission direction.
  74513. */
  74514. direction1?: Vector3,
  74515. /**
  74516. * The max limit of the emission direction.
  74517. */
  74518. direction2?: Vector3);
  74519. /**
  74520. * Called by the particle System when the direction is computed for the created particle.
  74521. * @param worldMatrix is the world matrix of the particle system
  74522. * @param directionToUpdate is the direction vector to update with the result
  74523. * @param particle is the particle we are computed the direction for
  74524. */
  74525. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74526. /**
  74527. * Clones the current emitter and returns a copy of it
  74528. * @returns the new emitter
  74529. */
  74530. clone(): SphereDirectedParticleEmitter;
  74531. /**
  74532. * Called by the GPUParticleSystem to setup the update shader
  74533. * @param effect defines the update shader
  74534. */
  74535. applyToShader(effect: Effect): void;
  74536. /**
  74537. * Returns a string to use to update the GPU particles update shader
  74538. * @returns a string containng the defines string
  74539. */
  74540. getEffectDefines(): string;
  74541. /**
  74542. * Returns the string "SphereDirectedParticleEmitter"
  74543. * @returns a string containing the class name
  74544. */
  74545. getClassName(): string;
  74546. /**
  74547. * Serializes the particle system to a JSON object.
  74548. * @returns the JSON object
  74549. */
  74550. serialize(): any;
  74551. /**
  74552. * Parse properties from a JSON object
  74553. * @param serializationObject defines the JSON object
  74554. */
  74555. parse(serializationObject: any): void;
  74556. }
  74557. }
  74558. declare module BABYLON {
  74559. /**
  74560. * Interface representing a particle system in Babylon.js.
  74561. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  74562. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  74563. */
  74564. export interface IParticleSystem {
  74565. /**
  74566. * List of animations used by the particle system.
  74567. */
  74568. animations: Animation[];
  74569. /**
  74570. * The id of the Particle system.
  74571. */
  74572. id: string;
  74573. /**
  74574. * The name of the Particle system.
  74575. */
  74576. name: string;
  74577. /**
  74578. * The emitter represents the Mesh or position we are attaching the particle system to.
  74579. */
  74580. emitter: Nullable<AbstractMesh | Vector3>;
  74581. /**
  74582. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74583. */
  74584. isBillboardBased: boolean;
  74585. /**
  74586. * The rendering group used by the Particle system to chose when to render.
  74587. */
  74588. renderingGroupId: number;
  74589. /**
  74590. * The layer mask we are rendering the particles through.
  74591. */
  74592. layerMask: number;
  74593. /**
  74594. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74595. */
  74596. updateSpeed: number;
  74597. /**
  74598. * The amount of time the particle system is running (depends of the overall update speed).
  74599. */
  74600. targetStopDuration: number;
  74601. /**
  74602. * The texture used to render each particle. (this can be a spritesheet)
  74603. */
  74604. particleTexture: Nullable<Texture>;
  74605. /**
  74606. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  74607. */
  74608. blendMode: number;
  74609. /**
  74610. * Minimum life time of emitting particles.
  74611. */
  74612. minLifeTime: number;
  74613. /**
  74614. * Maximum life time of emitting particles.
  74615. */
  74616. maxLifeTime: number;
  74617. /**
  74618. * Minimum Size of emitting particles.
  74619. */
  74620. minSize: number;
  74621. /**
  74622. * Maximum Size of emitting particles.
  74623. */
  74624. maxSize: number;
  74625. /**
  74626. * Minimum scale of emitting particles on X axis.
  74627. */
  74628. minScaleX: number;
  74629. /**
  74630. * Maximum scale of emitting particles on X axis.
  74631. */
  74632. maxScaleX: number;
  74633. /**
  74634. * Minimum scale of emitting particles on Y axis.
  74635. */
  74636. minScaleY: number;
  74637. /**
  74638. * Maximum scale of emitting particles on Y axis.
  74639. */
  74640. maxScaleY: number;
  74641. /**
  74642. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74643. */
  74644. color1: Color4;
  74645. /**
  74646. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74647. */
  74648. color2: Color4;
  74649. /**
  74650. * Color the particle will have at the end of its lifetime.
  74651. */
  74652. colorDead: Color4;
  74653. /**
  74654. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  74655. */
  74656. emitRate: number;
  74657. /**
  74658. * You can use gravity if you want to give an orientation to your particles.
  74659. */
  74660. gravity: Vector3;
  74661. /**
  74662. * Minimum power of emitting particles.
  74663. */
  74664. minEmitPower: number;
  74665. /**
  74666. * Maximum power of emitting particles.
  74667. */
  74668. maxEmitPower: number;
  74669. /**
  74670. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74671. */
  74672. minAngularSpeed: number;
  74673. /**
  74674. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74675. */
  74676. maxAngularSpeed: number;
  74677. /**
  74678. * Gets or sets the minimal initial rotation in radians.
  74679. */
  74680. minInitialRotation: number;
  74681. /**
  74682. * Gets or sets the maximal initial rotation in radians.
  74683. */
  74684. maxInitialRotation: number;
  74685. /**
  74686. * The particle emitter type defines the emitter used by the particle system.
  74687. * It can be for example box, sphere, or cone...
  74688. */
  74689. particleEmitterType: Nullable<IParticleEmitterType>;
  74690. /**
  74691. * Defines the delay in milliseconds before starting the system (0 by default)
  74692. */
  74693. startDelay: number;
  74694. /**
  74695. * 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
  74696. */
  74697. preWarmCycles: number;
  74698. /**
  74699. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  74700. */
  74701. preWarmStepOffset: number;
  74702. /**
  74703. * 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)
  74704. */
  74705. spriteCellChangeSpeed: number;
  74706. /**
  74707. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74708. */
  74709. startSpriteCellID: number;
  74710. /**
  74711. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74712. */
  74713. endSpriteCellID: number;
  74714. /**
  74715. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74716. */
  74717. spriteCellWidth: number;
  74718. /**
  74719. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74720. */
  74721. spriteCellHeight: number;
  74722. /**
  74723. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74724. */
  74725. spriteRandomStartCell: boolean;
  74726. /**
  74727. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  74728. */
  74729. isAnimationSheetEnabled: boolean;
  74730. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74731. translationPivot: Vector2;
  74732. /**
  74733. * Gets or sets a texture used to add random noise to particle positions
  74734. */
  74735. noiseTexture: Nullable<BaseTexture>;
  74736. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74737. noiseStrength: Vector3;
  74738. /**
  74739. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74740. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74741. */
  74742. billboardMode: number;
  74743. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74744. limitVelocityDamping: number;
  74745. /**
  74746. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74747. */
  74748. beginAnimationOnStart: boolean;
  74749. /**
  74750. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74751. */
  74752. beginAnimationFrom: number;
  74753. /**
  74754. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74755. */
  74756. beginAnimationTo: number;
  74757. /**
  74758. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74759. */
  74760. beginAnimationLoop: boolean;
  74761. /**
  74762. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74763. */
  74764. disposeOnStop: boolean;
  74765. /**
  74766. * Gets the maximum number of particles active at the same time.
  74767. * @returns The max number of active particles.
  74768. */
  74769. getCapacity(): number;
  74770. /**
  74771. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74772. * @returns True if it has been started, otherwise false.
  74773. */
  74774. isStarted(): boolean;
  74775. /**
  74776. * Animates the particle system for this frame.
  74777. */
  74778. animate(): void;
  74779. /**
  74780. * Renders the particle system in its current state.
  74781. * @returns the current number of particles
  74782. */
  74783. render(): number;
  74784. /**
  74785. * Dispose the particle system and frees its associated resources.
  74786. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74787. */
  74788. dispose(disposeTexture?: boolean): void;
  74789. /**
  74790. * Clones the particle system.
  74791. * @param name The name of the cloned object
  74792. * @param newEmitter The new emitter to use
  74793. * @returns the cloned particle system
  74794. */
  74795. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  74796. /**
  74797. * Serializes the particle system to a JSON object.
  74798. * @returns the JSON object
  74799. */
  74800. serialize(): any;
  74801. /**
  74802. * Rebuild the particle system
  74803. */
  74804. rebuild(): void;
  74805. /**
  74806. * Starts the particle system and begins to emit
  74807. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  74808. */
  74809. start(delay?: number): void;
  74810. /**
  74811. * Stops the particle system.
  74812. */
  74813. stop(): void;
  74814. /**
  74815. * Remove all active particles
  74816. */
  74817. reset(): void;
  74818. /**
  74819. * Is this system ready to be used/rendered
  74820. * @return true if the system is ready
  74821. */
  74822. isReady(): boolean;
  74823. /**
  74824. * Adds a new color gradient
  74825. * @param gradient defines the gradient to use (between 0 and 1)
  74826. * @param color1 defines the color to affect to the specified gradient
  74827. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74828. * @returns the current particle system
  74829. */
  74830. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74831. /**
  74832. * Remove a specific color gradient
  74833. * @param gradient defines the gradient to remove
  74834. * @returns the current particle system
  74835. */
  74836. removeColorGradient(gradient: number): IParticleSystem;
  74837. /**
  74838. * Adds a new size gradient
  74839. * @param gradient defines the gradient to use (between 0 and 1)
  74840. * @param factor defines the size factor to affect to the specified gradient
  74841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74842. * @returns the current particle system
  74843. */
  74844. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74845. /**
  74846. * Remove a specific size gradient
  74847. * @param gradient defines the gradient to remove
  74848. * @returns the current particle system
  74849. */
  74850. removeSizeGradient(gradient: number): IParticleSystem;
  74851. /**
  74852. * Gets the current list of color gradients.
  74853. * You must use addColorGradient and removeColorGradient to udpate this list
  74854. * @returns the list of color gradients
  74855. */
  74856. getColorGradients(): Nullable<Array<ColorGradient>>;
  74857. /**
  74858. * Gets the current list of size gradients.
  74859. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74860. * @returns the list of size gradients
  74861. */
  74862. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74863. /**
  74864. * Gets the current list of angular speed gradients.
  74865. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74866. * @returns the list of angular speed gradients
  74867. */
  74868. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74869. /**
  74870. * Adds a new angular speed gradient
  74871. * @param gradient defines the gradient to use (between 0 and 1)
  74872. * @param factor defines the angular speed to affect to the specified gradient
  74873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74874. * @returns the current particle system
  74875. */
  74876. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74877. /**
  74878. * Remove a specific angular speed gradient
  74879. * @param gradient defines the gradient to remove
  74880. * @returns the current particle system
  74881. */
  74882. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74883. /**
  74884. * Gets the current list of velocity gradients.
  74885. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74886. * @returns the list of velocity gradients
  74887. */
  74888. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74889. /**
  74890. * Adds a new velocity gradient
  74891. * @param gradient defines the gradient to use (between 0 and 1)
  74892. * @param factor defines the velocity to affect to the specified gradient
  74893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74894. * @returns the current particle system
  74895. */
  74896. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74897. /**
  74898. * Remove a specific velocity gradient
  74899. * @param gradient defines the gradient to remove
  74900. * @returns the current particle system
  74901. */
  74902. removeVelocityGradient(gradient: number): IParticleSystem;
  74903. /**
  74904. * Gets the current list of limit velocity gradients.
  74905. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74906. * @returns the list of limit velocity gradients
  74907. */
  74908. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74909. /**
  74910. * Adds a new limit velocity gradient
  74911. * @param gradient defines the gradient to use (between 0 and 1)
  74912. * @param factor defines the limit velocity to affect to the specified gradient
  74913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74914. * @returns the current particle system
  74915. */
  74916. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74917. /**
  74918. * Remove a specific limit velocity gradient
  74919. * @param gradient defines the gradient to remove
  74920. * @returns the current particle system
  74921. */
  74922. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74923. /**
  74924. * Adds a new drag gradient
  74925. * @param gradient defines the gradient to use (between 0 and 1)
  74926. * @param factor defines the drag to affect to the specified gradient
  74927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74928. * @returns the current particle system
  74929. */
  74930. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74931. /**
  74932. * Remove a specific drag gradient
  74933. * @param gradient defines the gradient to remove
  74934. * @returns the current particle system
  74935. */
  74936. removeDragGradient(gradient: number): IParticleSystem;
  74937. /**
  74938. * Gets the current list of drag gradients.
  74939. * You must use addDragGradient and removeDragGradient to udpate this list
  74940. * @returns the list of drag gradients
  74941. */
  74942. getDragGradients(): Nullable<Array<FactorGradient>>;
  74943. /**
  74944. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74945. * @param gradient defines the gradient to use (between 0 and 1)
  74946. * @param factor defines the emit rate to affect to the specified gradient
  74947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74948. * @returns the current particle system
  74949. */
  74950. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74951. /**
  74952. * Remove a specific emit rate gradient
  74953. * @param gradient defines the gradient to remove
  74954. * @returns the current particle system
  74955. */
  74956. removeEmitRateGradient(gradient: number): IParticleSystem;
  74957. /**
  74958. * Gets the current list of emit rate gradients.
  74959. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74960. * @returns the list of emit rate gradients
  74961. */
  74962. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74963. /**
  74964. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74965. * @param gradient defines the gradient to use (between 0 and 1)
  74966. * @param factor defines the start size to affect to the specified gradient
  74967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74968. * @returns the current particle system
  74969. */
  74970. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74971. /**
  74972. * Remove a specific start size gradient
  74973. * @param gradient defines the gradient to remove
  74974. * @returns the current particle system
  74975. */
  74976. removeStartSizeGradient(gradient: number): IParticleSystem;
  74977. /**
  74978. * Gets the current list of start size gradients.
  74979. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74980. * @returns the list of start size gradients
  74981. */
  74982. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74983. /**
  74984. * Adds a new life time gradient
  74985. * @param gradient defines the gradient to use (between 0 and 1)
  74986. * @param factor defines the life time factor to affect to the specified gradient
  74987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74988. * @returns the current particle system
  74989. */
  74990. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74991. /**
  74992. * Remove a specific life time gradient
  74993. * @param gradient defines the gradient to remove
  74994. * @returns the current particle system
  74995. */
  74996. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74997. /**
  74998. * Gets the current list of life time gradients.
  74999. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75000. * @returns the list of life time gradients
  75001. */
  75002. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75003. /**
  75004. * Gets the current list of color gradients.
  75005. * You must use addColorGradient and removeColorGradient to udpate this list
  75006. * @returns the list of color gradients
  75007. */
  75008. getColorGradients(): Nullable<Array<ColorGradient>>;
  75009. /**
  75010. * Adds a new ramp gradient used to remap particle colors
  75011. * @param gradient defines the gradient to use (between 0 and 1)
  75012. * @param color defines the color to affect to the specified gradient
  75013. * @returns the current particle system
  75014. */
  75015. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75016. /**
  75017. * Gets the current list of ramp gradients.
  75018. * You must use addRampGradient and removeRampGradient to udpate this list
  75019. * @returns the list of ramp gradients
  75020. */
  75021. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75022. /** Gets or sets a boolean indicating that ramp gradients must be used
  75023. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75024. */
  75025. useRampGradients: boolean;
  75026. /**
  75027. * Adds a new color remap gradient
  75028. * @param gradient defines the gradient to use (between 0 and 1)
  75029. * @param min defines the color remap minimal range
  75030. * @param max defines the color remap maximal range
  75031. * @returns the current particle system
  75032. */
  75033. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75034. /**
  75035. * Gets the current list of color remap gradients.
  75036. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75037. * @returns the list of color remap gradients
  75038. */
  75039. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75040. /**
  75041. * Adds a new alpha remap gradient
  75042. * @param gradient defines the gradient to use (between 0 and 1)
  75043. * @param min defines the alpha remap minimal range
  75044. * @param max defines the alpha remap maximal range
  75045. * @returns the current particle system
  75046. */
  75047. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75048. /**
  75049. * Gets the current list of alpha remap gradients.
  75050. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75051. * @returns the list of alpha remap gradients
  75052. */
  75053. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75054. /**
  75055. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75056. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75057. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75058. * @returns the emitter
  75059. */
  75060. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75061. /**
  75062. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75063. * @param radius The radius of the hemisphere to emit from
  75064. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75065. * @returns the emitter
  75066. */
  75067. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75068. /**
  75069. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75070. * @param radius The radius of the sphere to emit from
  75071. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75072. * @returns the emitter
  75073. */
  75074. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75075. /**
  75076. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75077. * @param radius The radius of the sphere to emit from
  75078. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75079. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75080. * @returns the emitter
  75081. */
  75082. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75083. /**
  75084. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75085. * @param radius The radius of the emission cylinder
  75086. * @param height The height of the emission cylinder
  75087. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75088. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75089. * @returns the emitter
  75090. */
  75091. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75092. /**
  75093. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75094. * @param radius The radius of the cylinder to emit from
  75095. * @param height The height of the emission cylinder
  75096. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75097. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75098. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75099. * @returns the emitter
  75100. */
  75101. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75102. /**
  75103. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75104. * @param radius The radius of the cone to emit from
  75105. * @param angle The base angle of the cone
  75106. * @returns the emitter
  75107. */
  75108. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75109. /**
  75110. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75111. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75112. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75113. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75114. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75115. * @returns the emitter
  75116. */
  75117. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75118. /**
  75119. * Get hosting scene
  75120. * @returns the scene
  75121. */
  75122. getScene(): Scene;
  75123. }
  75124. }
  75125. declare module BABYLON {
  75126. /**
  75127. * Creates an instance based on a source mesh.
  75128. */
  75129. export class InstancedMesh extends AbstractMesh {
  75130. private _sourceMesh;
  75131. private _currentLOD;
  75132. /** @hidden */
  75133. _indexInSourceMeshInstanceArray: number;
  75134. constructor(name: string, source: Mesh);
  75135. /**
  75136. * Returns the string "InstancedMesh".
  75137. */
  75138. getClassName(): string;
  75139. /**
  75140. * If the source mesh receives shadows
  75141. */
  75142. readonly receiveShadows: boolean;
  75143. /**
  75144. * The material of the source mesh
  75145. */
  75146. readonly material: Nullable<Material>;
  75147. /**
  75148. * Visibility of the source mesh
  75149. */
  75150. readonly visibility: number;
  75151. /**
  75152. * Skeleton of the source mesh
  75153. */
  75154. readonly skeleton: Nullable<Skeleton>;
  75155. /**
  75156. * Rendering ground id of the source mesh
  75157. */
  75158. renderingGroupId: number;
  75159. /**
  75160. * Returns the total number of vertices (integer).
  75161. */
  75162. getTotalVertices(): number;
  75163. /**
  75164. * Returns a positive integer : the total number of indices in this mesh geometry.
  75165. * @returns the numner of indices or zero if the mesh has no geometry.
  75166. */
  75167. getTotalIndices(): number;
  75168. /**
  75169. * The source mesh of the instance
  75170. */
  75171. readonly sourceMesh: Mesh;
  75172. /**
  75173. * Is this node ready to be used/rendered
  75174. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75175. * @return {boolean} is it ready
  75176. */
  75177. isReady(completeCheck?: boolean): boolean;
  75178. /**
  75179. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75180. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75181. * @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.
  75182. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75183. */
  75184. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75185. /**
  75186. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75187. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75188. * The `data` are either a numeric array either a Float32Array.
  75189. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75190. * 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).
  75191. * Note that a new underlying VertexBuffer object is created each call.
  75192. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75193. *
  75194. * Possible `kind` values :
  75195. * - VertexBuffer.PositionKind
  75196. * - VertexBuffer.UVKind
  75197. * - VertexBuffer.UV2Kind
  75198. * - VertexBuffer.UV3Kind
  75199. * - VertexBuffer.UV4Kind
  75200. * - VertexBuffer.UV5Kind
  75201. * - VertexBuffer.UV6Kind
  75202. * - VertexBuffer.ColorKind
  75203. * - VertexBuffer.MatricesIndicesKind
  75204. * - VertexBuffer.MatricesIndicesExtraKind
  75205. * - VertexBuffer.MatricesWeightsKind
  75206. * - VertexBuffer.MatricesWeightsExtraKind
  75207. *
  75208. * Returns the Mesh.
  75209. */
  75210. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75211. /**
  75212. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75213. * If the mesh has no geometry, it is simply returned as it is.
  75214. * The `data` are either a numeric array either a Float32Array.
  75215. * No new underlying VertexBuffer object is created.
  75216. * 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.
  75217. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75218. *
  75219. * Possible `kind` values :
  75220. * - VertexBuffer.PositionKind
  75221. * - VertexBuffer.UVKind
  75222. * - VertexBuffer.UV2Kind
  75223. * - VertexBuffer.UV3Kind
  75224. * - VertexBuffer.UV4Kind
  75225. * - VertexBuffer.UV5Kind
  75226. * - VertexBuffer.UV6Kind
  75227. * - VertexBuffer.ColorKind
  75228. * - VertexBuffer.MatricesIndicesKind
  75229. * - VertexBuffer.MatricesIndicesExtraKind
  75230. * - VertexBuffer.MatricesWeightsKind
  75231. * - VertexBuffer.MatricesWeightsExtraKind
  75232. *
  75233. * Returns the Mesh.
  75234. */
  75235. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75236. /**
  75237. * Sets the mesh indices.
  75238. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75239. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75240. * This method creates a new index buffer each call.
  75241. * Returns the Mesh.
  75242. */
  75243. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75244. /**
  75245. * Boolean : True if the mesh owns the requested kind of data.
  75246. */
  75247. isVerticesDataPresent(kind: string): boolean;
  75248. /**
  75249. * Returns an array of indices (IndicesArray).
  75250. */
  75251. getIndices(): Nullable<IndicesArray>;
  75252. readonly _positions: Nullable<Vector3[]>;
  75253. /**
  75254. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75255. * This means the mesh underlying bounding box and sphere are recomputed.
  75256. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75257. * @returns the current mesh
  75258. */
  75259. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75260. /** @hidden */
  75261. _preActivate(): InstancedMesh;
  75262. /** @hidden */
  75263. _activate(renderId: number): InstancedMesh;
  75264. /**
  75265. * Returns the current associated LOD AbstractMesh.
  75266. */
  75267. getLOD(camera: Camera): AbstractMesh;
  75268. /** @hidden */
  75269. _syncSubMeshes(): InstancedMesh;
  75270. /** @hidden */
  75271. _generatePointsArray(): boolean;
  75272. /**
  75273. * Creates a new InstancedMesh from the current mesh.
  75274. * - name (string) : the cloned mesh name
  75275. * - newParent (optional Node) : the optional Node to parent the clone to.
  75276. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75277. *
  75278. * Returns the clone.
  75279. */
  75280. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75281. /**
  75282. * Disposes the InstancedMesh.
  75283. * Returns nothing.
  75284. */
  75285. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75286. }
  75287. }
  75288. declare module BABYLON {
  75289. /**
  75290. * Defines the options associated with the creation of a shader material.
  75291. */
  75292. export interface IShaderMaterialOptions {
  75293. /**
  75294. * Does the material work in alpha blend mode
  75295. */
  75296. needAlphaBlending: boolean;
  75297. /**
  75298. * Does the material work in alpha test mode
  75299. */
  75300. needAlphaTesting: boolean;
  75301. /**
  75302. * The list of attribute names used in the shader
  75303. */
  75304. attributes: string[];
  75305. /**
  75306. * The list of unifrom names used in the shader
  75307. */
  75308. uniforms: string[];
  75309. /**
  75310. * The list of UBO names used in the shader
  75311. */
  75312. uniformBuffers: string[];
  75313. /**
  75314. * The list of sampler names used in the shader
  75315. */
  75316. samplers: string[];
  75317. /**
  75318. * The list of defines used in the shader
  75319. */
  75320. defines: string[];
  75321. }
  75322. /**
  75323. * 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.
  75324. *
  75325. * This returned material effects how the mesh will look based on the code in the shaders.
  75326. *
  75327. * @see http://doc.babylonjs.com/how_to/shader_material
  75328. */
  75329. export class ShaderMaterial extends Material {
  75330. private _shaderPath;
  75331. private _options;
  75332. private _textures;
  75333. private _textureArrays;
  75334. private _floats;
  75335. private _ints;
  75336. private _floatsArrays;
  75337. private _colors3;
  75338. private _colors3Arrays;
  75339. private _colors4;
  75340. private _vectors2;
  75341. private _vectors3;
  75342. private _vectors4;
  75343. private _matrices;
  75344. private _matrices3x3;
  75345. private _matrices2x2;
  75346. private _vectors2Arrays;
  75347. private _vectors3Arrays;
  75348. private _cachedWorldViewMatrix;
  75349. private _renderId;
  75350. /**
  75351. * Instantiate a new shader material.
  75352. * 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.
  75353. * This returned material effects how the mesh will look based on the code in the shaders.
  75354. * @see http://doc.babylonjs.com/how_to/shader_material
  75355. * @param name Define the name of the material in the scene
  75356. * @param scene Define the scene the material belongs to
  75357. * @param shaderPath Defines the route to the shader code in one of three ways:
  75358. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75359. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75360. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75361. * @param options Define the options used to create the shader
  75362. */
  75363. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75364. /**
  75365. * Gets the options used to compile the shader.
  75366. * They can be modified to trigger a new compilation
  75367. */
  75368. readonly options: IShaderMaterialOptions;
  75369. /**
  75370. * Gets the current class name of the material e.g. "ShaderMaterial"
  75371. * Mainly use in serialization.
  75372. * @returns the class name
  75373. */
  75374. getClassName(): string;
  75375. /**
  75376. * Specifies if the material will require alpha blending
  75377. * @returns a boolean specifying if alpha blending is needed
  75378. */
  75379. needAlphaBlending(): boolean;
  75380. /**
  75381. * Specifies if this material should be rendered in alpha test mode
  75382. * @returns a boolean specifying if an alpha test is needed.
  75383. */
  75384. needAlphaTesting(): boolean;
  75385. private _checkUniform;
  75386. /**
  75387. * Set a texture in the shader.
  75388. * @param name Define the name of the uniform samplers as defined in the shader
  75389. * @param texture Define the texture to bind to this sampler
  75390. * @return the material itself allowing "fluent" like uniform updates
  75391. */
  75392. setTexture(name: string, texture: Texture): ShaderMaterial;
  75393. /**
  75394. * Set a texture array in the shader.
  75395. * @param name Define the name of the uniform sampler array as defined in the shader
  75396. * @param textures Define the list of textures to bind to this sampler
  75397. * @return the material itself allowing "fluent" like uniform updates
  75398. */
  75399. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75400. /**
  75401. * Set a float in the shader.
  75402. * @param name Define the name of the uniform as defined in the shader
  75403. * @param value Define the value to give to the uniform
  75404. * @return the material itself allowing "fluent" like uniform updates
  75405. */
  75406. setFloat(name: string, value: number): ShaderMaterial;
  75407. /**
  75408. * Set a int in the shader.
  75409. * @param name Define the name of the uniform as defined in the shader
  75410. * @param value Define the value to give to the uniform
  75411. * @return the material itself allowing "fluent" like uniform updates
  75412. */
  75413. setInt(name: string, value: number): ShaderMaterial;
  75414. /**
  75415. * Set an array of floats in the shader.
  75416. * @param name Define the name of the uniform as defined in the shader
  75417. * @param value Define the value to give to the uniform
  75418. * @return the material itself allowing "fluent" like uniform updates
  75419. */
  75420. setFloats(name: string, value: number[]): ShaderMaterial;
  75421. /**
  75422. * Set a vec3 in the shader from a Color3.
  75423. * @param name Define the name of the uniform as defined in the shader
  75424. * @param value Define the value to give to the uniform
  75425. * @return the material itself allowing "fluent" like uniform updates
  75426. */
  75427. setColor3(name: string, value: Color3): ShaderMaterial;
  75428. /**
  75429. * Set a vec3 array in the shader from a Color3 array.
  75430. * @param name Define the name of the uniform as defined in the shader
  75431. * @param value Define the value to give to the uniform
  75432. * @return the material itself allowing "fluent" like uniform updates
  75433. */
  75434. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75435. /**
  75436. * Set a vec4 in the shader from a Color4.
  75437. * @param name Define the name of the uniform as defined in the shader
  75438. * @param value Define the value to give to the uniform
  75439. * @return the material itself allowing "fluent" like uniform updates
  75440. */
  75441. setColor4(name: string, value: Color4): ShaderMaterial;
  75442. /**
  75443. * Set a vec2 in the shader from a Vector2.
  75444. * @param name Define the name of the uniform as defined in the shader
  75445. * @param value Define the value to give to the uniform
  75446. * @return the material itself allowing "fluent" like uniform updates
  75447. */
  75448. setVector2(name: string, value: Vector2): ShaderMaterial;
  75449. /**
  75450. * Set a vec3 in the shader from a Vector3.
  75451. * @param name Define the name of the uniform as defined in the shader
  75452. * @param value Define the value to give to the uniform
  75453. * @return the material itself allowing "fluent" like uniform updates
  75454. */
  75455. setVector3(name: string, value: Vector3): ShaderMaterial;
  75456. /**
  75457. * Set a vec4 in the shader from a Vector4.
  75458. * @param name Define the name of the uniform as defined in the shader
  75459. * @param value Define the value to give to the uniform
  75460. * @return the material itself allowing "fluent" like uniform updates
  75461. */
  75462. setVector4(name: string, value: Vector4): ShaderMaterial;
  75463. /**
  75464. * Set a mat4 in the shader from a Matrix.
  75465. * @param name Define the name of the uniform as defined in the shader
  75466. * @param value Define the value to give to the uniform
  75467. * @return the material itself allowing "fluent" like uniform updates
  75468. */
  75469. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75470. /**
  75471. * Set a mat3 in the shader from a Float32Array.
  75472. * @param name Define the name of the uniform as defined in the shader
  75473. * @param value Define the value to give to the uniform
  75474. * @return the material itself allowing "fluent" like uniform updates
  75475. */
  75476. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75477. /**
  75478. * Set a mat2 in the shader from a Float32Array.
  75479. * @param name Define the name of the uniform as defined in the shader
  75480. * @param value Define the value to give to the uniform
  75481. * @return the material itself allowing "fluent" like uniform updates
  75482. */
  75483. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75484. /**
  75485. * Set a vec2 array in the shader from a number array.
  75486. * @param name Define the name of the uniform as defined in the shader
  75487. * @param value Define the value to give to the uniform
  75488. * @return the material itself allowing "fluent" like uniform updates
  75489. */
  75490. setArray2(name: string, value: number[]): ShaderMaterial;
  75491. /**
  75492. * Set a vec3 array in the shader from a number array.
  75493. * @param name Define the name of the uniform as defined in the shader
  75494. * @param value Define the value to give to the uniform
  75495. * @return the material itself allowing "fluent" like uniform updates
  75496. */
  75497. setArray3(name: string, value: number[]): ShaderMaterial;
  75498. private _checkCache;
  75499. /**
  75500. * Specifies that the submesh is ready to be used
  75501. * @param mesh defines the mesh to check
  75502. * @param subMesh defines which submesh to check
  75503. * @param useInstances specifies that instances should be used
  75504. * @returns a boolean indicating that the submesh is ready or not
  75505. */
  75506. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75507. /**
  75508. * Checks if the material is ready to render the requested mesh
  75509. * @param mesh Define the mesh to render
  75510. * @param useInstances Define whether or not the material is used with instances
  75511. * @returns true if ready, otherwise false
  75512. */
  75513. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75514. /**
  75515. * Binds the world matrix to the material
  75516. * @param world defines the world transformation matrix
  75517. */
  75518. bindOnlyWorldMatrix(world: Matrix): void;
  75519. /**
  75520. * Binds the material to the mesh
  75521. * @param world defines the world transformation matrix
  75522. * @param mesh defines the mesh to bind the material to
  75523. */
  75524. bind(world: Matrix, mesh?: Mesh): void;
  75525. /**
  75526. * Gets the active textures from the material
  75527. * @returns an array of textures
  75528. */
  75529. getActiveTextures(): BaseTexture[];
  75530. /**
  75531. * Specifies if the material uses a texture
  75532. * @param texture defines the texture to check against the material
  75533. * @returns a boolean specifying if the material uses the texture
  75534. */
  75535. hasTexture(texture: BaseTexture): boolean;
  75536. /**
  75537. * Makes a duplicate of the material, and gives it a new name
  75538. * @param name defines the new name for the duplicated material
  75539. * @returns the cloned material
  75540. */
  75541. clone(name: string): ShaderMaterial;
  75542. /**
  75543. * Disposes the material
  75544. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75545. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75546. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75547. */
  75548. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75549. /**
  75550. * Serializes this material in a JSON representation
  75551. * @returns the serialized material object
  75552. */
  75553. serialize(): any;
  75554. /**
  75555. * Creates a shader material from parsed shader material data
  75556. * @param source defines the JSON represnetation of the material
  75557. * @param scene defines the hosting scene
  75558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75559. * @returns a new material
  75560. */
  75561. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75562. }
  75563. }
  75564. declare module BABYLON {
  75565. /** @hidden */
  75566. export var colorPixelShader: {
  75567. name: string;
  75568. shader: string;
  75569. };
  75570. }
  75571. declare module BABYLON {
  75572. /** @hidden */
  75573. export var colorVertexShader: {
  75574. name: string;
  75575. shader: string;
  75576. };
  75577. }
  75578. declare module BABYLON {
  75579. /**
  75580. * Line mesh
  75581. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75582. */
  75583. export class LinesMesh extends Mesh {
  75584. /**
  75585. * If vertex color should be applied to the mesh
  75586. */
  75587. useVertexColor?: boolean | undefined;
  75588. /**
  75589. * If vertex alpha should be applied to the mesh
  75590. */
  75591. useVertexAlpha?: boolean | undefined;
  75592. /**
  75593. * Color of the line (Default: White)
  75594. */
  75595. color: Color3;
  75596. /**
  75597. * Alpha of the line (Default: 1)
  75598. */
  75599. alpha: number;
  75600. /**
  75601. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75602. * This margin is expressed in world space coordinates, so its value may vary.
  75603. * Default value is 0.1
  75604. */
  75605. intersectionThreshold: number;
  75606. private _colorShader;
  75607. /**
  75608. * Creates a new LinesMesh
  75609. * @param name defines the name
  75610. * @param scene defines the hosting scene
  75611. * @param parent defines the parent mesh if any
  75612. * @param source defines the optional source LinesMesh used to clone data from
  75613. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75614. * When false, achieved by calling a clone(), also passing False.
  75615. * This will make creation of children, recursive.
  75616. * @param useVertexColor defines if this LinesMesh supports vertex color
  75617. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75618. */
  75619. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75620. /**
  75621. * If vertex color should be applied to the mesh
  75622. */
  75623. useVertexColor?: boolean | undefined,
  75624. /**
  75625. * If vertex alpha should be applied to the mesh
  75626. */
  75627. useVertexAlpha?: boolean | undefined);
  75628. private _addClipPlaneDefine;
  75629. private _removeClipPlaneDefine;
  75630. isReady(): boolean;
  75631. /**
  75632. * Returns the string "LineMesh"
  75633. */
  75634. getClassName(): string;
  75635. /**
  75636. * @hidden
  75637. */
  75638. /**
  75639. * @hidden
  75640. */
  75641. material: Material;
  75642. /**
  75643. * @hidden
  75644. */
  75645. readonly checkCollisions: boolean;
  75646. /** @hidden */
  75647. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75648. /** @hidden */
  75649. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75650. /**
  75651. * Disposes of the line mesh
  75652. * @param doNotRecurse If children should be disposed
  75653. */
  75654. dispose(doNotRecurse?: boolean): void;
  75655. /**
  75656. * Returns a new LineMesh object cloned from the current one.
  75657. */
  75658. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75659. /**
  75660. * Creates a new InstancedLinesMesh object from the mesh model.
  75661. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75662. * @param name defines the name of the new instance
  75663. * @returns a new InstancedLinesMesh
  75664. */
  75665. createInstance(name: string): InstancedLinesMesh;
  75666. }
  75667. /**
  75668. * Creates an instance based on a source LinesMesh
  75669. */
  75670. export class InstancedLinesMesh extends InstancedMesh {
  75671. /**
  75672. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75673. * This margin is expressed in world space coordinates, so its value may vary.
  75674. * Initilized with the intersectionThreshold value of the source LinesMesh
  75675. */
  75676. intersectionThreshold: number;
  75677. constructor(name: string, source: LinesMesh);
  75678. /**
  75679. * Returns the string "InstancedLinesMesh".
  75680. */
  75681. getClassName(): string;
  75682. }
  75683. }
  75684. declare module BABYLON {
  75685. /** @hidden */
  75686. export var linePixelShader: {
  75687. name: string;
  75688. shader: string;
  75689. };
  75690. }
  75691. declare module BABYLON {
  75692. /** @hidden */
  75693. export var lineVertexShader: {
  75694. name: string;
  75695. shader: string;
  75696. };
  75697. }
  75698. declare module BABYLON {
  75699. interface AbstractMesh {
  75700. /**
  75701. * Disables the mesh edge rendering mode
  75702. * @returns the currentAbstractMesh
  75703. */
  75704. disableEdgesRendering(): AbstractMesh;
  75705. /**
  75706. * Enables the edge rendering mode on the mesh.
  75707. * This mode makes the mesh edges visible
  75708. * @param epsilon defines the maximal distance between two angles to detect a face
  75709. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75710. * @returns the currentAbstractMesh
  75711. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75712. */
  75713. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75714. /**
  75715. * Gets the edgesRenderer associated with the mesh
  75716. */
  75717. edgesRenderer: Nullable<EdgesRenderer>;
  75718. }
  75719. interface LinesMesh {
  75720. /**
  75721. * Enables the edge rendering mode on the mesh.
  75722. * This mode makes the mesh edges visible
  75723. * @param epsilon defines the maximal distance between two angles to detect a face
  75724. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75725. * @returns the currentAbstractMesh
  75726. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75727. */
  75728. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75729. }
  75730. interface InstancedLinesMesh {
  75731. /**
  75732. * Enables the edge rendering mode on the mesh.
  75733. * This mode makes the mesh edges visible
  75734. * @param epsilon defines the maximal distance between two angles to detect a face
  75735. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75736. * @returns the current InstancedLinesMesh
  75737. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75738. */
  75739. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  75740. }
  75741. /**
  75742. * Defines the minimum contract an Edges renderer should follow.
  75743. */
  75744. export interface IEdgesRenderer extends IDisposable {
  75745. /**
  75746. * Gets or sets a boolean indicating if the edgesRenderer is active
  75747. */
  75748. isEnabled: boolean;
  75749. /**
  75750. * Renders the edges of the attached mesh,
  75751. */
  75752. render(): void;
  75753. /**
  75754. * Checks wether or not the edges renderer is ready to render.
  75755. * @return true if ready, otherwise false.
  75756. */
  75757. isReady(): boolean;
  75758. }
  75759. /**
  75760. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  75761. */
  75762. export class EdgesRenderer implements IEdgesRenderer {
  75763. /**
  75764. * Define the size of the edges with an orthographic camera
  75765. */
  75766. edgesWidthScalerForOrthographic: number;
  75767. /**
  75768. * Define the size of the edges with a perspective camera
  75769. */
  75770. edgesWidthScalerForPerspective: number;
  75771. protected _source: AbstractMesh;
  75772. protected _linesPositions: number[];
  75773. protected _linesNormals: number[];
  75774. protected _linesIndices: number[];
  75775. protected _epsilon: number;
  75776. protected _indicesCount: number;
  75777. protected _lineShader: ShaderMaterial;
  75778. protected _ib: WebGLBuffer;
  75779. protected _buffers: {
  75780. [key: string]: Nullable<VertexBuffer>;
  75781. };
  75782. protected _checkVerticesInsteadOfIndices: boolean;
  75783. private _meshRebuildObserver;
  75784. private _meshDisposeObserver;
  75785. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  75786. isEnabled: boolean;
  75787. /**
  75788. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  75789. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  75790. * @param source Mesh used to create edges
  75791. * @param epsilon sum of angles in adjacency to check for edge
  75792. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  75793. * @param generateEdgesLines - should generate Lines or only prepare resources.
  75794. */
  75795. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  75796. protected _prepareRessources(): void;
  75797. /** @hidden */
  75798. _rebuild(): void;
  75799. /**
  75800. * Releases the required resources for the edges renderer
  75801. */
  75802. dispose(): void;
  75803. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  75804. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  75805. /**
  75806. * Checks if the pair of p0 and p1 is en edge
  75807. * @param faceIndex
  75808. * @param edge
  75809. * @param faceNormals
  75810. * @param p0
  75811. * @param p1
  75812. * @private
  75813. */
  75814. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  75815. /**
  75816. * push line into the position, normal and index buffer
  75817. * @protected
  75818. */
  75819. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  75820. /**
  75821. * Generates lines edges from adjacencjes
  75822. * @private
  75823. */
  75824. _generateEdgesLines(): void;
  75825. /**
  75826. * Checks wether or not the edges renderer is ready to render.
  75827. * @return true if ready, otherwise false.
  75828. */
  75829. isReady(): boolean;
  75830. /**
  75831. * Renders the edges of the attached mesh,
  75832. */
  75833. render(): void;
  75834. }
  75835. /**
  75836. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  75837. */
  75838. export class LineEdgesRenderer extends EdgesRenderer {
  75839. /**
  75840. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  75841. * @param source LineMesh used to generate edges
  75842. * @param epsilon not important (specified angle for edge detection)
  75843. * @param checkVerticesInsteadOfIndices not important for LineMesh
  75844. */
  75845. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  75846. /**
  75847. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  75848. */
  75849. _generateEdgesLines(): void;
  75850. }
  75851. }
  75852. declare module BABYLON {
  75853. /**
  75854. * This represents the object necessary to create a rendering group.
  75855. * This is exclusively used and created by the rendering manager.
  75856. * To modify the behavior, you use the available helpers in your scene or meshes.
  75857. * @hidden
  75858. */
  75859. export class RenderingGroup {
  75860. index: number;
  75861. private _scene;
  75862. private _opaqueSubMeshes;
  75863. private _transparentSubMeshes;
  75864. private _alphaTestSubMeshes;
  75865. private _depthOnlySubMeshes;
  75866. private _particleSystems;
  75867. private _spriteManagers;
  75868. private _opaqueSortCompareFn;
  75869. private _alphaTestSortCompareFn;
  75870. private _transparentSortCompareFn;
  75871. private _renderOpaque;
  75872. private _renderAlphaTest;
  75873. private _renderTransparent;
  75874. private _edgesRenderers;
  75875. onBeforeTransparentRendering: () => void;
  75876. /**
  75877. * Set the opaque sort comparison function.
  75878. * If null the sub meshes will be render in the order they were created
  75879. */
  75880. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75881. /**
  75882. * Set the alpha test sort comparison function.
  75883. * If null the sub meshes will be render in the order they were created
  75884. */
  75885. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75886. /**
  75887. * Set the transparent sort comparison function.
  75888. * If null the sub meshes will be render in the order they were created
  75889. */
  75890. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75891. /**
  75892. * Creates a new rendering group.
  75893. * @param index The rendering group index
  75894. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  75895. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  75896. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  75897. */
  75898. 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>);
  75899. /**
  75900. * Render all the sub meshes contained in the group.
  75901. * @param customRenderFunction Used to override the default render behaviour of the group.
  75902. * @returns true if rendered some submeshes.
  75903. */
  75904. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  75905. /**
  75906. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  75907. * @param subMeshes The submeshes to render
  75908. */
  75909. private renderOpaqueSorted;
  75910. /**
  75911. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  75912. * @param subMeshes The submeshes to render
  75913. */
  75914. private renderAlphaTestSorted;
  75915. /**
  75916. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  75917. * @param subMeshes The submeshes to render
  75918. */
  75919. private renderTransparentSorted;
  75920. /**
  75921. * Renders the submeshes in a specified order.
  75922. * @param subMeshes The submeshes to sort before render
  75923. * @param sortCompareFn The comparison function use to sort
  75924. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  75925. * @param transparent Specifies to activate blending if true
  75926. */
  75927. private static renderSorted;
  75928. /**
  75929. * Renders the submeshes in the order they were dispatched (no sort applied).
  75930. * @param subMeshes The submeshes to render
  75931. */
  75932. private static renderUnsorted;
  75933. /**
  75934. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75935. * are rendered back to front if in the same alpha index.
  75936. *
  75937. * @param a The first submesh
  75938. * @param b The second submesh
  75939. * @returns The result of the comparison
  75940. */
  75941. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  75942. /**
  75943. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75944. * are rendered back to front.
  75945. *
  75946. * @param a The first submesh
  75947. * @param b The second submesh
  75948. * @returns The result of the comparison
  75949. */
  75950. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  75951. /**
  75952. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75953. * are rendered front to back (prevent overdraw).
  75954. *
  75955. * @param a The first submesh
  75956. * @param b The second submesh
  75957. * @returns The result of the comparison
  75958. */
  75959. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  75960. /**
  75961. * Resets the different lists of submeshes to prepare a new frame.
  75962. */
  75963. prepare(): void;
  75964. dispose(): void;
  75965. /**
  75966. * Inserts the submesh in its correct queue depending on its material.
  75967. * @param subMesh The submesh to dispatch
  75968. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75969. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75970. */
  75971. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75972. dispatchSprites(spriteManager: ISpriteManager): void;
  75973. dispatchParticles(particleSystem: IParticleSystem): void;
  75974. private _renderParticles;
  75975. private _renderSprites;
  75976. }
  75977. }
  75978. declare module BABYLON {
  75979. /**
  75980. * Interface describing the different options available in the rendering manager
  75981. * regarding Auto Clear between groups.
  75982. */
  75983. export interface IRenderingManagerAutoClearSetup {
  75984. /**
  75985. * Defines whether or not autoclear is enable.
  75986. */
  75987. autoClear: boolean;
  75988. /**
  75989. * Defines whether or not to autoclear the depth buffer.
  75990. */
  75991. depth: boolean;
  75992. /**
  75993. * Defines whether or not to autoclear the stencil buffer.
  75994. */
  75995. stencil: boolean;
  75996. }
  75997. /**
  75998. * This class is used by the onRenderingGroupObservable
  75999. */
  76000. export class RenderingGroupInfo {
  76001. /**
  76002. * The Scene that being rendered
  76003. */
  76004. scene: Scene;
  76005. /**
  76006. * The camera currently used for the rendering pass
  76007. */
  76008. camera: Nullable<Camera>;
  76009. /**
  76010. * The ID of the renderingGroup being processed
  76011. */
  76012. renderingGroupId: number;
  76013. }
  76014. /**
  76015. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76016. * It is enable to manage the different groups as well as the different necessary sort functions.
  76017. * This should not be used directly aside of the few static configurations
  76018. */
  76019. export class RenderingManager {
  76020. /**
  76021. * The max id used for rendering groups (not included)
  76022. */
  76023. static MAX_RENDERINGGROUPS: number;
  76024. /**
  76025. * The min id used for rendering groups (included)
  76026. */
  76027. static MIN_RENDERINGGROUPS: number;
  76028. /**
  76029. * Used to globally prevent autoclearing scenes.
  76030. */
  76031. static AUTOCLEAR: boolean;
  76032. /**
  76033. * @hidden
  76034. */
  76035. _useSceneAutoClearSetup: boolean;
  76036. private _scene;
  76037. private _renderingGroups;
  76038. private _depthStencilBufferAlreadyCleaned;
  76039. private _autoClearDepthStencil;
  76040. private _customOpaqueSortCompareFn;
  76041. private _customAlphaTestSortCompareFn;
  76042. private _customTransparentSortCompareFn;
  76043. private _renderingGroupInfo;
  76044. /**
  76045. * Instantiates a new rendering group for a particular scene
  76046. * @param scene Defines the scene the groups belongs to
  76047. */
  76048. constructor(scene: Scene);
  76049. private _clearDepthStencilBuffer;
  76050. /**
  76051. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76052. * @hidden
  76053. */
  76054. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76055. /**
  76056. * Resets the different information of the group to prepare a new frame
  76057. * @hidden
  76058. */
  76059. reset(): void;
  76060. /**
  76061. * Dispose and release the group and its associated resources.
  76062. * @hidden
  76063. */
  76064. dispose(): void;
  76065. /**
  76066. * Clear the info related to rendering groups preventing retention points during dispose.
  76067. */
  76068. freeRenderingGroups(): void;
  76069. private _prepareRenderingGroup;
  76070. /**
  76071. * Add a sprite manager to the rendering manager in order to render it this frame.
  76072. * @param spriteManager Define the sprite manager to render
  76073. */
  76074. dispatchSprites(spriteManager: ISpriteManager): void;
  76075. /**
  76076. * Add a particle system to the rendering manager in order to render it this frame.
  76077. * @param particleSystem Define the particle system to render
  76078. */
  76079. dispatchParticles(particleSystem: IParticleSystem): void;
  76080. /**
  76081. * Add a submesh to the manager in order to render it this frame
  76082. * @param subMesh The submesh to dispatch
  76083. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76084. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76085. */
  76086. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76087. /**
  76088. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76089. * This allowed control for front to back rendering or reversly depending of the special needs.
  76090. *
  76091. * @param renderingGroupId The rendering group id corresponding to its index
  76092. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76093. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76094. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76095. */
  76096. 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;
  76097. /**
  76098. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76099. *
  76100. * @param renderingGroupId The rendering group id corresponding to its index
  76101. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76102. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76103. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76104. */
  76105. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76106. /**
  76107. * Gets the current auto clear configuration for one rendering group of the rendering
  76108. * manager.
  76109. * @param index the rendering group index to get the information for
  76110. * @returns The auto clear setup for the requested rendering group
  76111. */
  76112. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76113. }
  76114. }
  76115. declare module BABYLON {
  76116. /**
  76117. * This Helps creating a texture that will be created from a camera in your scene.
  76118. * It is basically a dynamic texture that could be used to create special effects for instance.
  76119. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76120. */
  76121. export class RenderTargetTexture extends Texture {
  76122. isCube: boolean;
  76123. /**
  76124. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76125. */
  76126. static readonly REFRESHRATE_RENDER_ONCE: number;
  76127. /**
  76128. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76129. */
  76130. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76131. /**
  76132. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76133. * the central point of your effect and can save a lot of performances.
  76134. */
  76135. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76136. /**
  76137. * Use this predicate to dynamically define the list of mesh you want to render.
  76138. * If set, the renderList property will be overwritten.
  76139. */
  76140. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76141. private _renderList;
  76142. /**
  76143. * Use this list to define the list of mesh you want to render.
  76144. */
  76145. renderList: Nullable<Array<AbstractMesh>>;
  76146. private _hookArray;
  76147. /**
  76148. * Define if particles should be rendered in your texture.
  76149. */
  76150. renderParticles: boolean;
  76151. /**
  76152. * Define if sprites should be rendered in your texture.
  76153. */
  76154. renderSprites: boolean;
  76155. /**
  76156. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76157. */
  76158. coordinatesMode: number;
  76159. /**
  76160. * Define the camera used to render the texture.
  76161. */
  76162. activeCamera: Nullable<Camera>;
  76163. /**
  76164. * Override the render function of the texture with your own one.
  76165. */
  76166. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76167. /**
  76168. * Define if camera post processes should be use while rendering the texture.
  76169. */
  76170. useCameraPostProcesses: boolean;
  76171. /**
  76172. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76173. */
  76174. ignoreCameraViewport: boolean;
  76175. private _postProcessManager;
  76176. private _postProcesses;
  76177. private _resizeObserver;
  76178. /**
  76179. * An event triggered when the texture is unbind.
  76180. */
  76181. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76182. /**
  76183. * An event triggered when the texture is unbind.
  76184. */
  76185. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76186. private _onAfterUnbindObserver;
  76187. /**
  76188. * Set a after unbind callback in the texture.
  76189. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76190. */
  76191. onAfterUnbind: () => void;
  76192. /**
  76193. * An event triggered before rendering the texture
  76194. */
  76195. onBeforeRenderObservable: Observable<number>;
  76196. private _onBeforeRenderObserver;
  76197. /**
  76198. * Set a before render callback in the texture.
  76199. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76200. */
  76201. onBeforeRender: (faceIndex: number) => void;
  76202. /**
  76203. * An event triggered after rendering the texture
  76204. */
  76205. onAfterRenderObservable: Observable<number>;
  76206. private _onAfterRenderObserver;
  76207. /**
  76208. * Set a after render callback in the texture.
  76209. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76210. */
  76211. onAfterRender: (faceIndex: number) => void;
  76212. /**
  76213. * An event triggered after the texture clear
  76214. */
  76215. onClearObservable: Observable<Engine>;
  76216. private _onClearObserver;
  76217. /**
  76218. * Set a clear callback in the texture.
  76219. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76220. */
  76221. onClear: (Engine: Engine) => void;
  76222. /**
  76223. * Define the clear color of the Render Target if it should be different from the scene.
  76224. */
  76225. clearColor: Color4;
  76226. protected _size: number | {
  76227. width: number;
  76228. height: number;
  76229. };
  76230. protected _initialSizeParameter: number | {
  76231. width: number;
  76232. height: number;
  76233. } | {
  76234. ratio: number;
  76235. };
  76236. protected _sizeRatio: Nullable<number>;
  76237. /** @hidden */
  76238. _generateMipMaps: boolean;
  76239. protected _renderingManager: RenderingManager;
  76240. /** @hidden */
  76241. _waitingRenderList: string[];
  76242. protected _doNotChangeAspectRatio: boolean;
  76243. protected _currentRefreshId: number;
  76244. protected _refreshRate: number;
  76245. protected _textureMatrix: Matrix;
  76246. protected _samples: number;
  76247. protected _renderTargetOptions: RenderTargetCreationOptions;
  76248. /**
  76249. * Gets render target creation options that were used.
  76250. */
  76251. readonly renderTargetOptions: RenderTargetCreationOptions;
  76252. protected _engine: Engine;
  76253. protected _onRatioRescale(): void;
  76254. /**
  76255. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  76256. * It must define where the camera used to render the texture is set
  76257. */
  76258. boundingBoxPosition: Vector3;
  76259. private _boundingBoxSize;
  76260. /**
  76261. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  76262. * When defined, the cubemap will switch to local mode
  76263. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76264. * @example https://www.babylonjs-playground.com/#RNASML
  76265. */
  76266. boundingBoxSize: Vector3;
  76267. /**
  76268. * In case the RTT has been created with a depth texture, get the associated
  76269. * depth texture.
  76270. * Otherwise, return null.
  76271. */
  76272. depthStencilTexture: Nullable<InternalTexture>;
  76273. /**
  76274. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  76275. * or used a shadow, depth texture...
  76276. * @param name The friendly name of the texture
  76277. * @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)
  76278. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  76279. * @param generateMipMaps True if mip maps need to be generated after render.
  76280. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  76281. * @param type The type of the buffer in the RTT (int, half float, float...)
  76282. * @param isCube True if a cube texture needs to be created
  76283. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  76284. * @param generateDepthBuffer True to generate a depth buffer
  76285. * @param generateStencilBuffer True to generate a stencil buffer
  76286. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  76287. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  76288. * @param delayAllocation if the texture allocation should be delayed (default: false)
  76289. */
  76290. constructor(name: string, size: number | {
  76291. width: number;
  76292. height: number;
  76293. } | {
  76294. ratio: number;
  76295. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  76296. /**
  76297. * Creates a depth stencil texture.
  76298. * This is only available in WebGL 2 or with the depth texture extension available.
  76299. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  76300. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  76301. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  76302. */
  76303. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  76304. private _processSizeParameter;
  76305. /**
  76306. * Define the number of samples to use in case of MSAA.
  76307. * It defaults to one meaning no MSAA has been enabled.
  76308. */
  76309. samples: number;
  76310. /**
  76311. * Resets the refresh counter of the texture and start bak from scratch.
  76312. * Could be useful to regenerate the texture if it is setup to render only once.
  76313. */
  76314. resetRefreshCounter(): void;
  76315. /**
  76316. * Define the refresh rate of the texture or the rendering frequency.
  76317. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76318. */
  76319. refreshRate: number;
  76320. /**
  76321. * Adds a post process to the render target rendering passes.
  76322. * @param postProcess define the post process to add
  76323. */
  76324. addPostProcess(postProcess: PostProcess): void;
  76325. /**
  76326. * Clear all the post processes attached to the render target
  76327. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  76328. */
  76329. clearPostProcesses(dispose?: boolean): void;
  76330. /**
  76331. * Remove one of the post process from the list of attached post processes to the texture
  76332. * @param postProcess define the post process to remove from the list
  76333. */
  76334. removePostProcess(postProcess: PostProcess): void;
  76335. /** @hidden */
  76336. _shouldRender(): boolean;
  76337. /**
  76338. * Gets the actual render size of the texture.
  76339. * @returns the width of the render size
  76340. */
  76341. getRenderSize(): number;
  76342. /**
  76343. * Gets the actual render width of the texture.
  76344. * @returns the width of the render size
  76345. */
  76346. getRenderWidth(): number;
  76347. /**
  76348. * Gets the actual render height of the texture.
  76349. * @returns the height of the render size
  76350. */
  76351. getRenderHeight(): number;
  76352. /**
  76353. * Get if the texture can be rescaled or not.
  76354. */
  76355. readonly canRescale: boolean;
  76356. /**
  76357. * Resize the texture using a ratio.
  76358. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  76359. */
  76360. scale(ratio: number): void;
  76361. /**
  76362. * Get the texture reflection matrix used to rotate/transform the reflection.
  76363. * @returns the reflection matrix
  76364. */
  76365. getReflectionTextureMatrix(): Matrix;
  76366. /**
  76367. * Resize the texture to a new desired size.
  76368. * Be carrefull as it will recreate all the data in the new texture.
  76369. * @param size Define the new size. It can be:
  76370. * - a number for squared texture,
  76371. * - an object containing { width: number, height: number }
  76372. * - or an object containing a ratio { ratio: number }
  76373. */
  76374. resize(size: number | {
  76375. width: number;
  76376. height: number;
  76377. } | {
  76378. ratio: number;
  76379. }): void;
  76380. /**
  76381. * Renders all the objects from the render list into the texture.
  76382. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  76383. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  76384. */
  76385. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  76386. private _bestReflectionRenderTargetDimension;
  76387. /**
  76388. * @hidden
  76389. * @param faceIndex face index to bind to if this is a cubetexture
  76390. */
  76391. _bindFrameBuffer(faceIndex?: number): void;
  76392. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  76393. private renderToTarget;
  76394. /**
  76395. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76396. * This allowed control for front to back rendering or reversly depending of the special needs.
  76397. *
  76398. * @param renderingGroupId The rendering group id corresponding to its index
  76399. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76400. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76401. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76402. */
  76403. 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;
  76404. /**
  76405. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76406. *
  76407. * @param renderingGroupId The rendering group id corresponding to its index
  76408. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76409. */
  76410. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  76411. /**
  76412. * Clones the texture.
  76413. * @returns the cloned texture
  76414. */
  76415. clone(): RenderTargetTexture;
  76416. /**
  76417. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76418. * @returns The JSON representation of the texture
  76419. */
  76420. serialize(): any;
  76421. /**
  76422. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  76423. */
  76424. disposeFramebufferObjects(): void;
  76425. /**
  76426. * Dispose the texture and release its associated resources.
  76427. */
  76428. dispose(): void;
  76429. /** @hidden */
  76430. _rebuild(): void;
  76431. /**
  76432. * Clear the info related to rendering groups preventing retention point in material dispose.
  76433. */
  76434. freeRenderingGroups(): void;
  76435. /**
  76436. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  76437. * @returns the view count
  76438. */
  76439. getViewCount(): number;
  76440. }
  76441. /**
  76442. * Renders to multiple views with a single draw call
  76443. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  76444. */
  76445. export class MultiviewRenderTarget extends RenderTargetTexture {
  76446. /**
  76447. * Creates a multiview render target
  76448. * @param scene scene used with the render target
  76449. * @param size the size of the render target (used for each view)
  76450. */
  76451. constructor(scene: Scene, size?: number | {
  76452. width: number;
  76453. height: number;
  76454. } | {
  76455. ratio: number;
  76456. });
  76457. /**
  76458. * @hidden
  76459. * @param faceIndex the face index, if its a cube texture
  76460. */
  76461. _bindFrameBuffer(faceIndex?: number): void;
  76462. /**
  76463. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  76464. * @returns the view count
  76465. */
  76466. getViewCount(): number;
  76467. }
  76468. }
  76469. declare module BABYLON {
  76470. /**
  76471. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76472. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76473. * You can then easily use it as a reflectionTexture on a flat surface.
  76474. * In case the surface is not a plane, please consider relying on reflection probes.
  76475. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76476. */
  76477. export class MirrorTexture extends RenderTargetTexture {
  76478. private scene;
  76479. /**
  76480. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  76481. * 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.
  76482. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76483. */
  76484. mirrorPlane: Plane;
  76485. /**
  76486. * Define the blur ratio used to blur the reflection if needed.
  76487. */
  76488. blurRatio: number;
  76489. /**
  76490. * Define the adaptive blur kernel used to blur the reflection if needed.
  76491. * This will autocompute the closest best match for the `blurKernel`
  76492. */
  76493. adaptiveBlurKernel: number;
  76494. /**
  76495. * Define the blur kernel used to blur the reflection if needed.
  76496. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76497. */
  76498. blurKernel: number;
  76499. /**
  76500. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  76501. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76502. */
  76503. blurKernelX: number;
  76504. /**
  76505. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  76506. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76507. */
  76508. blurKernelY: number;
  76509. private _autoComputeBlurKernel;
  76510. protected _onRatioRescale(): void;
  76511. private _updateGammaSpace;
  76512. private _imageProcessingConfigChangeObserver;
  76513. private _transformMatrix;
  76514. private _mirrorMatrix;
  76515. private _savedViewMatrix;
  76516. private _blurX;
  76517. private _blurY;
  76518. private _adaptiveBlurKernel;
  76519. private _blurKernelX;
  76520. private _blurKernelY;
  76521. private _blurRatio;
  76522. /**
  76523. * Instantiates a Mirror Texture.
  76524. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76525. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76526. * You can then easily use it as a reflectionTexture on a flat surface.
  76527. * In case the surface is not a plane, please consider relying on reflection probes.
  76528. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76529. * @param name
  76530. * @param size
  76531. * @param scene
  76532. * @param generateMipMaps
  76533. * @param type
  76534. * @param samplingMode
  76535. * @param generateDepthBuffer
  76536. */
  76537. constructor(name: string, size: number | {
  76538. width: number;
  76539. height: number;
  76540. } | {
  76541. ratio: number;
  76542. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  76543. private _preparePostProcesses;
  76544. /**
  76545. * Clone the mirror texture.
  76546. * @returns the cloned texture
  76547. */
  76548. clone(): MirrorTexture;
  76549. /**
  76550. * Serialize the texture to a JSON representation you could use in Parse later on
  76551. * @returns the serialized JSON representation
  76552. */
  76553. serialize(): any;
  76554. /**
  76555. * Dispose the texture and release its associated resources.
  76556. */
  76557. dispose(): void;
  76558. }
  76559. }
  76560. declare module BABYLON {
  76561. /**
  76562. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76563. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76564. */
  76565. export class Texture extends BaseTexture {
  76566. /** @hidden */
  76567. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  76568. /** @hidden */
  76569. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  76570. /** @hidden */
  76571. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  76572. /** nearest is mag = nearest and min = nearest and mip = linear */
  76573. static readonly NEAREST_SAMPLINGMODE: number;
  76574. /** nearest is mag = nearest and min = nearest and mip = linear */
  76575. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  76576. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76577. static readonly BILINEAR_SAMPLINGMODE: number;
  76578. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76579. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  76580. /** Trilinear is mag = linear and min = linear and mip = linear */
  76581. static readonly TRILINEAR_SAMPLINGMODE: number;
  76582. /** Trilinear is mag = linear and min = linear and mip = linear */
  76583. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  76584. /** mag = nearest and min = nearest and mip = nearest */
  76585. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  76586. /** mag = nearest and min = linear and mip = nearest */
  76587. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  76588. /** mag = nearest and min = linear and mip = linear */
  76589. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  76590. /** mag = nearest and min = linear and mip = none */
  76591. static readonly NEAREST_LINEAR: number;
  76592. /** mag = nearest and min = nearest and mip = none */
  76593. static readonly NEAREST_NEAREST: number;
  76594. /** mag = linear and min = nearest and mip = nearest */
  76595. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  76596. /** mag = linear and min = nearest and mip = linear */
  76597. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  76598. /** mag = linear and min = linear and mip = none */
  76599. static readonly LINEAR_LINEAR: number;
  76600. /** mag = linear and min = nearest and mip = none */
  76601. static readonly LINEAR_NEAREST: number;
  76602. /** Explicit coordinates mode */
  76603. static readonly EXPLICIT_MODE: number;
  76604. /** Spherical coordinates mode */
  76605. static readonly SPHERICAL_MODE: number;
  76606. /** Planar coordinates mode */
  76607. static readonly PLANAR_MODE: number;
  76608. /** Cubic coordinates mode */
  76609. static readonly CUBIC_MODE: number;
  76610. /** Projection coordinates mode */
  76611. static readonly PROJECTION_MODE: number;
  76612. /** Inverse Cubic coordinates mode */
  76613. static readonly SKYBOX_MODE: number;
  76614. /** Inverse Cubic coordinates mode */
  76615. static readonly INVCUBIC_MODE: number;
  76616. /** Equirectangular coordinates mode */
  76617. static readonly EQUIRECTANGULAR_MODE: number;
  76618. /** Equirectangular Fixed coordinates mode */
  76619. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  76620. /** Equirectangular Fixed Mirrored coordinates mode */
  76621. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76622. /** Texture is not repeating outside of 0..1 UVs */
  76623. static readonly CLAMP_ADDRESSMODE: number;
  76624. /** Texture is repeating outside of 0..1 UVs */
  76625. static readonly WRAP_ADDRESSMODE: number;
  76626. /** Texture is repeating and mirrored */
  76627. static readonly MIRROR_ADDRESSMODE: number;
  76628. /**
  76629. * 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
  76630. */
  76631. static UseSerializedUrlIfAny: boolean;
  76632. /**
  76633. * Define the url of the texture.
  76634. */
  76635. url: Nullable<string>;
  76636. /**
  76637. * Define an offset on the texture to offset the u coordinates of the UVs
  76638. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76639. */
  76640. uOffset: number;
  76641. /**
  76642. * Define an offset on the texture to offset the v coordinates of the UVs
  76643. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76644. */
  76645. vOffset: number;
  76646. /**
  76647. * Define an offset on the texture to scale the u coordinates of the UVs
  76648. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76649. */
  76650. uScale: number;
  76651. /**
  76652. * Define an offset on the texture to scale the v coordinates of the UVs
  76653. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76654. */
  76655. vScale: number;
  76656. /**
  76657. * Define an offset on the texture to rotate around the u coordinates of the UVs
  76658. * @see http://doc.babylonjs.com/how_to/more_materials
  76659. */
  76660. uAng: number;
  76661. /**
  76662. * Define an offset on the texture to rotate around the v coordinates of the UVs
  76663. * @see http://doc.babylonjs.com/how_to/more_materials
  76664. */
  76665. vAng: number;
  76666. /**
  76667. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  76668. * @see http://doc.babylonjs.com/how_to/more_materials
  76669. */
  76670. wAng: number;
  76671. /**
  76672. * Defines the center of rotation (U)
  76673. */
  76674. uRotationCenter: number;
  76675. /**
  76676. * Defines the center of rotation (V)
  76677. */
  76678. vRotationCenter: number;
  76679. /**
  76680. * Defines the center of rotation (W)
  76681. */
  76682. wRotationCenter: number;
  76683. /**
  76684. * Are mip maps generated for this texture or not.
  76685. */
  76686. readonly noMipmap: boolean;
  76687. /**
  76688. * List of inspectable custom properties (used by the Inspector)
  76689. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76690. */
  76691. inspectableCustomProperties: IInspectable[];
  76692. private _noMipmap;
  76693. /** @hidden */
  76694. _invertY: boolean;
  76695. private _rowGenerationMatrix;
  76696. private _cachedTextureMatrix;
  76697. private _projectionModeMatrix;
  76698. private _t0;
  76699. private _t1;
  76700. private _t2;
  76701. private _cachedUOffset;
  76702. private _cachedVOffset;
  76703. private _cachedUScale;
  76704. private _cachedVScale;
  76705. private _cachedUAng;
  76706. private _cachedVAng;
  76707. private _cachedWAng;
  76708. private _cachedProjectionMatrixId;
  76709. private _cachedCoordinatesMode;
  76710. /** @hidden */
  76711. protected _initialSamplingMode: number;
  76712. /** @hidden */
  76713. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  76714. private _deleteBuffer;
  76715. protected _format: Nullable<number>;
  76716. private _delayedOnLoad;
  76717. private _delayedOnError;
  76718. /**
  76719. * Observable triggered once the texture has been loaded.
  76720. */
  76721. onLoadObservable: Observable<Texture>;
  76722. protected _isBlocking: boolean;
  76723. /**
  76724. * Is the texture preventing material to render while loading.
  76725. * If false, a default texture will be used instead of the loading one during the preparation step.
  76726. */
  76727. isBlocking: boolean;
  76728. /**
  76729. * Get the current sampling mode associated with the texture.
  76730. */
  76731. readonly samplingMode: number;
  76732. /**
  76733. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  76734. */
  76735. readonly invertY: boolean;
  76736. /**
  76737. * Instantiates a new texture.
  76738. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76739. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76740. * @param url define the url of the picture to load as a texture
  76741. * @param scene define the scene the texture will belong to
  76742. * @param noMipmap define if the texture will require mip maps or not
  76743. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76744. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76745. * @param onLoad define a callback triggered when the texture has been loaded
  76746. * @param onError define a callback triggered when an error occurred during the loading session
  76747. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76748. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76749. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76750. */
  76751. 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);
  76752. /**
  76753. * Update the url (and optional buffer) of this texture if url was null during construction.
  76754. * @param url the url of the texture
  76755. * @param buffer the buffer of the texture (defaults to null)
  76756. * @param onLoad callback called when the texture is loaded (defaults to null)
  76757. */
  76758. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  76759. /**
  76760. * Finish the loading sequence of a texture flagged as delayed load.
  76761. * @hidden
  76762. */
  76763. delayLoad(): void;
  76764. private _prepareRowForTextureGeneration;
  76765. /**
  76766. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  76767. * @returns the transform matrix of the texture.
  76768. */
  76769. getTextureMatrix(): Matrix;
  76770. /**
  76771. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  76772. * @returns The reflection texture transform
  76773. */
  76774. getReflectionTextureMatrix(): Matrix;
  76775. /**
  76776. * Clones the texture.
  76777. * @returns the cloned texture
  76778. */
  76779. clone(): Texture;
  76780. /**
  76781. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76782. * @returns The JSON representation of the texture
  76783. */
  76784. serialize(): any;
  76785. /**
  76786. * Get the current class name of the texture useful for serialization or dynamic coding.
  76787. * @returns "Texture"
  76788. */
  76789. getClassName(): string;
  76790. /**
  76791. * Dispose the texture and release its associated resources.
  76792. */
  76793. dispose(): void;
  76794. /**
  76795. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  76796. * @param parsedTexture Define the JSON representation of the texture
  76797. * @param scene Define the scene the parsed texture should be instantiated in
  76798. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  76799. * @returns The parsed texture if successful
  76800. */
  76801. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  76802. /**
  76803. * Creates a texture from its base 64 representation.
  76804. * @param data Define the base64 payload without the data: prefix
  76805. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76806. * @param scene Define the scene the texture should belong to
  76807. * @param noMipmap Forces the texture to not create mip map information if true
  76808. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76809. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76810. * @param onLoad define a callback triggered when the texture has been loaded
  76811. * @param onError define a callback triggered when an error occurred during the loading session
  76812. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76813. * @returns the created texture
  76814. */
  76815. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  76816. /**
  76817. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  76818. * @param data Define the base64 payload without the data: prefix
  76819. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76820. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76821. * @param scene Define the scene the texture should belong to
  76822. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76823. * @param noMipmap Forces the texture to not create mip map information if true
  76824. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76825. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76826. * @param onLoad define a callback triggered when the texture has been loaded
  76827. * @param onError define a callback triggered when an error occurred during the loading session
  76828. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76829. * @returns the created texture
  76830. */
  76831. 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;
  76832. }
  76833. }
  76834. declare module BABYLON {
  76835. /**
  76836. * Raw texture can help creating a texture directly from an array of data.
  76837. * This can be super useful if you either get the data from an uncompressed source or
  76838. * if you wish to create your texture pixel by pixel.
  76839. */
  76840. export class RawTexture extends Texture {
  76841. /**
  76842. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76843. */
  76844. format: number;
  76845. private _engine;
  76846. /**
  76847. * Instantiates a new RawTexture.
  76848. * Raw texture can help creating a texture directly from an array of data.
  76849. * This can be super useful if you either get the data from an uncompressed source or
  76850. * if you wish to create your texture pixel by pixel.
  76851. * @param data define the array of data to use to create the texture
  76852. * @param width define the width of the texture
  76853. * @param height define the height of the texture
  76854. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76855. * @param scene define the scene the texture belongs to
  76856. * @param generateMipMaps define whether mip maps should be generated or not
  76857. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76858. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76859. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76860. */
  76861. constructor(data: ArrayBufferView, width: number, height: number,
  76862. /**
  76863. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76864. */
  76865. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76866. /**
  76867. * Updates the texture underlying data.
  76868. * @param data Define the new data of the texture
  76869. */
  76870. update(data: ArrayBufferView): void;
  76871. /**
  76872. * Creates a luminance texture from some data.
  76873. * @param data Define the texture data
  76874. * @param width Define the width of the texture
  76875. * @param height Define the height of the texture
  76876. * @param scene Define the scene the texture belongs to
  76877. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76878. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76879. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76880. * @returns the luminance texture
  76881. */
  76882. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76883. /**
  76884. * Creates a luminance alpha texture from some data.
  76885. * @param data Define the texture data
  76886. * @param width Define the width of the texture
  76887. * @param height Define the height of the texture
  76888. * @param scene Define the scene the texture belongs to
  76889. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76890. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76891. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76892. * @returns the luminance alpha texture
  76893. */
  76894. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76895. /**
  76896. * Creates an alpha texture from some data.
  76897. * @param data Define the texture data
  76898. * @param width Define the width of the texture
  76899. * @param height Define the height of the texture
  76900. * @param scene Define the scene the texture belongs to
  76901. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76904. * @returns the alpha texture
  76905. */
  76906. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76907. /**
  76908. * Creates a RGB texture from some data.
  76909. * @param data Define the texture data
  76910. * @param width Define the width of the texture
  76911. * @param height Define the height of the texture
  76912. * @param scene Define the scene the texture belongs to
  76913. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76914. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76915. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76916. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76917. * @returns the RGB alpha texture
  76918. */
  76919. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76920. /**
  76921. * Creates a RGBA texture from some data.
  76922. * @param data Define the texture data
  76923. * @param width Define the width of the texture
  76924. * @param height Define the height of the texture
  76925. * @param scene Define the scene the texture belongs to
  76926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76929. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76930. * @returns the RGBA texture
  76931. */
  76932. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76933. /**
  76934. * Creates a R texture from some data.
  76935. * @param data Define the texture data
  76936. * @param width Define the width of the texture
  76937. * @param height Define the height of the texture
  76938. * @param scene Define the scene the texture belongs to
  76939. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76940. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76941. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76942. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76943. * @returns the R texture
  76944. */
  76945. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76946. }
  76947. }
  76948. declare module BABYLON {
  76949. /**
  76950. * Defines a runtime animation
  76951. */
  76952. export class RuntimeAnimation {
  76953. private _events;
  76954. /**
  76955. * The current frame of the runtime animation
  76956. */
  76957. private _currentFrame;
  76958. /**
  76959. * The animation used by the runtime animation
  76960. */
  76961. private _animation;
  76962. /**
  76963. * The target of the runtime animation
  76964. */
  76965. private _target;
  76966. /**
  76967. * The initiating animatable
  76968. */
  76969. private _host;
  76970. /**
  76971. * The original value of the runtime animation
  76972. */
  76973. private _originalValue;
  76974. /**
  76975. * The original blend value of the runtime animation
  76976. */
  76977. private _originalBlendValue;
  76978. /**
  76979. * The offsets cache of the runtime animation
  76980. */
  76981. private _offsetsCache;
  76982. /**
  76983. * The high limits cache of the runtime animation
  76984. */
  76985. private _highLimitsCache;
  76986. /**
  76987. * Specifies if the runtime animation has been stopped
  76988. */
  76989. private _stopped;
  76990. /**
  76991. * The blending factor of the runtime animation
  76992. */
  76993. private _blendingFactor;
  76994. /**
  76995. * The BabylonJS scene
  76996. */
  76997. private _scene;
  76998. /**
  76999. * The current value of the runtime animation
  77000. */
  77001. private _currentValue;
  77002. /** @hidden */
  77003. _workValue: any;
  77004. /**
  77005. * The active target of the runtime animation
  77006. */
  77007. private _activeTarget;
  77008. /**
  77009. * The target path of the runtime animation
  77010. */
  77011. private _targetPath;
  77012. /**
  77013. * The weight of the runtime animation
  77014. */
  77015. private _weight;
  77016. /**
  77017. * The ratio offset of the runtime animation
  77018. */
  77019. private _ratioOffset;
  77020. /**
  77021. * The previous delay of the runtime animation
  77022. */
  77023. private _previousDelay;
  77024. /**
  77025. * The previous ratio of the runtime animation
  77026. */
  77027. private _previousRatio;
  77028. /**
  77029. * Gets the current frame of the runtime animation
  77030. */
  77031. readonly currentFrame: number;
  77032. /**
  77033. * Gets the weight of the runtime animation
  77034. */
  77035. readonly weight: number;
  77036. /**
  77037. * Gets the current value of the runtime animation
  77038. */
  77039. readonly currentValue: any;
  77040. /**
  77041. * Gets the target path of the runtime animation
  77042. */
  77043. readonly targetPath: string;
  77044. /**
  77045. * Gets the actual target of the runtime animation
  77046. */
  77047. readonly target: any;
  77048. /**
  77049. * Create a new RuntimeAnimation object
  77050. * @param target defines the target of the animation
  77051. * @param animation defines the source animation object
  77052. * @param scene defines the hosting scene
  77053. * @param host defines the initiating Animatable
  77054. */
  77055. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77056. /**
  77057. * Gets the animation from the runtime animation
  77058. */
  77059. readonly animation: Animation;
  77060. /**
  77061. * Resets the runtime animation to the beginning
  77062. * @param restoreOriginal defines whether to restore the target property to the original value
  77063. */
  77064. reset(restoreOriginal?: boolean): void;
  77065. /**
  77066. * Specifies if the runtime animation is stopped
  77067. * @returns Boolean specifying if the runtime animation is stopped
  77068. */
  77069. isStopped(): boolean;
  77070. /**
  77071. * Disposes of the runtime animation
  77072. */
  77073. dispose(): void;
  77074. /**
  77075. * Interpolates the animation from the current frame
  77076. * @param currentFrame The frame to interpolate the animation to
  77077. * @param repeatCount The number of times that the animation should loop
  77078. * @param loopMode The type of looping mode to use
  77079. * @param offsetValue Animation offset value
  77080. * @param highLimitValue The high limit value
  77081. * @returns The interpolated value
  77082. */
  77083. private _interpolate;
  77084. /**
  77085. * Apply the interpolated value to the target
  77086. * @param currentValue defines the value computed by the animation
  77087. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77088. */
  77089. setValue(currentValue: any, weight?: number): void;
  77090. private _setValue;
  77091. /**
  77092. * Gets the loop pmode of the runtime animation
  77093. * @returns Loop Mode
  77094. */
  77095. private _getCorrectLoopMode;
  77096. /**
  77097. * Move the current animation to a given frame
  77098. * @param frame defines the frame to move to
  77099. */
  77100. goToFrame(frame: number): void;
  77101. /**
  77102. * @hidden Internal use only
  77103. */
  77104. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77105. /**
  77106. * Execute the current animation
  77107. * @param delay defines the delay to add to the current frame
  77108. * @param from defines the lower bound of the animation range
  77109. * @param to defines the upper bound of the animation range
  77110. * @param loop defines if the current animation must loop
  77111. * @param speedRatio defines the current speed ratio
  77112. * @param weight defines the weight of the animation (default is -1 so no weight)
  77113. * @param onLoop optional callback called when animation loops
  77114. * @returns a boolean indicating if the animation is running
  77115. */
  77116. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  77117. }
  77118. }
  77119. declare module BABYLON {
  77120. /**
  77121. * Class used to store an actual running animation
  77122. */
  77123. export class Animatable {
  77124. /** defines the target object */
  77125. target: any;
  77126. /** defines the starting frame number (default is 0) */
  77127. fromFrame: number;
  77128. /** defines the ending frame number (default is 100) */
  77129. toFrame: number;
  77130. /** defines if the animation must loop (default is false) */
  77131. loopAnimation: boolean;
  77132. /** defines a callback to call when animation ends if it is not looping */
  77133. onAnimationEnd?: (() => void) | null | undefined;
  77134. /** defines a callback to call when animation loops */
  77135. onAnimationLoop?: (() => void) | null | undefined;
  77136. private _localDelayOffset;
  77137. private _pausedDelay;
  77138. private _runtimeAnimations;
  77139. private _paused;
  77140. private _scene;
  77141. private _speedRatio;
  77142. private _weight;
  77143. private _syncRoot;
  77144. /**
  77145. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77146. * This will only apply for non looping animation (default is true)
  77147. */
  77148. disposeOnEnd: boolean;
  77149. /**
  77150. * Gets a boolean indicating if the animation has started
  77151. */
  77152. animationStarted: boolean;
  77153. /**
  77154. * Observer raised when the animation ends
  77155. */
  77156. onAnimationEndObservable: Observable<Animatable>;
  77157. /**
  77158. * Observer raised when the animation loops
  77159. */
  77160. onAnimationLoopObservable: Observable<Animatable>;
  77161. /**
  77162. * Gets the root Animatable used to synchronize and normalize animations
  77163. */
  77164. readonly syncRoot: Animatable;
  77165. /**
  77166. * Gets the current frame of the first RuntimeAnimation
  77167. * Used to synchronize Animatables
  77168. */
  77169. readonly masterFrame: number;
  77170. /**
  77171. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77172. */
  77173. weight: number;
  77174. /**
  77175. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77176. */
  77177. speedRatio: number;
  77178. /**
  77179. * Creates a new Animatable
  77180. * @param scene defines the hosting scene
  77181. * @param target defines the target object
  77182. * @param fromFrame defines the starting frame number (default is 0)
  77183. * @param toFrame defines the ending frame number (default is 100)
  77184. * @param loopAnimation defines if the animation must loop (default is false)
  77185. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77186. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77187. * @param animations defines a group of animation to add to the new Animatable
  77188. * @param onAnimationLoop defines a callback to call when animation loops
  77189. */
  77190. constructor(scene: Scene,
  77191. /** defines the target object */
  77192. target: any,
  77193. /** defines the starting frame number (default is 0) */
  77194. fromFrame?: number,
  77195. /** defines the ending frame number (default is 100) */
  77196. toFrame?: number,
  77197. /** defines if the animation must loop (default is false) */
  77198. loopAnimation?: boolean, speedRatio?: number,
  77199. /** defines a callback to call when animation ends if it is not looping */
  77200. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77201. /** defines a callback to call when animation loops */
  77202. onAnimationLoop?: (() => void) | null | undefined);
  77203. /**
  77204. * Synchronize and normalize current Animatable with a source Animatable
  77205. * This is useful when using animation weights and when animations are not of the same length
  77206. * @param root defines the root Animatable to synchronize with
  77207. * @returns the current Animatable
  77208. */
  77209. syncWith(root: Animatable): Animatable;
  77210. /**
  77211. * Gets the list of runtime animations
  77212. * @returns an array of RuntimeAnimation
  77213. */
  77214. getAnimations(): RuntimeAnimation[];
  77215. /**
  77216. * Adds more animations to the current animatable
  77217. * @param target defines the target of the animations
  77218. * @param animations defines the new animations to add
  77219. */
  77220. appendAnimations(target: any, animations: Animation[]): void;
  77221. /**
  77222. * Gets the source animation for a specific property
  77223. * @param property defines the propertyu to look for
  77224. * @returns null or the source animation for the given property
  77225. */
  77226. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77227. /**
  77228. * Gets the runtime animation for a specific property
  77229. * @param property defines the propertyu to look for
  77230. * @returns null or the runtime animation for the given property
  77231. */
  77232. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77233. /**
  77234. * Resets the animatable to its original state
  77235. */
  77236. reset(): void;
  77237. /**
  77238. * Allows the animatable to blend with current running animations
  77239. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77240. * @param blendingSpeed defines the blending speed to use
  77241. */
  77242. enableBlending(blendingSpeed: number): void;
  77243. /**
  77244. * Disable animation blending
  77245. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77246. */
  77247. disableBlending(): void;
  77248. /**
  77249. * Jump directly to a given frame
  77250. * @param frame defines the frame to jump to
  77251. */
  77252. goToFrame(frame: number): void;
  77253. /**
  77254. * Pause the animation
  77255. */
  77256. pause(): void;
  77257. /**
  77258. * Restart the animation
  77259. */
  77260. restart(): void;
  77261. private _raiseOnAnimationEnd;
  77262. /**
  77263. * Stop and delete the current animation
  77264. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77265. * @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)
  77266. */
  77267. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77268. /**
  77269. * Wait asynchronously for the animation to end
  77270. * @returns a promise which will be fullfilled when the animation ends
  77271. */
  77272. waitAsync(): Promise<Animatable>;
  77273. /** @hidden */
  77274. _animate(delay: number): boolean;
  77275. }
  77276. interface Scene {
  77277. /** @hidden */
  77278. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77279. /** @hidden */
  77280. _processLateAnimationBindingsForMatrices(holder: {
  77281. totalWeight: number;
  77282. animations: RuntimeAnimation[];
  77283. originalValue: Matrix;
  77284. }): any;
  77285. /** @hidden */
  77286. _processLateAnimationBindingsForQuaternions(holder: {
  77287. totalWeight: number;
  77288. animations: RuntimeAnimation[];
  77289. originalValue: Quaternion;
  77290. }, refQuaternion: Quaternion): Quaternion;
  77291. /** @hidden */
  77292. _processLateAnimationBindings(): void;
  77293. /**
  77294. * Will start the animation sequence of a given target
  77295. * @param target defines the target
  77296. * @param from defines from which frame should animation start
  77297. * @param to defines until which frame should animation run.
  77298. * @param weight defines the weight to apply to the animation (1.0 by default)
  77299. * @param loop defines if the animation loops
  77300. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77301. * @param onAnimationEnd defines the function to be executed when the animation ends
  77302. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77303. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77304. * @param onAnimationLoop defines the callback to call when an animation loops
  77305. * @returns the animatable object created for this animation
  77306. */
  77307. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77308. /**
  77309. * Will start the animation sequence of a given target
  77310. * @param target defines the target
  77311. * @param from defines from which frame should animation start
  77312. * @param to defines until which frame should animation run.
  77313. * @param loop defines if the animation loops
  77314. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77315. * @param onAnimationEnd defines the function to be executed when the animation ends
  77316. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77317. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77318. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77319. * @param onAnimationLoop defines the callback to call when an animation loops
  77320. * @returns the animatable object created for this animation
  77321. */
  77322. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77323. /**
  77324. * Will start the animation sequence of a given target and its hierarchy
  77325. * @param target defines the target
  77326. * @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.
  77327. * @param from defines from which frame should animation start
  77328. * @param to defines until which frame should animation run.
  77329. * @param loop defines if the animation loops
  77330. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77331. * @param onAnimationEnd defines the function to be executed when the animation ends
  77332. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77333. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77334. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77335. * @param onAnimationLoop defines the callback to call when an animation loops
  77336. * @returns the list of created animatables
  77337. */
  77338. 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[];
  77339. /**
  77340. * Begin a new animation on a given node
  77341. * @param target defines the target where the animation will take place
  77342. * @param animations defines the list of animations to start
  77343. * @param from defines the initial value
  77344. * @param to defines the final value
  77345. * @param loop defines if you want animation to loop (off by default)
  77346. * @param speedRatio defines the speed ratio to apply to all animations
  77347. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77348. * @param onAnimationLoop defines the callback to call when an animation loops
  77349. * @returns the list of created animatables
  77350. */
  77351. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77352. /**
  77353. * Begin a new animation on a given node and its hierarchy
  77354. * @param target defines the root node where the animation will take place
  77355. * @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.
  77356. * @param animations defines the list of animations to start
  77357. * @param from defines the initial value
  77358. * @param to defines the final value
  77359. * @param loop defines if you want animation to loop (off by default)
  77360. * @param speedRatio defines the speed ratio to apply to all animations
  77361. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77362. * @param onAnimationLoop defines the callback to call when an animation loops
  77363. * @returns the list of animatables created for all nodes
  77364. */
  77365. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77366. /**
  77367. * Gets the animatable associated with a specific target
  77368. * @param target defines the target of the animatable
  77369. * @returns the required animatable if found
  77370. */
  77371. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77372. /**
  77373. * Gets all animatables associated with a given target
  77374. * @param target defines the target to look animatables for
  77375. * @returns an array of Animatables
  77376. */
  77377. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77378. /**
  77379. * Will stop the animation of the given target
  77380. * @param target - the target
  77381. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  77382. * @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)
  77383. */
  77384. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  77385. /**
  77386. * Stops and removes all animations that have been applied to the scene
  77387. */
  77388. stopAllAnimations(): void;
  77389. }
  77390. interface Bone {
  77391. /**
  77392. * Copy an animation range from another bone
  77393. * @param source defines the source bone
  77394. * @param rangeName defines the range name to copy
  77395. * @param frameOffset defines the frame offset
  77396. * @param rescaleAsRequired defines if rescaling must be applied if required
  77397. * @param skelDimensionsRatio defines the scaling ratio
  77398. * @returns true if operation was successful
  77399. */
  77400. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77401. }
  77402. }
  77403. declare module BABYLON {
  77404. /**
  77405. * Class used to handle skinning animations
  77406. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77407. */
  77408. export class Skeleton implements IAnimatable {
  77409. /** defines the skeleton name */
  77410. name: string;
  77411. /** defines the skeleton Id */
  77412. id: string;
  77413. /**
  77414. * Defines the list of child bones
  77415. */
  77416. bones: Bone[];
  77417. /**
  77418. * Defines an estimate of the dimension of the skeleton at rest
  77419. */
  77420. dimensionsAtRest: Vector3;
  77421. /**
  77422. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77423. */
  77424. needInitialSkinMatrix: boolean;
  77425. /**
  77426. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77427. */
  77428. overrideMesh: Nullable<AbstractMesh>;
  77429. /**
  77430. * Gets the list of animations attached to this skeleton
  77431. */
  77432. animations: Array<Animation>;
  77433. private _scene;
  77434. private _isDirty;
  77435. private _transformMatrices;
  77436. private _transformMatrixTexture;
  77437. private _meshesWithPoseMatrix;
  77438. private _animatables;
  77439. private _identity;
  77440. private _synchronizedWithMesh;
  77441. private _ranges;
  77442. private _lastAbsoluteTransformsUpdateId;
  77443. private _canUseTextureForBones;
  77444. private _uniqueId;
  77445. /** @hidden */
  77446. _numBonesWithLinkedTransformNode: number;
  77447. /**
  77448. * Specifies if the skeleton should be serialized
  77449. */
  77450. doNotSerialize: boolean;
  77451. private _useTextureToStoreBoneMatrices;
  77452. /**
  77453. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77454. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  77455. */
  77456. useTextureToStoreBoneMatrices: boolean;
  77457. private _animationPropertiesOverride;
  77458. /**
  77459. * Gets or sets the animation properties override
  77460. */
  77461. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77462. /**
  77463. * List of inspectable custom properties (used by the Inspector)
  77464. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77465. */
  77466. inspectableCustomProperties: IInspectable[];
  77467. /**
  77468. * An observable triggered before computing the skeleton's matrices
  77469. */
  77470. onBeforeComputeObservable: Observable<Skeleton>;
  77471. /**
  77472. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77473. */
  77474. readonly isUsingTextureForMatrices: boolean;
  77475. /**
  77476. * Gets the unique ID of this skeleton
  77477. */
  77478. readonly uniqueId: number;
  77479. /**
  77480. * Creates a new skeleton
  77481. * @param name defines the skeleton name
  77482. * @param id defines the skeleton Id
  77483. * @param scene defines the hosting scene
  77484. */
  77485. constructor(
  77486. /** defines the skeleton name */
  77487. name: string,
  77488. /** defines the skeleton Id */
  77489. id: string, scene: Scene);
  77490. /**
  77491. * Gets the current object class name.
  77492. * @return the class name
  77493. */
  77494. getClassName(): string;
  77495. /**
  77496. * Returns an array containing the root bones
  77497. * @returns an array containing the root bones
  77498. */
  77499. getChildren(): Array<Bone>;
  77500. /**
  77501. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77502. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77503. * @returns a Float32Array containing matrices data
  77504. */
  77505. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77506. /**
  77507. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77508. * @returns a raw texture containing the data
  77509. */
  77510. getTransformMatrixTexture(): Nullable<RawTexture>;
  77511. /**
  77512. * Gets the current hosting scene
  77513. * @returns a scene object
  77514. */
  77515. getScene(): Scene;
  77516. /**
  77517. * Gets a string representing the current skeleton data
  77518. * @param fullDetails defines a boolean indicating if we want a verbose version
  77519. * @returns a string representing the current skeleton data
  77520. */
  77521. toString(fullDetails?: boolean): string;
  77522. /**
  77523. * Get bone's index searching by name
  77524. * @param name defines bone's name to search for
  77525. * @return the indice of the bone. Returns -1 if not found
  77526. */
  77527. getBoneIndexByName(name: string): number;
  77528. /**
  77529. * Creater a new animation range
  77530. * @param name defines the name of the range
  77531. * @param from defines the start key
  77532. * @param to defines the end key
  77533. */
  77534. createAnimationRange(name: string, from: number, to: number): void;
  77535. /**
  77536. * Delete a specific animation range
  77537. * @param name defines the name of the range
  77538. * @param deleteFrames defines if frames must be removed as well
  77539. */
  77540. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77541. /**
  77542. * Gets a specific animation range
  77543. * @param name defines the name of the range to look for
  77544. * @returns the requested animation range or null if not found
  77545. */
  77546. getAnimationRange(name: string): Nullable<AnimationRange>;
  77547. /**
  77548. * Gets the list of all animation ranges defined on this skeleton
  77549. * @returns an array
  77550. */
  77551. getAnimationRanges(): Nullable<AnimationRange>[];
  77552. /**
  77553. * Copy animation range from a source skeleton.
  77554. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77555. * @param source defines the source skeleton
  77556. * @param name defines the name of the range to copy
  77557. * @param rescaleAsRequired defines if rescaling must be applied if required
  77558. * @returns true if operation was successful
  77559. */
  77560. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77561. /**
  77562. * Forces the skeleton to go to rest pose
  77563. */
  77564. returnToRest(): void;
  77565. private _getHighestAnimationFrame;
  77566. /**
  77567. * Begin a specific animation range
  77568. * @param name defines the name of the range to start
  77569. * @param loop defines if looping must be turned on (false by default)
  77570. * @param speedRatio defines the speed ratio to apply (1 by default)
  77571. * @param onAnimationEnd defines a callback which will be called when animation will end
  77572. * @returns a new animatable
  77573. */
  77574. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77575. /** @hidden */
  77576. _markAsDirty(): void;
  77577. /** @hidden */
  77578. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77579. /** @hidden */
  77580. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77581. private _computeTransformMatrices;
  77582. /**
  77583. * Build all resources required to render a skeleton
  77584. */
  77585. prepare(): void;
  77586. /**
  77587. * Gets the list of animatables currently running for this skeleton
  77588. * @returns an array of animatables
  77589. */
  77590. getAnimatables(): IAnimatable[];
  77591. /**
  77592. * Clone the current skeleton
  77593. * @param name defines the name of the new skeleton
  77594. * @param id defines the id of the enw skeleton
  77595. * @returns the new skeleton
  77596. */
  77597. clone(name: string, id: string): Skeleton;
  77598. /**
  77599. * Enable animation blending for this skeleton
  77600. * @param blendingSpeed defines the blending speed to apply
  77601. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77602. */
  77603. enableBlending(blendingSpeed?: number): void;
  77604. /**
  77605. * Releases all resources associated with the current skeleton
  77606. */
  77607. dispose(): void;
  77608. /**
  77609. * Serialize the skeleton in a JSON object
  77610. * @returns a JSON object
  77611. */
  77612. serialize(): any;
  77613. /**
  77614. * Creates a new skeleton from serialized data
  77615. * @param parsedSkeleton defines the serialized data
  77616. * @param scene defines the hosting scene
  77617. * @returns a new skeleton
  77618. */
  77619. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77620. /**
  77621. * Compute all node absolute transforms
  77622. * @param forceUpdate defines if computation must be done even if cache is up to date
  77623. */
  77624. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77625. /**
  77626. * Gets the root pose matrix
  77627. * @returns a matrix
  77628. */
  77629. getPoseMatrix(): Nullable<Matrix>;
  77630. /**
  77631. * Sorts bones per internal index
  77632. */
  77633. sortBones(): void;
  77634. private _sortBones;
  77635. }
  77636. }
  77637. declare module BABYLON {
  77638. /**
  77639. * Defines a target to use with MorphTargetManager
  77640. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77641. */
  77642. export class MorphTarget implements IAnimatable {
  77643. /** defines the name of the target */
  77644. name: string;
  77645. /**
  77646. * Gets or sets the list of animations
  77647. */
  77648. animations: Animation[];
  77649. private _scene;
  77650. private _positions;
  77651. private _normals;
  77652. private _tangents;
  77653. private _influence;
  77654. /**
  77655. * Observable raised when the influence changes
  77656. */
  77657. onInfluenceChanged: Observable<boolean>;
  77658. /** @hidden */
  77659. _onDataLayoutChanged: Observable<void>;
  77660. /**
  77661. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  77662. */
  77663. influence: number;
  77664. /**
  77665. * Gets or sets the id of the morph Target
  77666. */
  77667. id: string;
  77668. private _animationPropertiesOverride;
  77669. /**
  77670. * Gets or sets the animation properties override
  77671. */
  77672. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77673. /**
  77674. * Creates a new MorphTarget
  77675. * @param name defines the name of the target
  77676. * @param influence defines the influence to use
  77677. * @param scene defines the scene the morphtarget belongs to
  77678. */
  77679. constructor(
  77680. /** defines the name of the target */
  77681. name: string, influence?: number, scene?: Nullable<Scene>);
  77682. /**
  77683. * Gets a boolean defining if the target contains position data
  77684. */
  77685. readonly hasPositions: boolean;
  77686. /**
  77687. * Gets a boolean defining if the target contains normal data
  77688. */
  77689. readonly hasNormals: boolean;
  77690. /**
  77691. * Gets a boolean defining if the target contains tangent data
  77692. */
  77693. readonly hasTangents: boolean;
  77694. /**
  77695. * Affects position data to this target
  77696. * @param data defines the position data to use
  77697. */
  77698. setPositions(data: Nullable<FloatArray>): void;
  77699. /**
  77700. * Gets the position data stored in this target
  77701. * @returns a FloatArray containing the position data (or null if not present)
  77702. */
  77703. getPositions(): Nullable<FloatArray>;
  77704. /**
  77705. * Affects normal data to this target
  77706. * @param data defines the normal data to use
  77707. */
  77708. setNormals(data: Nullable<FloatArray>): void;
  77709. /**
  77710. * Gets the normal data stored in this target
  77711. * @returns a FloatArray containing the normal data (or null if not present)
  77712. */
  77713. getNormals(): Nullable<FloatArray>;
  77714. /**
  77715. * Affects tangent data to this target
  77716. * @param data defines the tangent data to use
  77717. */
  77718. setTangents(data: Nullable<FloatArray>): void;
  77719. /**
  77720. * Gets the tangent data stored in this target
  77721. * @returns a FloatArray containing the tangent data (or null if not present)
  77722. */
  77723. getTangents(): Nullable<FloatArray>;
  77724. /**
  77725. * Serializes the current target into a Serialization object
  77726. * @returns the serialized object
  77727. */
  77728. serialize(): any;
  77729. /**
  77730. * Returns the string "MorphTarget"
  77731. * @returns "MorphTarget"
  77732. */
  77733. getClassName(): string;
  77734. /**
  77735. * Creates a new target from serialized data
  77736. * @param serializationObject defines the serialized data to use
  77737. * @returns a new MorphTarget
  77738. */
  77739. static Parse(serializationObject: any): MorphTarget;
  77740. /**
  77741. * Creates a MorphTarget from mesh data
  77742. * @param mesh defines the source mesh
  77743. * @param name defines the name to use for the new target
  77744. * @param influence defines the influence to attach to the target
  77745. * @returns a new MorphTarget
  77746. */
  77747. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  77748. }
  77749. }
  77750. declare module BABYLON {
  77751. /**
  77752. * This class is used to deform meshes using morphing between different targets
  77753. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77754. */
  77755. export class MorphTargetManager {
  77756. private _targets;
  77757. private _targetInfluenceChangedObservers;
  77758. private _targetDataLayoutChangedObservers;
  77759. private _activeTargets;
  77760. private _scene;
  77761. private _influences;
  77762. private _supportsNormals;
  77763. private _supportsTangents;
  77764. private _vertexCount;
  77765. private _uniqueId;
  77766. private _tempInfluences;
  77767. /**
  77768. * Creates a new MorphTargetManager
  77769. * @param scene defines the current scene
  77770. */
  77771. constructor(scene?: Nullable<Scene>);
  77772. /**
  77773. * Gets the unique ID of this manager
  77774. */
  77775. readonly uniqueId: number;
  77776. /**
  77777. * Gets the number of vertices handled by this manager
  77778. */
  77779. readonly vertexCount: number;
  77780. /**
  77781. * Gets a boolean indicating if this manager supports morphing of normals
  77782. */
  77783. readonly supportsNormals: boolean;
  77784. /**
  77785. * Gets a boolean indicating if this manager supports morphing of tangents
  77786. */
  77787. readonly supportsTangents: boolean;
  77788. /**
  77789. * Gets the number of targets stored in this manager
  77790. */
  77791. readonly numTargets: number;
  77792. /**
  77793. * Gets the number of influencers (ie. the number of targets with influences > 0)
  77794. */
  77795. readonly numInfluencers: number;
  77796. /**
  77797. * Gets the list of influences (one per target)
  77798. */
  77799. readonly influences: Float32Array;
  77800. /**
  77801. * Gets the active target at specified index. An active target is a target with an influence > 0
  77802. * @param index defines the index to check
  77803. * @returns the requested target
  77804. */
  77805. getActiveTarget(index: number): MorphTarget;
  77806. /**
  77807. * Gets the target at specified index
  77808. * @param index defines the index to check
  77809. * @returns the requested target
  77810. */
  77811. getTarget(index: number): MorphTarget;
  77812. /**
  77813. * Add a new target to this manager
  77814. * @param target defines the target to add
  77815. */
  77816. addTarget(target: MorphTarget): void;
  77817. /**
  77818. * Removes a target from the manager
  77819. * @param target defines the target to remove
  77820. */
  77821. removeTarget(target: MorphTarget): void;
  77822. /**
  77823. * Serializes the current manager into a Serialization object
  77824. * @returns the serialized object
  77825. */
  77826. serialize(): any;
  77827. private _syncActiveTargets;
  77828. /**
  77829. * Syncrhonize the targets with all the meshes using this morph target manager
  77830. */
  77831. synchronize(): void;
  77832. /**
  77833. * Creates a new MorphTargetManager from serialized data
  77834. * @param serializationObject defines the serialized data
  77835. * @param scene defines the hosting scene
  77836. * @returns the new MorphTargetManager
  77837. */
  77838. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  77839. }
  77840. }
  77841. declare module BABYLON {
  77842. /**
  77843. * Mesh representing the gorund
  77844. */
  77845. export class GroundMesh extends Mesh {
  77846. /** If octree should be generated */
  77847. generateOctree: boolean;
  77848. private _heightQuads;
  77849. /** @hidden */
  77850. _subdivisionsX: number;
  77851. /** @hidden */
  77852. _subdivisionsY: number;
  77853. /** @hidden */
  77854. _width: number;
  77855. /** @hidden */
  77856. _height: number;
  77857. /** @hidden */
  77858. _minX: number;
  77859. /** @hidden */
  77860. _maxX: number;
  77861. /** @hidden */
  77862. _minZ: number;
  77863. /** @hidden */
  77864. _maxZ: number;
  77865. constructor(name: string, scene: Scene);
  77866. /**
  77867. * "GroundMesh"
  77868. * @returns "GroundMesh"
  77869. */
  77870. getClassName(): string;
  77871. /**
  77872. * The minimum of x and y subdivisions
  77873. */
  77874. readonly subdivisions: number;
  77875. /**
  77876. * X subdivisions
  77877. */
  77878. readonly subdivisionsX: number;
  77879. /**
  77880. * Y subdivisions
  77881. */
  77882. readonly subdivisionsY: number;
  77883. /**
  77884. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  77885. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  77886. * @param chunksCount the number of subdivisions for x and y
  77887. * @param octreeBlocksSize (Default: 32)
  77888. */
  77889. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  77890. /**
  77891. * Returns a height (y) value in the Worl system :
  77892. * the ground altitude at the coordinates (x, z) expressed in the World system.
  77893. * @param x x coordinate
  77894. * @param z z coordinate
  77895. * @returns the ground y position if (x, z) are outside the ground surface.
  77896. */
  77897. getHeightAtCoordinates(x: number, z: number): number;
  77898. /**
  77899. * Returns a normalized vector (Vector3) orthogonal to the ground
  77900. * at the ground coordinates (x, z) expressed in the World system.
  77901. * @param x x coordinate
  77902. * @param z z coordinate
  77903. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  77904. */
  77905. getNormalAtCoordinates(x: number, z: number): Vector3;
  77906. /**
  77907. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  77908. * at the ground coordinates (x, z) expressed in the World system.
  77909. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  77910. * @param x x coordinate
  77911. * @param z z coordinate
  77912. * @param ref vector to store the result
  77913. * @returns the GroundMesh.
  77914. */
  77915. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  77916. /**
  77917. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  77918. * if the ground has been updated.
  77919. * This can be used in the render loop.
  77920. * @returns the GroundMesh.
  77921. */
  77922. updateCoordinateHeights(): GroundMesh;
  77923. private _getFacetAt;
  77924. private _initHeightQuads;
  77925. private _computeHeightQuads;
  77926. /**
  77927. * Serializes this ground mesh
  77928. * @param serializationObject object to write serialization to
  77929. */
  77930. serialize(serializationObject: any): void;
  77931. /**
  77932. * Parses a serialized ground mesh
  77933. * @param parsedMesh the serialized mesh
  77934. * @param scene the scene to create the ground mesh in
  77935. * @returns the created ground mesh
  77936. */
  77937. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  77938. }
  77939. }
  77940. declare module BABYLON {
  77941. /**
  77942. * Interface for Physics-Joint data
  77943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77944. */
  77945. export interface PhysicsJointData {
  77946. /**
  77947. * The main pivot of the joint
  77948. */
  77949. mainPivot?: Vector3;
  77950. /**
  77951. * The connected pivot of the joint
  77952. */
  77953. connectedPivot?: Vector3;
  77954. /**
  77955. * The main axis of the joint
  77956. */
  77957. mainAxis?: Vector3;
  77958. /**
  77959. * The connected axis of the joint
  77960. */
  77961. connectedAxis?: Vector3;
  77962. /**
  77963. * The collision of the joint
  77964. */
  77965. collision?: boolean;
  77966. /**
  77967. * Native Oimo/Cannon/Energy data
  77968. */
  77969. nativeParams?: any;
  77970. }
  77971. /**
  77972. * This is a holder class for the physics joint created by the physics plugin
  77973. * It holds a set of functions to control the underlying joint
  77974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77975. */
  77976. export class PhysicsJoint {
  77977. /**
  77978. * The type of the physics joint
  77979. */
  77980. type: number;
  77981. /**
  77982. * The data for the physics joint
  77983. */
  77984. jointData: PhysicsJointData;
  77985. private _physicsJoint;
  77986. protected _physicsPlugin: IPhysicsEnginePlugin;
  77987. /**
  77988. * Initializes the physics joint
  77989. * @param type The type of the physics joint
  77990. * @param jointData The data for the physics joint
  77991. */
  77992. constructor(
  77993. /**
  77994. * The type of the physics joint
  77995. */
  77996. type: number,
  77997. /**
  77998. * The data for the physics joint
  77999. */
  78000. jointData: PhysicsJointData);
  78001. /**
  78002. * Gets the physics joint
  78003. */
  78004. /**
  78005. * Sets the physics joint
  78006. */
  78007. physicsJoint: any;
  78008. /**
  78009. * Sets the physics plugin
  78010. */
  78011. physicsPlugin: IPhysicsEnginePlugin;
  78012. /**
  78013. * Execute a function that is physics-plugin specific.
  78014. * @param {Function} func the function that will be executed.
  78015. * It accepts two parameters: the physics world and the physics joint
  78016. */
  78017. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78018. /**
  78019. * Distance-Joint type
  78020. */
  78021. static DistanceJoint: number;
  78022. /**
  78023. * Hinge-Joint type
  78024. */
  78025. static HingeJoint: number;
  78026. /**
  78027. * Ball-and-Socket joint type
  78028. */
  78029. static BallAndSocketJoint: number;
  78030. /**
  78031. * Wheel-Joint type
  78032. */
  78033. static WheelJoint: number;
  78034. /**
  78035. * Slider-Joint type
  78036. */
  78037. static SliderJoint: number;
  78038. /**
  78039. * Prismatic-Joint type
  78040. */
  78041. static PrismaticJoint: number;
  78042. /**
  78043. * Universal-Joint type
  78044. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78045. */
  78046. static UniversalJoint: number;
  78047. /**
  78048. * Hinge-Joint 2 type
  78049. */
  78050. static Hinge2Joint: number;
  78051. /**
  78052. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78053. */
  78054. static PointToPointJoint: number;
  78055. /**
  78056. * Spring-Joint type
  78057. */
  78058. static SpringJoint: number;
  78059. /**
  78060. * Lock-Joint type
  78061. */
  78062. static LockJoint: number;
  78063. }
  78064. /**
  78065. * A class representing a physics distance joint
  78066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78067. */
  78068. export class DistanceJoint extends PhysicsJoint {
  78069. /**
  78070. *
  78071. * @param jointData The data for the Distance-Joint
  78072. */
  78073. constructor(jointData: DistanceJointData);
  78074. /**
  78075. * Update the predefined distance.
  78076. * @param maxDistance The maximum preferred distance
  78077. * @param minDistance The minimum preferred distance
  78078. */
  78079. updateDistance(maxDistance: number, minDistance?: number): void;
  78080. }
  78081. /**
  78082. * Represents a Motor-Enabled Joint
  78083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78084. */
  78085. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78086. /**
  78087. * Initializes the Motor-Enabled Joint
  78088. * @param type The type of the joint
  78089. * @param jointData The physica joint data for the joint
  78090. */
  78091. constructor(type: number, jointData: PhysicsJointData);
  78092. /**
  78093. * Set the motor values.
  78094. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78095. * @param force the force to apply
  78096. * @param maxForce max force for this motor.
  78097. */
  78098. setMotor(force?: number, maxForce?: number): void;
  78099. /**
  78100. * Set the motor's limits.
  78101. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78102. * @param upperLimit The upper limit of the motor
  78103. * @param lowerLimit The lower limit of the motor
  78104. */
  78105. setLimit(upperLimit: number, lowerLimit?: number): void;
  78106. }
  78107. /**
  78108. * This class represents a single physics Hinge-Joint
  78109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78110. */
  78111. export class HingeJoint extends MotorEnabledJoint {
  78112. /**
  78113. * Initializes the Hinge-Joint
  78114. * @param jointData The joint data for the Hinge-Joint
  78115. */
  78116. constructor(jointData: PhysicsJointData);
  78117. /**
  78118. * Set the motor values.
  78119. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78120. * @param {number} force the force to apply
  78121. * @param {number} maxForce max force for this motor.
  78122. */
  78123. setMotor(force?: number, maxForce?: number): void;
  78124. /**
  78125. * Set the motor's limits.
  78126. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78127. * @param upperLimit The upper limit of the motor
  78128. * @param lowerLimit The lower limit of the motor
  78129. */
  78130. setLimit(upperLimit: number, lowerLimit?: number): void;
  78131. }
  78132. /**
  78133. * This class represents a dual hinge physics joint (same as wheel joint)
  78134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78135. */
  78136. export class Hinge2Joint extends MotorEnabledJoint {
  78137. /**
  78138. * Initializes the Hinge2-Joint
  78139. * @param jointData The joint data for the Hinge2-Joint
  78140. */
  78141. constructor(jointData: PhysicsJointData);
  78142. /**
  78143. * Set the motor values.
  78144. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78145. * @param {number} targetSpeed the speed the motor is to reach
  78146. * @param {number} maxForce max force for this motor.
  78147. * @param {motorIndex} the motor's index, 0 or 1.
  78148. */
  78149. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78150. /**
  78151. * Set the motor limits.
  78152. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78153. * @param {number} upperLimit the upper limit
  78154. * @param {number} lowerLimit lower limit
  78155. * @param {motorIndex} the motor's index, 0 or 1.
  78156. */
  78157. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78158. }
  78159. /**
  78160. * Interface for a motor enabled joint
  78161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78162. */
  78163. export interface IMotorEnabledJoint {
  78164. /**
  78165. * Physics joint
  78166. */
  78167. physicsJoint: any;
  78168. /**
  78169. * Sets the motor of the motor-enabled joint
  78170. * @param force The force of the motor
  78171. * @param maxForce The maximum force of the motor
  78172. * @param motorIndex The index of the motor
  78173. */
  78174. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78175. /**
  78176. * Sets the limit of the motor
  78177. * @param upperLimit The upper limit of the motor
  78178. * @param lowerLimit The lower limit of the motor
  78179. * @param motorIndex The index of the motor
  78180. */
  78181. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78182. }
  78183. /**
  78184. * Joint data for a Distance-Joint
  78185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78186. */
  78187. export interface DistanceJointData extends PhysicsJointData {
  78188. /**
  78189. * Max distance the 2 joint objects can be apart
  78190. */
  78191. maxDistance: number;
  78192. }
  78193. /**
  78194. * Joint data from a spring joint
  78195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78196. */
  78197. export interface SpringJointData extends PhysicsJointData {
  78198. /**
  78199. * Length of the spring
  78200. */
  78201. length: number;
  78202. /**
  78203. * Stiffness of the spring
  78204. */
  78205. stiffness: number;
  78206. /**
  78207. * Damping of the spring
  78208. */
  78209. damping: number;
  78210. /** this callback will be called when applying the force to the impostors. */
  78211. forceApplicationCallback: () => void;
  78212. }
  78213. }
  78214. declare module BABYLON {
  78215. /**
  78216. * Holds the data for the raycast result
  78217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78218. */
  78219. export class PhysicsRaycastResult {
  78220. private _hasHit;
  78221. private _hitDistance;
  78222. private _hitNormalWorld;
  78223. private _hitPointWorld;
  78224. private _rayFromWorld;
  78225. private _rayToWorld;
  78226. /**
  78227. * Gets if there was a hit
  78228. */
  78229. readonly hasHit: boolean;
  78230. /**
  78231. * Gets the distance from the hit
  78232. */
  78233. readonly hitDistance: number;
  78234. /**
  78235. * Gets the hit normal/direction in the world
  78236. */
  78237. readonly hitNormalWorld: Vector3;
  78238. /**
  78239. * Gets the hit point in the world
  78240. */
  78241. readonly hitPointWorld: Vector3;
  78242. /**
  78243. * Gets the ray "start point" of the ray in the world
  78244. */
  78245. readonly rayFromWorld: Vector3;
  78246. /**
  78247. * Gets the ray "end point" of the ray in the world
  78248. */
  78249. readonly rayToWorld: Vector3;
  78250. /**
  78251. * Sets the hit data (normal & point in world space)
  78252. * @param hitNormalWorld defines the normal in world space
  78253. * @param hitPointWorld defines the point in world space
  78254. */
  78255. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  78256. /**
  78257. * Sets the distance from the start point to the hit point
  78258. * @param distance
  78259. */
  78260. setHitDistance(distance: number): void;
  78261. /**
  78262. * Calculates the distance manually
  78263. */
  78264. calculateHitDistance(): void;
  78265. /**
  78266. * Resets all the values to default
  78267. * @param from The from point on world space
  78268. * @param to The to point on world space
  78269. */
  78270. reset(from?: Vector3, to?: Vector3): void;
  78271. }
  78272. /**
  78273. * Interface for the size containing width and height
  78274. */
  78275. interface IXYZ {
  78276. /**
  78277. * X
  78278. */
  78279. x: number;
  78280. /**
  78281. * Y
  78282. */
  78283. y: number;
  78284. /**
  78285. * Z
  78286. */
  78287. z: number;
  78288. }
  78289. }
  78290. declare module BABYLON {
  78291. /**
  78292. * Interface used to describe a physics joint
  78293. */
  78294. export interface PhysicsImpostorJoint {
  78295. /** Defines the main impostor to which the joint is linked */
  78296. mainImpostor: PhysicsImpostor;
  78297. /** Defines the impostor that is connected to the main impostor using this joint */
  78298. connectedImpostor: PhysicsImpostor;
  78299. /** Defines the joint itself */
  78300. joint: PhysicsJoint;
  78301. }
  78302. /** @hidden */
  78303. export interface IPhysicsEnginePlugin {
  78304. world: any;
  78305. name: string;
  78306. setGravity(gravity: Vector3): void;
  78307. setTimeStep(timeStep: number): void;
  78308. getTimeStep(): number;
  78309. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  78310. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78311. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78312. generatePhysicsBody(impostor: PhysicsImpostor): void;
  78313. removePhysicsBody(impostor: PhysicsImpostor): void;
  78314. generateJoint(joint: PhysicsImpostorJoint): void;
  78315. removeJoint(joint: PhysicsImpostorJoint): void;
  78316. isSupported(): boolean;
  78317. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  78318. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  78319. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78320. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78321. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78322. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78323. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  78324. getBodyMass(impostor: PhysicsImpostor): number;
  78325. getBodyFriction(impostor: PhysicsImpostor): number;
  78326. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  78327. getBodyRestitution(impostor: PhysicsImpostor): number;
  78328. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  78329. getBodyPressure?(impostor: PhysicsImpostor): number;
  78330. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  78331. getBodyStiffness?(impostor: PhysicsImpostor): number;
  78332. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  78333. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  78334. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  78335. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  78336. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  78337. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78338. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78339. sleepBody(impostor: PhysicsImpostor): void;
  78340. wakeUpBody(impostor: PhysicsImpostor): void;
  78341. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78342. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  78343. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  78344. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78345. getRadius(impostor: PhysicsImpostor): number;
  78346. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  78347. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  78348. dispose(): void;
  78349. }
  78350. /**
  78351. * Interface used to define a physics engine
  78352. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  78353. */
  78354. export interface IPhysicsEngine {
  78355. /**
  78356. * Gets the gravity vector used by the simulation
  78357. */
  78358. gravity: Vector3;
  78359. /**
  78360. * Sets the gravity vector used by the simulation
  78361. * @param gravity defines the gravity vector to use
  78362. */
  78363. setGravity(gravity: Vector3): void;
  78364. /**
  78365. * Set the time step of the physics engine.
  78366. * Default is 1/60.
  78367. * To slow it down, enter 1/600 for example.
  78368. * To speed it up, 1/30
  78369. * @param newTimeStep the new timestep to apply to this world.
  78370. */
  78371. setTimeStep(newTimeStep: number): void;
  78372. /**
  78373. * Get the time step of the physics engine.
  78374. * @returns the current time step
  78375. */
  78376. getTimeStep(): number;
  78377. /**
  78378. * Release all resources
  78379. */
  78380. dispose(): void;
  78381. /**
  78382. * Gets the name of the current physics plugin
  78383. * @returns the name of the plugin
  78384. */
  78385. getPhysicsPluginName(): string;
  78386. /**
  78387. * Adding a new impostor for the impostor tracking.
  78388. * This will be done by the impostor itself.
  78389. * @param impostor the impostor to add
  78390. */
  78391. addImpostor(impostor: PhysicsImpostor): void;
  78392. /**
  78393. * Remove an impostor from the engine.
  78394. * This impostor and its mesh will not longer be updated by the physics engine.
  78395. * @param impostor the impostor to remove
  78396. */
  78397. removeImpostor(impostor: PhysicsImpostor): void;
  78398. /**
  78399. * Add a joint to the physics engine
  78400. * @param mainImpostor defines the main impostor to which the joint is added.
  78401. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  78402. * @param joint defines the joint that will connect both impostors.
  78403. */
  78404. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78405. /**
  78406. * Removes a joint from the simulation
  78407. * @param mainImpostor defines the impostor used with the joint
  78408. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  78409. * @param joint defines the joint to remove
  78410. */
  78411. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78412. /**
  78413. * Gets the current plugin used to run the simulation
  78414. * @returns current plugin
  78415. */
  78416. getPhysicsPlugin(): IPhysicsEnginePlugin;
  78417. /**
  78418. * Gets the list of physic impostors
  78419. * @returns an array of PhysicsImpostor
  78420. */
  78421. getImpostors(): Array<PhysicsImpostor>;
  78422. /**
  78423. * Gets the impostor for a physics enabled object
  78424. * @param object defines the object impersonated by the impostor
  78425. * @returns the PhysicsImpostor or null if not found
  78426. */
  78427. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78428. /**
  78429. * Gets the impostor for a physics body object
  78430. * @param body defines physics body used by the impostor
  78431. * @returns the PhysicsImpostor or null if not found
  78432. */
  78433. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  78434. /**
  78435. * Does a raycast in the physics world
  78436. * @param from when should the ray start?
  78437. * @param to when should the ray end?
  78438. * @returns PhysicsRaycastResult
  78439. */
  78440. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78441. /**
  78442. * Called by the scene. No need to call it.
  78443. * @param delta defines the timespam between frames
  78444. */
  78445. _step(delta: number): void;
  78446. }
  78447. }
  78448. declare module BABYLON {
  78449. /**
  78450. * The interface for the physics imposter parameters
  78451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78452. */
  78453. export interface PhysicsImpostorParameters {
  78454. /**
  78455. * The mass of the physics imposter
  78456. */
  78457. mass: number;
  78458. /**
  78459. * The friction of the physics imposter
  78460. */
  78461. friction?: number;
  78462. /**
  78463. * The coefficient of restitution of the physics imposter
  78464. */
  78465. restitution?: number;
  78466. /**
  78467. * The native options of the physics imposter
  78468. */
  78469. nativeOptions?: any;
  78470. /**
  78471. * Specifies if the parent should be ignored
  78472. */
  78473. ignoreParent?: boolean;
  78474. /**
  78475. * Specifies if bi-directional transformations should be disabled
  78476. */
  78477. disableBidirectionalTransformation?: boolean;
  78478. /**
  78479. * The pressure inside the physics imposter, soft object only
  78480. */
  78481. pressure?: number;
  78482. /**
  78483. * The stiffness the physics imposter, soft object only
  78484. */
  78485. stiffness?: number;
  78486. /**
  78487. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  78488. */
  78489. velocityIterations?: number;
  78490. /**
  78491. * The number of iterations used in maintaining consistent vertex positions, soft object only
  78492. */
  78493. positionIterations?: number;
  78494. /**
  78495. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  78496. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  78497. * Add to fix multiple points
  78498. */
  78499. fixedPoints?: number;
  78500. /**
  78501. * The collision margin around a soft object
  78502. */
  78503. margin?: number;
  78504. /**
  78505. * The collision margin around a soft object
  78506. */
  78507. damping?: number;
  78508. /**
  78509. * The path for a rope based on an extrusion
  78510. */
  78511. path?: any;
  78512. /**
  78513. * The shape of an extrusion used for a rope based on an extrusion
  78514. */
  78515. shape?: any;
  78516. }
  78517. /**
  78518. * Interface for a physics-enabled object
  78519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78520. */
  78521. export interface IPhysicsEnabledObject {
  78522. /**
  78523. * The position of the physics-enabled object
  78524. */
  78525. position: Vector3;
  78526. /**
  78527. * The rotation of the physics-enabled object
  78528. */
  78529. rotationQuaternion: Nullable<Quaternion>;
  78530. /**
  78531. * The scale of the physics-enabled object
  78532. */
  78533. scaling: Vector3;
  78534. /**
  78535. * The rotation of the physics-enabled object
  78536. */
  78537. rotation?: Vector3;
  78538. /**
  78539. * The parent of the physics-enabled object
  78540. */
  78541. parent?: any;
  78542. /**
  78543. * The bounding info of the physics-enabled object
  78544. * @returns The bounding info of the physics-enabled object
  78545. */
  78546. getBoundingInfo(): BoundingInfo;
  78547. /**
  78548. * Computes the world matrix
  78549. * @param force Specifies if the world matrix should be computed by force
  78550. * @returns A world matrix
  78551. */
  78552. computeWorldMatrix(force: boolean): Matrix;
  78553. /**
  78554. * Gets the world matrix
  78555. * @returns A world matrix
  78556. */
  78557. getWorldMatrix?(): Matrix;
  78558. /**
  78559. * Gets the child meshes
  78560. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  78561. * @returns An array of abstract meshes
  78562. */
  78563. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  78564. /**
  78565. * Gets the vertex data
  78566. * @param kind The type of vertex data
  78567. * @returns A nullable array of numbers, or a float32 array
  78568. */
  78569. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  78570. /**
  78571. * Gets the indices from the mesh
  78572. * @returns A nullable array of index arrays
  78573. */
  78574. getIndices?(): Nullable<IndicesArray>;
  78575. /**
  78576. * Gets the scene from the mesh
  78577. * @returns the indices array or null
  78578. */
  78579. getScene?(): Scene;
  78580. /**
  78581. * Gets the absolute position from the mesh
  78582. * @returns the absolute position
  78583. */
  78584. getAbsolutePosition(): Vector3;
  78585. /**
  78586. * Gets the absolute pivot point from the mesh
  78587. * @returns the absolute pivot point
  78588. */
  78589. getAbsolutePivotPoint(): Vector3;
  78590. /**
  78591. * Rotates the mesh
  78592. * @param axis The axis of rotation
  78593. * @param amount The amount of rotation
  78594. * @param space The space of the rotation
  78595. * @returns The rotation transform node
  78596. */
  78597. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78598. /**
  78599. * Translates the mesh
  78600. * @param axis The axis of translation
  78601. * @param distance The distance of translation
  78602. * @param space The space of the translation
  78603. * @returns The transform node
  78604. */
  78605. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78606. /**
  78607. * Sets the absolute position of the mesh
  78608. * @param absolutePosition The absolute position of the mesh
  78609. * @returns The transform node
  78610. */
  78611. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78612. /**
  78613. * Gets the class name of the mesh
  78614. * @returns The class name
  78615. */
  78616. getClassName(): string;
  78617. }
  78618. /**
  78619. * Represents a physics imposter
  78620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78621. */
  78622. export class PhysicsImpostor {
  78623. /**
  78624. * The physics-enabled object used as the physics imposter
  78625. */
  78626. object: IPhysicsEnabledObject;
  78627. /**
  78628. * The type of the physics imposter
  78629. */
  78630. type: number;
  78631. private _options;
  78632. private _scene?;
  78633. /**
  78634. * The default object size of the imposter
  78635. */
  78636. static DEFAULT_OBJECT_SIZE: Vector3;
  78637. /**
  78638. * The identity quaternion of the imposter
  78639. */
  78640. static IDENTITY_QUATERNION: Quaternion;
  78641. /** @hidden */
  78642. _pluginData: any;
  78643. private _physicsEngine;
  78644. private _physicsBody;
  78645. private _bodyUpdateRequired;
  78646. private _onBeforePhysicsStepCallbacks;
  78647. private _onAfterPhysicsStepCallbacks;
  78648. /** @hidden */
  78649. _onPhysicsCollideCallbacks: Array<{
  78650. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  78651. otherImpostors: Array<PhysicsImpostor>;
  78652. }>;
  78653. private _deltaPosition;
  78654. private _deltaRotation;
  78655. private _deltaRotationConjugated;
  78656. /** hidden */
  78657. _isFromLine: boolean;
  78658. private _parent;
  78659. private _isDisposed;
  78660. private static _tmpVecs;
  78661. private static _tmpQuat;
  78662. /**
  78663. * Specifies if the physics imposter is disposed
  78664. */
  78665. readonly isDisposed: boolean;
  78666. /**
  78667. * Gets the mass of the physics imposter
  78668. */
  78669. mass: number;
  78670. /**
  78671. * Gets the coefficient of friction
  78672. */
  78673. /**
  78674. * Sets the coefficient of friction
  78675. */
  78676. friction: number;
  78677. /**
  78678. * Gets the coefficient of restitution
  78679. */
  78680. /**
  78681. * Sets the coefficient of restitution
  78682. */
  78683. restitution: number;
  78684. /**
  78685. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  78686. */
  78687. /**
  78688. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  78689. */
  78690. pressure: number;
  78691. /**
  78692. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78693. */
  78694. /**
  78695. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78696. */
  78697. stiffness: number;
  78698. /**
  78699. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78700. */
  78701. /**
  78702. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78703. */
  78704. velocityIterations: number;
  78705. /**
  78706. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78707. */
  78708. /**
  78709. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78710. */
  78711. positionIterations: number;
  78712. /**
  78713. * The unique id of the physics imposter
  78714. * set by the physics engine when adding this impostor to the array
  78715. */
  78716. uniqueId: number;
  78717. /**
  78718. * @hidden
  78719. */
  78720. soft: boolean;
  78721. /**
  78722. * @hidden
  78723. */
  78724. segments: number;
  78725. private _joints;
  78726. /**
  78727. * Initializes the physics imposter
  78728. * @param object The physics-enabled object used as the physics imposter
  78729. * @param type The type of the physics imposter
  78730. * @param _options The options for the physics imposter
  78731. * @param _scene The Babylon scene
  78732. */
  78733. constructor(
  78734. /**
  78735. * The physics-enabled object used as the physics imposter
  78736. */
  78737. object: IPhysicsEnabledObject,
  78738. /**
  78739. * The type of the physics imposter
  78740. */
  78741. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  78742. /**
  78743. * This function will completly initialize this impostor.
  78744. * It will create a new body - but only if this mesh has no parent.
  78745. * If it has, this impostor will not be used other than to define the impostor
  78746. * of the child mesh.
  78747. * @hidden
  78748. */
  78749. _init(): void;
  78750. private _getPhysicsParent;
  78751. /**
  78752. * Should a new body be generated.
  78753. * @returns boolean specifying if body initialization is required
  78754. */
  78755. isBodyInitRequired(): boolean;
  78756. /**
  78757. * Sets the updated scaling
  78758. * @param updated Specifies if the scaling is updated
  78759. */
  78760. setScalingUpdated(): void;
  78761. /**
  78762. * Force a regeneration of this or the parent's impostor's body.
  78763. * Use under cautious - This will remove all joints already implemented.
  78764. */
  78765. forceUpdate(): void;
  78766. /**
  78767. * Gets the body that holds this impostor. Either its own, or its parent.
  78768. */
  78769. /**
  78770. * Set the physics body. Used mainly by the physics engine/plugin
  78771. */
  78772. physicsBody: any;
  78773. /**
  78774. * Get the parent of the physics imposter
  78775. * @returns Physics imposter or null
  78776. */
  78777. /**
  78778. * Sets the parent of the physics imposter
  78779. */
  78780. parent: Nullable<PhysicsImpostor>;
  78781. /**
  78782. * Resets the update flags
  78783. */
  78784. resetUpdateFlags(): void;
  78785. /**
  78786. * Gets the object extend size
  78787. * @returns the object extend size
  78788. */
  78789. getObjectExtendSize(): Vector3;
  78790. /**
  78791. * Gets the object center
  78792. * @returns The object center
  78793. */
  78794. getObjectCenter(): Vector3;
  78795. /**
  78796. * Get a specific parametes from the options parameter
  78797. * @param paramName The object parameter name
  78798. * @returns The object parameter
  78799. */
  78800. getParam(paramName: string): any;
  78801. /**
  78802. * Sets a specific parameter in the options given to the physics plugin
  78803. * @param paramName The parameter name
  78804. * @param value The value of the parameter
  78805. */
  78806. setParam(paramName: string, value: number): void;
  78807. /**
  78808. * Specifically change the body's mass option. Won't recreate the physics body object
  78809. * @param mass The mass of the physics imposter
  78810. */
  78811. setMass(mass: number): void;
  78812. /**
  78813. * Gets the linear velocity
  78814. * @returns linear velocity or null
  78815. */
  78816. getLinearVelocity(): Nullable<Vector3>;
  78817. /**
  78818. * Sets the linear velocity
  78819. * @param velocity linear velocity or null
  78820. */
  78821. setLinearVelocity(velocity: Nullable<Vector3>): void;
  78822. /**
  78823. * Gets the angular velocity
  78824. * @returns angular velocity or null
  78825. */
  78826. getAngularVelocity(): Nullable<Vector3>;
  78827. /**
  78828. * Sets the angular velocity
  78829. * @param velocity The velocity or null
  78830. */
  78831. setAngularVelocity(velocity: Nullable<Vector3>): void;
  78832. /**
  78833. * Execute a function with the physics plugin native code
  78834. * Provide a function the will have two variables - the world object and the physics body object
  78835. * @param func The function to execute with the physics plugin native code
  78836. */
  78837. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  78838. /**
  78839. * Register a function that will be executed before the physics world is stepping forward
  78840. * @param func The function to execute before the physics world is stepped forward
  78841. */
  78842. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78843. /**
  78844. * Unregister a function that will be executed before the physics world is stepping forward
  78845. * @param func The function to execute before the physics world is stepped forward
  78846. */
  78847. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78848. /**
  78849. * Register a function that will be executed after the physics step
  78850. * @param func The function to execute after physics step
  78851. */
  78852. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78853. /**
  78854. * Unregisters a function that will be executed after the physics step
  78855. * @param func The function to execute after physics step
  78856. */
  78857. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78858. /**
  78859. * register a function that will be executed when this impostor collides against a different body
  78860. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  78861. * @param func Callback that is executed on collision
  78862. */
  78863. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  78864. /**
  78865. * Unregisters the physics imposter on contact
  78866. * @param collideAgainst The physics object to collide against
  78867. * @param func Callback to execute on collision
  78868. */
  78869. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  78870. private _tmpQuat;
  78871. private _tmpQuat2;
  78872. /**
  78873. * Get the parent rotation
  78874. * @returns The parent rotation
  78875. */
  78876. getParentsRotation(): Quaternion;
  78877. /**
  78878. * this function is executed by the physics engine.
  78879. */
  78880. beforeStep: () => void;
  78881. /**
  78882. * this function is executed by the physics engine
  78883. */
  78884. afterStep: () => void;
  78885. /**
  78886. * Legacy collision detection event support
  78887. */
  78888. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  78889. /**
  78890. * event and body object due to cannon's event-based architecture.
  78891. */
  78892. onCollide: (e: {
  78893. body: any;
  78894. }) => void;
  78895. /**
  78896. * Apply a force
  78897. * @param force The force to apply
  78898. * @param contactPoint The contact point for the force
  78899. * @returns The physics imposter
  78900. */
  78901. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78902. /**
  78903. * Apply an impulse
  78904. * @param force The impulse force
  78905. * @param contactPoint The contact point for the impulse force
  78906. * @returns The physics imposter
  78907. */
  78908. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78909. /**
  78910. * A help function to create a joint
  78911. * @param otherImpostor A physics imposter used to create a joint
  78912. * @param jointType The type of joint
  78913. * @param jointData The data for the joint
  78914. * @returns The physics imposter
  78915. */
  78916. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  78917. /**
  78918. * Add a joint to this impostor with a different impostor
  78919. * @param otherImpostor A physics imposter used to add a joint
  78920. * @param joint The joint to add
  78921. * @returns The physics imposter
  78922. */
  78923. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  78924. /**
  78925. * Add an anchor to a cloth impostor
  78926. * @param otherImpostor rigid impostor to anchor to
  78927. * @param width ratio across width from 0 to 1
  78928. * @param height ratio up height from 0 to 1
  78929. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  78930. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  78931. * @returns impostor the soft imposter
  78932. */
  78933. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  78934. /**
  78935. * Add a hook to a rope impostor
  78936. * @param otherImpostor rigid impostor to anchor to
  78937. * @param length ratio across rope from 0 to 1
  78938. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  78939. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  78940. * @returns impostor the rope imposter
  78941. */
  78942. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  78943. /**
  78944. * Will keep this body still, in a sleep mode.
  78945. * @returns the physics imposter
  78946. */
  78947. sleep(): PhysicsImpostor;
  78948. /**
  78949. * Wake the body up.
  78950. * @returns The physics imposter
  78951. */
  78952. wakeUp(): PhysicsImpostor;
  78953. /**
  78954. * Clones the physics imposter
  78955. * @param newObject The physics imposter clones to this physics-enabled object
  78956. * @returns A nullable physics imposter
  78957. */
  78958. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78959. /**
  78960. * Disposes the physics imposter
  78961. */
  78962. dispose(): void;
  78963. /**
  78964. * Sets the delta position
  78965. * @param position The delta position amount
  78966. */
  78967. setDeltaPosition(position: Vector3): void;
  78968. /**
  78969. * Sets the delta rotation
  78970. * @param rotation The delta rotation amount
  78971. */
  78972. setDeltaRotation(rotation: Quaternion): void;
  78973. /**
  78974. * Gets the box size of the physics imposter and stores the result in the input parameter
  78975. * @param result Stores the box size
  78976. * @returns The physics imposter
  78977. */
  78978. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  78979. /**
  78980. * Gets the radius of the physics imposter
  78981. * @returns Radius of the physics imposter
  78982. */
  78983. getRadius(): number;
  78984. /**
  78985. * Sync a bone with this impostor
  78986. * @param bone The bone to sync to the impostor.
  78987. * @param boneMesh The mesh that the bone is influencing.
  78988. * @param jointPivot The pivot of the joint / bone in local space.
  78989. * @param distToJoint Optional distance from the impostor to the joint.
  78990. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78991. */
  78992. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  78993. /**
  78994. * Sync impostor to a bone
  78995. * @param bone The bone that the impostor will be synced to.
  78996. * @param boneMesh The mesh that the bone is influencing.
  78997. * @param jointPivot The pivot of the joint / bone in local space.
  78998. * @param distToJoint Optional distance from the impostor to the joint.
  78999. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79000. * @param boneAxis Optional vector3 axis the bone is aligned with
  79001. */
  79002. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  79003. /**
  79004. * No-Imposter type
  79005. */
  79006. static NoImpostor: number;
  79007. /**
  79008. * Sphere-Imposter type
  79009. */
  79010. static SphereImpostor: number;
  79011. /**
  79012. * Box-Imposter type
  79013. */
  79014. static BoxImpostor: number;
  79015. /**
  79016. * Plane-Imposter type
  79017. */
  79018. static PlaneImpostor: number;
  79019. /**
  79020. * Mesh-imposter type
  79021. */
  79022. static MeshImpostor: number;
  79023. /**
  79024. * Cylinder-Imposter type
  79025. */
  79026. static CylinderImpostor: number;
  79027. /**
  79028. * Particle-Imposter type
  79029. */
  79030. static ParticleImpostor: number;
  79031. /**
  79032. * Heightmap-Imposter type
  79033. */
  79034. static HeightmapImpostor: number;
  79035. /**
  79036. * ConvexHull-Impostor type (Ammo.js plugin only)
  79037. */
  79038. static ConvexHullImpostor: number;
  79039. /**
  79040. * Rope-Imposter type
  79041. */
  79042. static RopeImpostor: number;
  79043. /**
  79044. * Cloth-Imposter type
  79045. */
  79046. static ClothImpostor: number;
  79047. /**
  79048. * Softbody-Imposter type
  79049. */
  79050. static SoftbodyImpostor: number;
  79051. }
  79052. }
  79053. declare module BABYLON {
  79054. /**
  79055. * Class used to represent a specific level of detail of a mesh
  79056. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79057. */
  79058. export class MeshLODLevel {
  79059. /** Defines the distance where this level should star being displayed */
  79060. distance: number;
  79061. /** Defines the mesh to use to render this level */
  79062. mesh: Nullable<Mesh>;
  79063. /**
  79064. * Creates a new LOD level
  79065. * @param distance defines the distance where this level should star being displayed
  79066. * @param mesh defines the mesh to use to render this level
  79067. */
  79068. constructor(
  79069. /** Defines the distance where this level should star being displayed */
  79070. distance: number,
  79071. /** Defines the mesh to use to render this level */
  79072. mesh: Nullable<Mesh>);
  79073. }
  79074. /**
  79075. * @hidden
  79076. **/
  79077. export class _CreationDataStorage {
  79078. closePath?: boolean;
  79079. closeArray?: boolean;
  79080. idx: number[];
  79081. dashSize: number;
  79082. gapSize: number;
  79083. path3D: Path3D;
  79084. pathArray: Vector3[][];
  79085. arc: number;
  79086. radius: number;
  79087. cap: number;
  79088. tessellation: number;
  79089. }
  79090. /**
  79091. * @hidden
  79092. **/
  79093. class _InstanceDataStorage {
  79094. visibleInstances: any;
  79095. renderIdForInstances: number[];
  79096. batchCache: _InstancesBatch;
  79097. instancesBufferSize: number;
  79098. instancesBuffer: Nullable<Buffer>;
  79099. instancesData: Float32Array;
  79100. overridenInstanceCount: number;
  79101. }
  79102. /**
  79103. * @hidden
  79104. **/
  79105. export class _InstancesBatch {
  79106. mustReturn: boolean;
  79107. visibleInstances: Nullable<InstancedMesh[]>[];
  79108. renderSelf: boolean[];
  79109. }
  79110. /**
  79111. * Class used to represent renderable models
  79112. */
  79113. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79114. /**
  79115. * Mesh side orientation : usually the external or front surface
  79116. */
  79117. static readonly FRONTSIDE: number;
  79118. /**
  79119. * Mesh side orientation : usually the internal or back surface
  79120. */
  79121. static readonly BACKSIDE: number;
  79122. /**
  79123. * Mesh side orientation : both internal and external or front and back surfaces
  79124. */
  79125. static readonly DOUBLESIDE: number;
  79126. /**
  79127. * Mesh side orientation : by default, `FRONTSIDE`
  79128. */
  79129. static readonly DEFAULTSIDE: number;
  79130. /**
  79131. * Mesh cap setting : no cap
  79132. */
  79133. static readonly NO_CAP: number;
  79134. /**
  79135. * Mesh cap setting : one cap at the beginning of the mesh
  79136. */
  79137. static readonly CAP_START: number;
  79138. /**
  79139. * Mesh cap setting : one cap at the end of the mesh
  79140. */
  79141. static readonly CAP_END: number;
  79142. /**
  79143. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79144. */
  79145. static readonly CAP_ALL: number;
  79146. /**
  79147. * Gets the default side orientation.
  79148. * @param orientation the orientation to value to attempt to get
  79149. * @returns the default orientation
  79150. * @hidden
  79151. */
  79152. static _GetDefaultSideOrientation(orientation?: number): number;
  79153. private _onBeforeRenderObservable;
  79154. private _onBeforeBindObservable;
  79155. private _onAfterRenderObservable;
  79156. private _onBeforeDrawObservable;
  79157. /**
  79158. * An event triggered before rendering the mesh
  79159. */
  79160. readonly onBeforeRenderObservable: Observable<Mesh>;
  79161. /**
  79162. * An event triggered before binding the mesh
  79163. */
  79164. readonly onBeforeBindObservable: Observable<Mesh>;
  79165. /**
  79166. * An event triggered after rendering the mesh
  79167. */
  79168. readonly onAfterRenderObservable: Observable<Mesh>;
  79169. /**
  79170. * An event triggered before drawing the mesh
  79171. */
  79172. readonly onBeforeDrawObservable: Observable<Mesh>;
  79173. private _onBeforeDrawObserver;
  79174. /**
  79175. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79176. */
  79177. onBeforeDraw: () => void;
  79178. /**
  79179. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79180. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79181. */
  79182. delayLoadState: number;
  79183. /**
  79184. * Gets the list of instances created from this mesh
  79185. * it is not supposed to be modified manually.
  79186. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79187. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79188. */
  79189. instances: InstancedMesh[];
  79190. /**
  79191. * Gets the file containing delay loading data for this mesh
  79192. */
  79193. delayLoadingFile: string;
  79194. /** @hidden */
  79195. _binaryInfo: any;
  79196. private _LODLevels;
  79197. /**
  79198. * User defined function used to change how LOD level selection is done
  79199. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79200. */
  79201. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79202. private _morphTargetManager;
  79203. /**
  79204. * Gets or sets the morph target manager
  79205. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79206. */
  79207. morphTargetManager: Nullable<MorphTargetManager>;
  79208. /** @hidden */
  79209. _creationDataStorage: Nullable<_CreationDataStorage>;
  79210. /** @hidden */
  79211. _geometry: Nullable<Geometry>;
  79212. /** @hidden */
  79213. _delayInfo: Array<string>;
  79214. /** @hidden */
  79215. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79216. /** @hidden */
  79217. _instanceDataStorage: _InstanceDataStorage;
  79218. private _effectiveMaterial;
  79219. /** @hidden */
  79220. _shouldGenerateFlatShading: boolean;
  79221. private _preActivateId;
  79222. /** @hidden */
  79223. _originalBuilderSideOrientation: number;
  79224. /**
  79225. * Use this property to change the original side orientation defined at construction time
  79226. */
  79227. overrideMaterialSideOrientation: Nullable<number>;
  79228. private _areNormalsFrozen;
  79229. private _sourcePositions;
  79230. private _sourceNormals;
  79231. private _source;
  79232. private meshMap;
  79233. /**
  79234. * Gets the source mesh (the one used to clone this one from)
  79235. */
  79236. readonly source: Nullable<Mesh>;
  79237. /**
  79238. * Gets or sets a boolean indicating that this mesh does not use index buffer
  79239. */
  79240. isUnIndexed: boolean;
  79241. /**
  79242. * @constructor
  79243. * @param name The value used by scene.getMeshByName() to do a lookup.
  79244. * @param scene The scene to add this mesh to.
  79245. * @param parent The parent of this mesh, if it has one
  79246. * @param source An optional Mesh from which geometry is shared, cloned.
  79247. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79248. * When false, achieved by calling a clone(), also passing False.
  79249. * This will make creation of children, recursive.
  79250. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  79251. */
  79252. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  79253. /**
  79254. * Gets the class name
  79255. * @returns the string "Mesh".
  79256. */
  79257. getClassName(): string;
  79258. /** @hidden */
  79259. readonly _isMesh: boolean;
  79260. /**
  79261. * Returns a description of this mesh
  79262. * @param fullDetails define if full details about this mesh must be used
  79263. * @returns a descriptive string representing this mesh
  79264. */
  79265. toString(fullDetails?: boolean): string;
  79266. /** @hidden */
  79267. _unBindEffect(): void;
  79268. /**
  79269. * Gets a boolean indicating if this mesh has LOD
  79270. */
  79271. readonly hasLODLevels: boolean;
  79272. /**
  79273. * Gets the list of MeshLODLevel associated with the current mesh
  79274. * @returns an array of MeshLODLevel
  79275. */
  79276. getLODLevels(): MeshLODLevel[];
  79277. private _sortLODLevels;
  79278. /**
  79279. * Add a mesh as LOD level triggered at the given distance.
  79280. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79281. * @param distance The distance from the center of the object to show this level
  79282. * @param mesh The mesh to be added as LOD level (can be null)
  79283. * @return This mesh (for chaining)
  79284. */
  79285. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  79286. /**
  79287. * Returns the LOD level mesh at the passed distance or null if not found.
  79288. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79289. * @param distance The distance from the center of the object to show this level
  79290. * @returns a Mesh or `null`
  79291. */
  79292. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  79293. /**
  79294. * Remove a mesh from the LOD array
  79295. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79296. * @param mesh defines the mesh to be removed
  79297. * @return This mesh (for chaining)
  79298. */
  79299. removeLODLevel(mesh: Mesh): Mesh;
  79300. /**
  79301. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  79302. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79303. * @param camera defines the camera to use to compute distance
  79304. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  79305. * @return This mesh (for chaining)
  79306. */
  79307. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  79308. /**
  79309. * Gets the mesh internal Geometry object
  79310. */
  79311. readonly geometry: Nullable<Geometry>;
  79312. /**
  79313. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  79314. * @returns the total number of vertices
  79315. */
  79316. getTotalVertices(): number;
  79317. /**
  79318. * Returns the content of an associated vertex buffer
  79319. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79320. * - VertexBuffer.PositionKind
  79321. * - VertexBuffer.UVKind
  79322. * - VertexBuffer.UV2Kind
  79323. * - VertexBuffer.UV3Kind
  79324. * - VertexBuffer.UV4Kind
  79325. * - VertexBuffer.UV5Kind
  79326. * - VertexBuffer.UV6Kind
  79327. * - VertexBuffer.ColorKind
  79328. * - VertexBuffer.MatricesIndicesKind
  79329. * - VertexBuffer.MatricesIndicesExtraKind
  79330. * - VertexBuffer.MatricesWeightsKind
  79331. * - VertexBuffer.MatricesWeightsExtraKind
  79332. * @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
  79333. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  79334. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  79335. */
  79336. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79337. /**
  79338. * Returns the mesh VertexBuffer object from the requested `kind`
  79339. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79340. * - VertexBuffer.PositionKind
  79341. * - VertexBuffer.UVKind
  79342. * - VertexBuffer.UV2Kind
  79343. * - VertexBuffer.UV3Kind
  79344. * - VertexBuffer.UV4Kind
  79345. * - VertexBuffer.UV5Kind
  79346. * - VertexBuffer.UV6Kind
  79347. * - VertexBuffer.ColorKind
  79348. * - VertexBuffer.MatricesIndicesKind
  79349. * - VertexBuffer.MatricesIndicesExtraKind
  79350. * - VertexBuffer.MatricesWeightsKind
  79351. * - VertexBuffer.MatricesWeightsExtraKind
  79352. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  79353. */
  79354. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79355. /**
  79356. * Tests if a specific vertex buffer is associated with this mesh
  79357. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79358. * - VertexBuffer.PositionKind
  79359. * - VertexBuffer.UVKind
  79360. * - VertexBuffer.UV2Kind
  79361. * - VertexBuffer.UV3Kind
  79362. * - VertexBuffer.UV4Kind
  79363. * - VertexBuffer.UV5Kind
  79364. * - VertexBuffer.UV6Kind
  79365. * - VertexBuffer.ColorKind
  79366. * - VertexBuffer.MatricesIndicesKind
  79367. * - VertexBuffer.MatricesIndicesExtraKind
  79368. * - VertexBuffer.MatricesWeightsKind
  79369. * - VertexBuffer.MatricesWeightsExtraKind
  79370. * @returns a boolean
  79371. */
  79372. isVerticesDataPresent(kind: string): boolean;
  79373. /**
  79374. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  79375. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79376. * - VertexBuffer.PositionKind
  79377. * - VertexBuffer.UVKind
  79378. * - VertexBuffer.UV2Kind
  79379. * - VertexBuffer.UV3Kind
  79380. * - VertexBuffer.UV4Kind
  79381. * - VertexBuffer.UV5Kind
  79382. * - VertexBuffer.UV6Kind
  79383. * - VertexBuffer.ColorKind
  79384. * - VertexBuffer.MatricesIndicesKind
  79385. * - VertexBuffer.MatricesIndicesExtraKind
  79386. * - VertexBuffer.MatricesWeightsKind
  79387. * - VertexBuffer.MatricesWeightsExtraKind
  79388. * @returns a boolean
  79389. */
  79390. isVertexBufferUpdatable(kind: string): boolean;
  79391. /**
  79392. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  79393. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79394. * - VertexBuffer.PositionKind
  79395. * - VertexBuffer.UVKind
  79396. * - VertexBuffer.UV2Kind
  79397. * - VertexBuffer.UV3Kind
  79398. * - VertexBuffer.UV4Kind
  79399. * - VertexBuffer.UV5Kind
  79400. * - VertexBuffer.UV6Kind
  79401. * - VertexBuffer.ColorKind
  79402. * - VertexBuffer.MatricesIndicesKind
  79403. * - VertexBuffer.MatricesIndicesExtraKind
  79404. * - VertexBuffer.MatricesWeightsKind
  79405. * - VertexBuffer.MatricesWeightsExtraKind
  79406. * @returns an array of strings
  79407. */
  79408. getVerticesDataKinds(): string[];
  79409. /**
  79410. * Returns a positive integer : the total number of indices in this mesh geometry.
  79411. * @returns the numner of indices or zero if the mesh has no geometry.
  79412. */
  79413. getTotalIndices(): number;
  79414. /**
  79415. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79416. * @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.
  79417. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79418. * @returns the indices array or an empty array if the mesh has no geometry
  79419. */
  79420. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79421. readonly isBlocked: boolean;
  79422. /**
  79423. * Determine if the current mesh is ready to be rendered
  79424. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79425. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  79426. * @returns true if all associated assets are ready (material, textures, shaders)
  79427. */
  79428. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  79429. /**
  79430. * 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.
  79431. */
  79432. readonly areNormalsFrozen: boolean;
  79433. /**
  79434. * 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.
  79435. * @returns the current mesh
  79436. */
  79437. freezeNormals(): Mesh;
  79438. /**
  79439. * 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
  79440. * @returns the current mesh
  79441. */
  79442. unfreezeNormals(): Mesh;
  79443. /**
  79444. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  79445. */
  79446. overridenInstanceCount: number;
  79447. /** @hidden */
  79448. _preActivate(): Mesh;
  79449. /** @hidden */
  79450. _preActivateForIntermediateRendering(renderId: number): Mesh;
  79451. /** @hidden */
  79452. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  79453. /**
  79454. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79455. * This means the mesh underlying bounding box and sphere are recomputed.
  79456. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79457. * @returns the current mesh
  79458. */
  79459. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  79460. /** @hidden */
  79461. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  79462. /**
  79463. * This function will subdivide the mesh into multiple submeshes
  79464. * @param count defines the expected number of submeshes
  79465. */
  79466. subdivide(count: number): void;
  79467. /**
  79468. * Copy a FloatArray into a specific associated vertex buffer
  79469. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79470. * - VertexBuffer.PositionKind
  79471. * - VertexBuffer.UVKind
  79472. * - VertexBuffer.UV2Kind
  79473. * - VertexBuffer.UV3Kind
  79474. * - VertexBuffer.UV4Kind
  79475. * - VertexBuffer.UV5Kind
  79476. * - VertexBuffer.UV6Kind
  79477. * - VertexBuffer.ColorKind
  79478. * - VertexBuffer.MatricesIndicesKind
  79479. * - VertexBuffer.MatricesIndicesExtraKind
  79480. * - VertexBuffer.MatricesWeightsKind
  79481. * - VertexBuffer.MatricesWeightsExtraKind
  79482. * @param data defines the data source
  79483. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79484. * @param stride defines the data stride size (can be null)
  79485. * @returns the current mesh
  79486. */
  79487. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79488. /**
  79489. * Flags an associated vertex buffer as updatable
  79490. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  79491. * - VertexBuffer.PositionKind
  79492. * - VertexBuffer.UVKind
  79493. * - VertexBuffer.UV2Kind
  79494. * - VertexBuffer.UV3Kind
  79495. * - VertexBuffer.UV4Kind
  79496. * - VertexBuffer.UV5Kind
  79497. * - VertexBuffer.UV6Kind
  79498. * - VertexBuffer.ColorKind
  79499. * - VertexBuffer.MatricesIndicesKind
  79500. * - VertexBuffer.MatricesIndicesExtraKind
  79501. * - VertexBuffer.MatricesWeightsKind
  79502. * - VertexBuffer.MatricesWeightsExtraKind
  79503. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79504. */
  79505. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  79506. /**
  79507. * Sets the mesh global Vertex Buffer
  79508. * @param buffer defines the buffer to use
  79509. * @returns the current mesh
  79510. */
  79511. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  79512. /**
  79513. * Update a specific associated vertex buffer
  79514. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79515. * - VertexBuffer.PositionKind
  79516. * - VertexBuffer.UVKind
  79517. * - VertexBuffer.UV2Kind
  79518. * - VertexBuffer.UV3Kind
  79519. * - VertexBuffer.UV4Kind
  79520. * - VertexBuffer.UV5Kind
  79521. * - VertexBuffer.UV6Kind
  79522. * - VertexBuffer.ColorKind
  79523. * - VertexBuffer.MatricesIndicesKind
  79524. * - VertexBuffer.MatricesIndicesExtraKind
  79525. * - VertexBuffer.MatricesWeightsKind
  79526. * - VertexBuffer.MatricesWeightsExtraKind
  79527. * @param data defines the data source
  79528. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79529. * @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)
  79530. * @returns the current mesh
  79531. */
  79532. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79533. /**
  79534. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  79535. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  79536. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  79537. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  79538. * @returns the current mesh
  79539. */
  79540. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  79541. /**
  79542. * Creates a un-shared specific occurence of the geometry for the mesh.
  79543. * @returns the current mesh
  79544. */
  79545. makeGeometryUnique(): Mesh;
  79546. /**
  79547. * Set the index buffer of this mesh
  79548. * @param indices defines the source data
  79549. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  79550. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  79551. * @returns the current mesh
  79552. */
  79553. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  79554. /**
  79555. * Update the current index buffer
  79556. * @param indices defines the source data
  79557. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  79558. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  79559. * @returns the current mesh
  79560. */
  79561. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  79562. /**
  79563. * Invert the geometry to move from a right handed system to a left handed one.
  79564. * @returns the current mesh
  79565. */
  79566. toLeftHanded(): Mesh;
  79567. /** @hidden */
  79568. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  79569. /** @hidden */
  79570. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  79571. /**
  79572. * Registers for this mesh a javascript function called just before the rendering process
  79573. * @param func defines the function to call before rendering this mesh
  79574. * @returns the current mesh
  79575. */
  79576. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79577. /**
  79578. * Disposes a previously registered javascript function called before the rendering
  79579. * @param func defines the function to remove
  79580. * @returns the current mesh
  79581. */
  79582. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79583. /**
  79584. * Registers for this mesh a javascript function called just after the rendering is complete
  79585. * @param func defines the function to call after rendering this mesh
  79586. * @returns the current mesh
  79587. */
  79588. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79589. /**
  79590. * Disposes a previously registered javascript function called after the rendering.
  79591. * @param func defines the function to remove
  79592. * @returns the current mesh
  79593. */
  79594. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79595. /** @hidden */
  79596. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  79597. /** @hidden */
  79598. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  79599. /** @hidden */
  79600. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  79601. /**
  79602. * 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
  79603. * @param subMesh defines the subMesh to render
  79604. * @param enableAlphaMode defines if alpha mode can be changed
  79605. * @returns the current mesh
  79606. */
  79607. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  79608. private _onBeforeDraw;
  79609. /**
  79610. * Renormalize the mesh and patch it up if there are no weights
  79611. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  79612. * However in the case of zero weights then we set just a single influence to 1.
  79613. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  79614. */
  79615. cleanMatrixWeights(): void;
  79616. private normalizeSkinFourWeights;
  79617. private normalizeSkinWeightsAndExtra;
  79618. /**
  79619. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  79620. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  79621. * the user know there was an issue with importing the mesh
  79622. * @returns a validation object with skinned, valid and report string
  79623. */
  79624. validateSkinning(): {
  79625. skinned: boolean;
  79626. valid: boolean;
  79627. report: string;
  79628. };
  79629. /** @hidden */
  79630. _checkDelayState(): Mesh;
  79631. private _queueLoad;
  79632. /**
  79633. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79634. * A mesh is in the frustum if its bounding box intersects the frustum
  79635. * @param frustumPlanes defines the frustum to test
  79636. * @returns true if the mesh is in the frustum planes
  79637. */
  79638. isInFrustum(frustumPlanes: Plane[]): boolean;
  79639. /**
  79640. * Sets the mesh material by the material or multiMaterial `id` property
  79641. * @param id is a string identifying the material or the multiMaterial
  79642. * @returns the current mesh
  79643. */
  79644. setMaterialByID(id: string): Mesh;
  79645. /**
  79646. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  79647. * @returns an array of IAnimatable
  79648. */
  79649. getAnimatables(): IAnimatable[];
  79650. /**
  79651. * Modifies the mesh geometry according to the passed transformation matrix.
  79652. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  79653. * The mesh normals are modified using the same transformation.
  79654. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79655. * @param transform defines the transform matrix to use
  79656. * @see http://doc.babylonjs.com/resources/baking_transformations
  79657. * @returns the current mesh
  79658. */
  79659. bakeTransformIntoVertices(transform: Matrix): Mesh;
  79660. /**
  79661. * Modifies the mesh geometry according to its own current World Matrix.
  79662. * The mesh World Matrix is then reset.
  79663. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  79664. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79665. * @see http://doc.babylonjs.com/resources/baking_transformations
  79666. * @returns the current mesh
  79667. */
  79668. bakeCurrentTransformIntoVertices(): Mesh;
  79669. /** @hidden */
  79670. readonly _positions: Nullable<Vector3[]>;
  79671. /** @hidden */
  79672. _resetPointsArrayCache(): Mesh;
  79673. /** @hidden */
  79674. _generatePointsArray(): boolean;
  79675. /**
  79676. * Returns a new Mesh object generated from the current mesh properties.
  79677. * This method must not get confused with createInstance()
  79678. * @param name is a string, the name given to the new mesh
  79679. * @param newParent can be any Node object (default `null`)
  79680. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  79681. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  79682. * @returns a new mesh
  79683. */
  79684. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  79685. /**
  79686. * Releases resources associated with this mesh.
  79687. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79688. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79689. */
  79690. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79691. /**
  79692. * Modifies the mesh geometry according to a displacement map.
  79693. * 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.
  79694. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79695. * @param url is a string, the URL from the image file is to be downloaded.
  79696. * @param minHeight is the lower limit of the displacement.
  79697. * @param maxHeight is the upper limit of the displacement.
  79698. * @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.
  79699. * @param uvOffset is an optional vector2 used to offset UV.
  79700. * @param uvScale is an optional vector2 used to scale UV.
  79701. * @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.
  79702. * @returns the Mesh.
  79703. */
  79704. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79705. /**
  79706. * Modifies the mesh geometry according to a displacementMap buffer.
  79707. * 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.
  79708. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79709. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  79710. * @param heightMapWidth is the width of the buffer image.
  79711. * @param heightMapHeight is the height of the buffer image.
  79712. * @param minHeight is the lower limit of the displacement.
  79713. * @param maxHeight is the upper limit of the displacement.
  79714. * @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.
  79715. * @param uvOffset is an optional vector2 used to offset UV.
  79716. * @param uvScale is an optional vector2 used to scale UV.
  79717. * @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.
  79718. * @returns the Mesh.
  79719. */
  79720. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79721. /**
  79722. * Modify the mesh to get a flat shading rendering.
  79723. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  79724. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  79725. * @returns current mesh
  79726. */
  79727. convertToFlatShadedMesh(): Mesh;
  79728. /**
  79729. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  79730. * In other words, more vertices, no more indices and a single bigger VBO.
  79731. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  79732. * @returns current mesh
  79733. */
  79734. convertToUnIndexedMesh(): Mesh;
  79735. /**
  79736. * Inverses facet orientations.
  79737. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79738. * @param flipNormals will also inverts the normals
  79739. * @returns current mesh
  79740. */
  79741. flipFaces(flipNormals?: boolean): Mesh;
  79742. /**
  79743. * Increase the number of facets and hence vertices in a mesh
  79744. * Vertex normals are interpolated from existing vertex normals
  79745. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79746. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  79747. */
  79748. increaseVertices(numberPerEdge: number): void;
  79749. /**
  79750. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  79751. * This will undo any application of covertToFlatShadedMesh
  79752. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79753. */
  79754. forceSharedVertices(): void;
  79755. /** @hidden */
  79756. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  79757. /** @hidden */
  79758. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  79759. /**
  79760. * Creates a new InstancedMesh object from the mesh model.
  79761. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79762. * @param name defines the name of the new instance
  79763. * @returns a new InstancedMesh
  79764. */
  79765. createInstance(name: string): InstancedMesh;
  79766. /**
  79767. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  79768. * After this call, all the mesh instances have the same submeshes than the current mesh.
  79769. * @returns the current mesh
  79770. */
  79771. synchronizeInstances(): Mesh;
  79772. /**
  79773. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  79774. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  79775. * This should be used together with the simplification to avoid disappearing triangles.
  79776. * @param successCallback an optional success callback to be called after the optimization finished.
  79777. * @returns the current mesh
  79778. */
  79779. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  79780. /**
  79781. * Serialize current mesh
  79782. * @param serializationObject defines the object which will receive the serialization data
  79783. */
  79784. serialize(serializationObject: any): void;
  79785. /** @hidden */
  79786. _syncGeometryWithMorphTargetManager(): void;
  79787. /** @hidden */
  79788. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  79789. /**
  79790. * Returns a new Mesh object parsed from the source provided.
  79791. * @param parsedMesh is the source
  79792. * @param scene defines the hosting scene
  79793. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  79794. * @returns a new Mesh
  79795. */
  79796. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  79797. /**
  79798. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  79799. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79800. * @param name defines the name of the mesh to create
  79801. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  79802. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  79803. * @param closePath creates a seam between the first and the last points of each path of the path array
  79804. * @param offset is taken in account only if the `pathArray` is containing a single path
  79805. * @param scene defines the hosting scene
  79806. * @param updatable defines if the mesh must be flagged as updatable
  79807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79808. * @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)
  79809. * @returns a new Mesh
  79810. */
  79811. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79812. /**
  79813. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  79814. * @param name defines the name of the mesh to create
  79815. * @param radius sets the radius size (float) of the polygon (default 0.5)
  79816. * @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
  79817. * @param scene defines the hosting scene
  79818. * @param updatable defines if the mesh must be flagged as updatable
  79819. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79820. * @returns a new Mesh
  79821. */
  79822. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79823. /**
  79824. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  79825. * @param name defines the name of the mesh to create
  79826. * @param size sets the size (float) of each box side (default 1)
  79827. * @param scene defines the hosting scene
  79828. * @param updatable defines if the mesh must be flagged as updatable
  79829. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79830. * @returns a new Mesh
  79831. */
  79832. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79833. /**
  79834. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  79835. * @param name defines the name of the mesh to create
  79836. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  79837. * @param diameter sets the diameter size (float) of the sphere (default 1)
  79838. * @param scene defines the hosting scene
  79839. * @param updatable defines if the mesh must be flagged as updatable
  79840. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79841. * @returns a new Mesh
  79842. */
  79843. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79844. /**
  79845. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  79846. * @param name defines the name of the mesh to create
  79847. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  79848. * @param diameterTop set the top cap diameter (floats, default 1)
  79849. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  79850. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  79851. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  79852. * @param scene defines the hosting scene
  79853. * @param updatable defines if the mesh must be flagged as updatable
  79854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79855. * @returns a new Mesh
  79856. */
  79857. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  79858. /**
  79859. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  79860. * @param name defines the name of the mesh to create
  79861. * @param diameter sets the diameter size (float) of the torus (default 1)
  79862. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  79863. * @param tessellation sets the number of torus sides (postive integer, default 16)
  79864. * @param scene defines the hosting scene
  79865. * @param updatable defines if the mesh must be flagged as updatable
  79866. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79867. * @returns a new Mesh
  79868. */
  79869. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79870. /**
  79871. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  79872. * @param name defines the name of the mesh to create
  79873. * @param radius sets the global radius size (float) of the torus knot (default 2)
  79874. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  79875. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  79876. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  79877. * @param p the number of windings on X axis (positive integers, default 2)
  79878. * @param q the number of windings on Y axis (positive integers, default 3)
  79879. * @param scene defines the hosting scene
  79880. * @param updatable defines if the mesh must be flagged as updatable
  79881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79882. * @returns a new Mesh
  79883. */
  79884. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79885. /**
  79886. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  79887. * @param name defines the name of the mesh to create
  79888. * @param points is an array successive Vector3
  79889. * @param scene defines the hosting scene
  79890. * @param updatable defines if the mesh must be flagged as updatable
  79891. * @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).
  79892. * @returns a new Mesh
  79893. */
  79894. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  79895. /**
  79896. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  79897. * @param name defines the name of the mesh to create
  79898. * @param points is an array successive Vector3
  79899. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  79900. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79901. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  79902. * @param scene defines the hosting scene
  79903. * @param updatable defines if the mesh must be flagged as updatable
  79904. * @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)
  79905. * @returns a new Mesh
  79906. */
  79907. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  79908. /**
  79909. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  79910. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  79911. * 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.
  79912. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79913. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79914. * Remember you can only change the shape positions, not their number when updating a polygon.
  79915. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  79916. * @param name defines the name of the mesh to create
  79917. * @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
  79918. * @param scene defines the hosting scene
  79919. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79920. * @param updatable defines if the mesh must be flagged as updatable
  79921. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79922. * @param earcutInjection can be used to inject your own earcut reference
  79923. * @returns a new Mesh
  79924. */
  79925. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79926. /**
  79927. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  79928. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  79929. * @param name defines the name of the mesh to create
  79930. * @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
  79931. * @param depth defines the height of extrusion
  79932. * @param scene defines the hosting scene
  79933. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79934. * @param updatable defines if the mesh must be flagged as updatable
  79935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79936. * @param earcutInjection can be used to inject your own earcut reference
  79937. * @returns a new Mesh
  79938. */
  79939. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79940. /**
  79941. * Creates an extruded shape mesh.
  79942. * 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
  79943. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79944. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79945. * @param name defines the name of the mesh to create
  79946. * @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
  79947. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79948. * @param scale is the value to scale the shape
  79949. * @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
  79950. * @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
  79951. * @param scene defines the hosting scene
  79952. * @param updatable defines if the mesh must be flagged as updatable
  79953. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79954. * @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)
  79955. * @returns a new Mesh
  79956. */
  79957. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79958. /**
  79959. * Creates an custom extruded shape mesh.
  79960. * The custom extrusion is a parametric shape.
  79961. * It has no predefined shape. Its final shape will depend on the input parameters.
  79962. * Please consider using the same method from the MeshBuilder class instead
  79963. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79964. * @param name defines the name of the mesh to create
  79965. * @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
  79966. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79967. * @param scaleFunction is a custom Javascript function called on each path point
  79968. * @param rotationFunction is a custom Javascript function called on each path point
  79969. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79970. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  79971. * @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
  79972. * @param scene defines the hosting scene
  79973. * @param updatable defines if the mesh must be flagged as updatable
  79974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79975. * @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)
  79976. * @returns a new Mesh
  79977. */
  79978. 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;
  79979. /**
  79980. * Creates lathe mesh.
  79981. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  79982. * Please consider using the same method from the MeshBuilder class instead
  79983. * @param name defines the name of the mesh to create
  79984. * @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
  79985. * @param radius is the radius value of the lathe
  79986. * @param tessellation is the side number of the lathe.
  79987. * @param scene defines the hosting scene
  79988. * @param updatable defines if the mesh must be flagged as updatable
  79989. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79990. * @returns a new Mesh
  79991. */
  79992. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79993. /**
  79994. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  79995. * @param name defines the name of the mesh to create
  79996. * @param size sets the size (float) of both sides of the plane at once (default 1)
  79997. * @param scene defines the hosting scene
  79998. * @param updatable defines if the mesh must be flagged as updatable
  79999. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80000. * @returns a new Mesh
  80001. */
  80002. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80003. /**
  80004. * Creates a ground mesh.
  80005. * Please consider using the same method from the MeshBuilder class instead
  80006. * @param name defines the name of the mesh to create
  80007. * @param width set the width of the ground
  80008. * @param height set the height of the ground
  80009. * @param subdivisions sets the number of subdivisions per side
  80010. * @param scene defines the hosting scene
  80011. * @param updatable defines if the mesh must be flagged as updatable
  80012. * @returns a new Mesh
  80013. */
  80014. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80015. /**
  80016. * Creates a tiled ground mesh.
  80017. * Please consider using the same method from the MeshBuilder class instead
  80018. * @param name defines the name of the mesh to create
  80019. * @param xmin set the ground minimum X coordinate
  80020. * @param zmin set the ground minimum Y coordinate
  80021. * @param xmax set the ground maximum X coordinate
  80022. * @param zmax set the ground maximum Z coordinate
  80023. * @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
  80024. * @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
  80025. * @param scene defines the hosting scene
  80026. * @param updatable defines if the mesh must be flagged as updatable
  80027. * @returns a new Mesh
  80028. */
  80029. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80030. w: number;
  80031. h: number;
  80032. }, precision: {
  80033. w: number;
  80034. h: number;
  80035. }, scene: Scene, updatable?: boolean): Mesh;
  80036. /**
  80037. * Creates a ground mesh from a height map.
  80038. * Please consider using the same method from the MeshBuilder class instead
  80039. * @see http://doc.babylonjs.com/babylon101/height_map
  80040. * @param name defines the name of the mesh to create
  80041. * @param url sets the URL of the height map image resource
  80042. * @param width set the ground width size
  80043. * @param height set the ground height size
  80044. * @param subdivisions sets the number of subdivision per side
  80045. * @param minHeight is the minimum altitude on the ground
  80046. * @param maxHeight is the maximum altitude on the ground
  80047. * @param scene defines the hosting scene
  80048. * @param updatable defines if the mesh must be flagged as updatable
  80049. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80050. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80051. * @returns a new Mesh
  80052. */
  80053. 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;
  80054. /**
  80055. * Creates a tube mesh.
  80056. * The tube is a parametric shape.
  80057. * It has no predefined shape. Its final shape will depend on the input parameters.
  80058. * Please consider using the same method from the MeshBuilder class instead
  80059. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80060. * @param name defines the name of the mesh to create
  80061. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80062. * @param radius sets the tube radius size
  80063. * @param tessellation is the number of sides on the tubular surface
  80064. * @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
  80065. * @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
  80066. * @param scene defines the hosting scene
  80067. * @param updatable defines if the mesh must be flagged as updatable
  80068. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80069. * @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)
  80070. * @returns a new Mesh
  80071. */
  80072. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80073. (i: number, distance: number): number;
  80074. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80075. /**
  80076. * Creates a polyhedron mesh.
  80077. * Please consider using the same method from the MeshBuilder class instead.
  80078. * * 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
  80079. * * The parameter `size` (positive float, default 1) sets the polygon size
  80080. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80081. * * 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`
  80082. * * 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
  80083. * * 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)`)
  80084. * * 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
  80085. * * 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
  80086. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80087. * * If you create a double-sided mesh, you can choose what parts of 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
  80088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80089. * @param name defines the name of the mesh to create
  80090. * @param options defines the options used to create the mesh
  80091. * @param scene defines the hosting scene
  80092. * @returns a new Mesh
  80093. */
  80094. static CreatePolyhedron(name: string, options: {
  80095. type?: number;
  80096. size?: number;
  80097. sizeX?: number;
  80098. sizeY?: number;
  80099. sizeZ?: number;
  80100. custom?: any;
  80101. faceUV?: Vector4[];
  80102. faceColors?: Color4[];
  80103. updatable?: boolean;
  80104. sideOrientation?: number;
  80105. }, scene: Scene): Mesh;
  80106. /**
  80107. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80108. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80109. * * 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`)
  80110. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80111. * * 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
  80112. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80113. * * If you create a double-sided mesh, you can choose what parts of 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
  80114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80115. * @param name defines the name of the mesh
  80116. * @param options defines the options used to create the mesh
  80117. * @param scene defines the hosting scene
  80118. * @returns a new Mesh
  80119. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80120. */
  80121. static CreateIcoSphere(name: string, options: {
  80122. radius?: number;
  80123. flat?: boolean;
  80124. subdivisions?: number;
  80125. sideOrientation?: number;
  80126. updatable?: boolean;
  80127. }, scene: Scene): Mesh;
  80128. /**
  80129. * Creates a decal mesh.
  80130. * Please consider using the same method from the MeshBuilder class instead.
  80131. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80132. * @param name defines the name of the mesh
  80133. * @param sourceMesh defines the mesh receiving the decal
  80134. * @param position sets the position of the decal in world coordinates
  80135. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80136. * @param size sets the decal scaling
  80137. * @param angle sets the angle to rotate the decal
  80138. * @returns a new Mesh
  80139. */
  80140. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80141. /**
  80142. * Prepare internal position array for software CPU skinning
  80143. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80144. */
  80145. setPositionsForCPUSkinning(): Float32Array;
  80146. /**
  80147. * Prepare internal normal array for software CPU skinning
  80148. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80149. */
  80150. setNormalsForCPUSkinning(): Float32Array;
  80151. /**
  80152. * Updates the vertex buffer by applying transformation from the bones
  80153. * @param skeleton defines the skeleton to apply to current mesh
  80154. * @returns the current mesh
  80155. */
  80156. applySkeleton(skeleton: Skeleton): Mesh;
  80157. /**
  80158. * 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
  80159. * @param meshes defines the list of meshes to scan
  80160. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80161. */
  80162. static MinMax(meshes: AbstractMesh[]): {
  80163. min: Vector3;
  80164. max: Vector3;
  80165. };
  80166. /**
  80167. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80168. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80169. * @returns a vector3
  80170. */
  80171. static Center(meshesOrMinMaxVector: {
  80172. min: Vector3;
  80173. max: Vector3;
  80174. } | AbstractMesh[]): Vector3;
  80175. /**
  80176. * Merge the array of meshes into a single mesh for performance reasons.
  80177. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80178. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80179. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80180. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80181. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80182. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80183. * @returns a new mesh
  80184. */
  80185. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80186. /** @hidden */
  80187. addInstance(instance: InstancedMesh): void;
  80188. /** @hidden */
  80189. removeInstance(instance: InstancedMesh): void;
  80190. }
  80191. }
  80192. declare module BABYLON {
  80193. /**
  80194. * Base class for the main features of a material in Babylon.js
  80195. */
  80196. export class Material implements IAnimatable {
  80197. /**
  80198. * Returns the triangle fill mode
  80199. */
  80200. static readonly TriangleFillMode: number;
  80201. /**
  80202. * Returns the wireframe mode
  80203. */
  80204. static readonly WireFrameFillMode: number;
  80205. /**
  80206. * Returns the point fill mode
  80207. */
  80208. static readonly PointFillMode: number;
  80209. /**
  80210. * Returns the point list draw mode
  80211. */
  80212. static readonly PointListDrawMode: number;
  80213. /**
  80214. * Returns the line list draw mode
  80215. */
  80216. static readonly LineListDrawMode: number;
  80217. /**
  80218. * Returns the line loop draw mode
  80219. */
  80220. static readonly LineLoopDrawMode: number;
  80221. /**
  80222. * Returns the line strip draw mode
  80223. */
  80224. static readonly LineStripDrawMode: number;
  80225. /**
  80226. * Returns the triangle strip draw mode
  80227. */
  80228. static readonly TriangleStripDrawMode: number;
  80229. /**
  80230. * Returns the triangle fan draw mode
  80231. */
  80232. static readonly TriangleFanDrawMode: number;
  80233. /**
  80234. * Stores the clock-wise side orientation
  80235. */
  80236. static readonly ClockWiseSideOrientation: number;
  80237. /**
  80238. * Stores the counter clock-wise side orientation
  80239. */
  80240. static readonly CounterClockWiseSideOrientation: number;
  80241. /**
  80242. * The dirty texture flag value
  80243. */
  80244. static readonly TextureDirtyFlag: number;
  80245. /**
  80246. * The dirty light flag value
  80247. */
  80248. static readonly LightDirtyFlag: number;
  80249. /**
  80250. * The dirty fresnel flag value
  80251. */
  80252. static readonly FresnelDirtyFlag: number;
  80253. /**
  80254. * The dirty attribute flag value
  80255. */
  80256. static readonly AttributesDirtyFlag: number;
  80257. /**
  80258. * The dirty misc flag value
  80259. */
  80260. static readonly MiscDirtyFlag: number;
  80261. /**
  80262. * The all dirty flag value
  80263. */
  80264. static readonly AllDirtyFlag: number;
  80265. /**
  80266. * The ID of the material
  80267. */
  80268. id: string;
  80269. /**
  80270. * Gets or sets the unique id of the material
  80271. */
  80272. uniqueId: number;
  80273. /**
  80274. * The name of the material
  80275. */
  80276. name: string;
  80277. /**
  80278. * Gets or sets user defined metadata
  80279. */
  80280. metadata: any;
  80281. /**
  80282. * For internal use only. Please do not use.
  80283. */
  80284. reservedDataStore: any;
  80285. /**
  80286. * Specifies if the ready state should be checked on each call
  80287. */
  80288. checkReadyOnEveryCall: boolean;
  80289. /**
  80290. * Specifies if the ready state should be checked once
  80291. */
  80292. checkReadyOnlyOnce: boolean;
  80293. /**
  80294. * The state of the material
  80295. */
  80296. state: string;
  80297. /**
  80298. * The alpha value of the material
  80299. */
  80300. protected _alpha: number;
  80301. /**
  80302. * List of inspectable custom properties (used by the Inspector)
  80303. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80304. */
  80305. inspectableCustomProperties: IInspectable[];
  80306. /**
  80307. * Sets the alpha value of the material
  80308. */
  80309. /**
  80310. * Gets the alpha value of the material
  80311. */
  80312. alpha: number;
  80313. /**
  80314. * Specifies if back face culling is enabled
  80315. */
  80316. protected _backFaceCulling: boolean;
  80317. /**
  80318. * Sets the back-face culling state
  80319. */
  80320. /**
  80321. * Gets the back-face culling state
  80322. */
  80323. backFaceCulling: boolean;
  80324. /**
  80325. * Stores the value for side orientation
  80326. */
  80327. sideOrientation: number;
  80328. /**
  80329. * Callback triggered when the material is compiled
  80330. */
  80331. onCompiled: (effect: Effect) => void;
  80332. /**
  80333. * Callback triggered when an error occurs
  80334. */
  80335. onError: (effect: Effect, errors: string) => void;
  80336. /**
  80337. * Callback triggered to get the render target textures
  80338. */
  80339. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  80340. /**
  80341. * Gets a boolean indicating that current material needs to register RTT
  80342. */
  80343. readonly hasRenderTargetTextures: boolean;
  80344. /**
  80345. * Specifies if the material should be serialized
  80346. */
  80347. doNotSerialize: boolean;
  80348. /**
  80349. * @hidden
  80350. */
  80351. _storeEffectOnSubMeshes: boolean;
  80352. /**
  80353. * Stores the animations for the material
  80354. */
  80355. animations: Array<Animation>;
  80356. /**
  80357. * An event triggered when the material is disposed
  80358. */
  80359. onDisposeObservable: Observable<Material>;
  80360. /**
  80361. * An observer which watches for dispose events
  80362. */
  80363. private _onDisposeObserver;
  80364. private _onUnBindObservable;
  80365. /**
  80366. * Called during a dispose event
  80367. */
  80368. onDispose: () => void;
  80369. private _onBindObservable;
  80370. /**
  80371. * An event triggered when the material is bound
  80372. */
  80373. readonly onBindObservable: Observable<AbstractMesh>;
  80374. /**
  80375. * An observer which watches for bind events
  80376. */
  80377. private _onBindObserver;
  80378. /**
  80379. * Called during a bind event
  80380. */
  80381. onBind: (Mesh: AbstractMesh) => void;
  80382. /**
  80383. * An event triggered when the material is unbound
  80384. */
  80385. readonly onUnBindObservable: Observable<Material>;
  80386. /**
  80387. * Stores the value of the alpha mode
  80388. */
  80389. private _alphaMode;
  80390. /**
  80391. * Sets the value of the alpha mode.
  80392. *
  80393. * | Value | Type | Description |
  80394. * | --- | --- | --- |
  80395. * | 0 | ALPHA_DISABLE | |
  80396. * | 1 | ALPHA_ADD | |
  80397. * | 2 | ALPHA_COMBINE | |
  80398. * | 3 | ALPHA_SUBTRACT | |
  80399. * | 4 | ALPHA_MULTIPLY | |
  80400. * | 5 | ALPHA_MAXIMIZED | |
  80401. * | 6 | ALPHA_ONEONE | |
  80402. * | 7 | ALPHA_PREMULTIPLIED | |
  80403. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  80404. * | 9 | ALPHA_INTERPOLATE | |
  80405. * | 10 | ALPHA_SCREENMODE | |
  80406. *
  80407. */
  80408. /**
  80409. * Gets the value of the alpha mode
  80410. */
  80411. alphaMode: number;
  80412. /**
  80413. * Stores the state of the need depth pre-pass value
  80414. */
  80415. private _needDepthPrePass;
  80416. /**
  80417. * Sets the need depth pre-pass value
  80418. */
  80419. /**
  80420. * Gets the depth pre-pass value
  80421. */
  80422. needDepthPrePass: boolean;
  80423. /**
  80424. * Specifies if depth writing should be disabled
  80425. */
  80426. disableDepthWrite: boolean;
  80427. /**
  80428. * Specifies if depth writing should be forced
  80429. */
  80430. forceDepthWrite: boolean;
  80431. /**
  80432. * Specifies if there should be a separate pass for culling
  80433. */
  80434. separateCullingPass: boolean;
  80435. /**
  80436. * Stores the state specifing if fog should be enabled
  80437. */
  80438. private _fogEnabled;
  80439. /**
  80440. * Sets the state for enabling fog
  80441. */
  80442. /**
  80443. * Gets the value of the fog enabled state
  80444. */
  80445. fogEnabled: boolean;
  80446. /**
  80447. * Stores the size of points
  80448. */
  80449. pointSize: number;
  80450. /**
  80451. * Stores the z offset value
  80452. */
  80453. zOffset: number;
  80454. /**
  80455. * Gets a value specifying if wireframe mode is enabled
  80456. */
  80457. /**
  80458. * Sets the state of wireframe mode
  80459. */
  80460. wireframe: boolean;
  80461. /**
  80462. * Gets the value specifying if point clouds are enabled
  80463. */
  80464. /**
  80465. * Sets the state of point cloud mode
  80466. */
  80467. pointsCloud: boolean;
  80468. /**
  80469. * Gets the material fill mode
  80470. */
  80471. /**
  80472. * Sets the material fill mode
  80473. */
  80474. fillMode: number;
  80475. /**
  80476. * @hidden
  80477. * Stores the effects for the material
  80478. */
  80479. _effect: Nullable<Effect>;
  80480. /**
  80481. * @hidden
  80482. * Specifies if the material was previously ready
  80483. */
  80484. _wasPreviouslyReady: boolean;
  80485. /**
  80486. * Specifies if uniform buffers should be used
  80487. */
  80488. private _useUBO;
  80489. /**
  80490. * Stores a reference to the scene
  80491. */
  80492. private _scene;
  80493. /**
  80494. * Stores the fill mode state
  80495. */
  80496. private _fillMode;
  80497. /**
  80498. * Specifies if the depth write state should be cached
  80499. */
  80500. private _cachedDepthWriteState;
  80501. /**
  80502. * Stores the uniform buffer
  80503. */
  80504. protected _uniformBuffer: UniformBuffer;
  80505. /** @hidden */
  80506. _indexInSceneMaterialArray: number;
  80507. /** @hidden */
  80508. meshMap: Nullable<{
  80509. [id: string]: AbstractMesh | undefined;
  80510. }>;
  80511. /**
  80512. * Creates a material instance
  80513. * @param name defines the name of the material
  80514. * @param scene defines the scene to reference
  80515. * @param doNotAdd specifies if the material should be added to the scene
  80516. */
  80517. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  80518. /**
  80519. * Returns a string representation of the current material
  80520. * @param fullDetails defines a boolean indicating which levels of logging is desired
  80521. * @returns a string with material information
  80522. */
  80523. toString(fullDetails?: boolean): string;
  80524. /**
  80525. * Gets the class name of the material
  80526. * @returns a string with the class name of the material
  80527. */
  80528. getClassName(): string;
  80529. /**
  80530. * Specifies if updates for the material been locked
  80531. */
  80532. readonly isFrozen: boolean;
  80533. /**
  80534. * Locks updates for the material
  80535. */
  80536. freeze(): void;
  80537. /**
  80538. * Unlocks updates for the material
  80539. */
  80540. unfreeze(): void;
  80541. /**
  80542. * Specifies if the material is ready to be used
  80543. * @param mesh defines the mesh to check
  80544. * @param useInstances specifies if instances should be used
  80545. * @returns a boolean indicating if the material is ready to be used
  80546. */
  80547. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  80548. /**
  80549. * Specifies that the submesh is ready to be used
  80550. * @param mesh defines the mesh to check
  80551. * @param subMesh defines which submesh to check
  80552. * @param useInstances specifies that instances should be used
  80553. * @returns a boolean indicating that the submesh is ready or not
  80554. */
  80555. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  80556. /**
  80557. * Returns the material effect
  80558. * @returns the effect associated with the material
  80559. */
  80560. getEffect(): Nullable<Effect>;
  80561. /**
  80562. * Returns the current scene
  80563. * @returns a Scene
  80564. */
  80565. getScene(): Scene;
  80566. /**
  80567. * Specifies if the material will require alpha blending
  80568. * @returns a boolean specifying if alpha blending is needed
  80569. */
  80570. needAlphaBlending(): boolean;
  80571. /**
  80572. * Specifies if the mesh will require alpha blending
  80573. * @param mesh defines the mesh to check
  80574. * @returns a boolean specifying if alpha blending is needed for the mesh
  80575. */
  80576. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  80577. /**
  80578. * Specifies if this material should be rendered in alpha test mode
  80579. * @returns a boolean specifying if an alpha test is needed.
  80580. */
  80581. needAlphaTesting(): boolean;
  80582. /**
  80583. * Gets the texture used for the alpha test
  80584. * @returns the texture to use for alpha testing
  80585. */
  80586. getAlphaTestTexture(): Nullable<BaseTexture>;
  80587. /**
  80588. * Marks the material to indicate that it needs to be re-calculated
  80589. */
  80590. markDirty(): void;
  80591. /** @hidden */
  80592. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  80593. /**
  80594. * Binds the material to the mesh
  80595. * @param world defines the world transformation matrix
  80596. * @param mesh defines the mesh to bind the material to
  80597. */
  80598. bind(world: Matrix, mesh?: Mesh): void;
  80599. /**
  80600. * Binds the submesh to the material
  80601. * @param world defines the world transformation matrix
  80602. * @param mesh defines the mesh containing the submesh
  80603. * @param subMesh defines the submesh to bind the material to
  80604. */
  80605. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  80606. /**
  80607. * Binds the world matrix to the material
  80608. * @param world defines the world transformation matrix
  80609. */
  80610. bindOnlyWorldMatrix(world: Matrix): void;
  80611. /**
  80612. * Binds the scene's uniform buffer to the effect.
  80613. * @param effect defines the effect to bind to the scene uniform buffer
  80614. * @param sceneUbo defines the uniform buffer storing scene data
  80615. */
  80616. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  80617. /**
  80618. * Binds the view matrix to the effect
  80619. * @param effect defines the effect to bind the view matrix to
  80620. */
  80621. bindView(effect: Effect): void;
  80622. /**
  80623. * Binds the view projection matrix to the effect
  80624. * @param effect defines the effect to bind the view projection matrix to
  80625. */
  80626. bindViewProjection(effect: Effect): void;
  80627. /**
  80628. * Specifies if material alpha testing should be turned on for the mesh
  80629. * @param mesh defines the mesh to check
  80630. */
  80631. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  80632. /**
  80633. * Processes to execute after binding the material to a mesh
  80634. * @param mesh defines the rendered mesh
  80635. */
  80636. protected _afterBind(mesh?: Mesh): void;
  80637. /**
  80638. * Unbinds the material from the mesh
  80639. */
  80640. unbind(): void;
  80641. /**
  80642. * Gets the active textures from the material
  80643. * @returns an array of textures
  80644. */
  80645. getActiveTextures(): BaseTexture[];
  80646. /**
  80647. * Specifies if the material uses a texture
  80648. * @param texture defines the texture to check against the material
  80649. * @returns a boolean specifying if the material uses the texture
  80650. */
  80651. hasTexture(texture: BaseTexture): boolean;
  80652. /**
  80653. * Makes a duplicate of the material, and gives it a new name
  80654. * @param name defines the new name for the duplicated material
  80655. * @returns the cloned material
  80656. */
  80657. clone(name: string): Nullable<Material>;
  80658. /**
  80659. * Gets the meshes bound to the material
  80660. * @returns an array of meshes bound to the material
  80661. */
  80662. getBindedMeshes(): AbstractMesh[];
  80663. /**
  80664. * Force shader compilation
  80665. * @param mesh defines the mesh associated with this material
  80666. * @param onCompiled defines a function to execute once the material is compiled
  80667. * @param options defines the options to configure the compilation
  80668. */
  80669. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  80670. clipPlane: boolean;
  80671. }>): void;
  80672. /**
  80673. * Force shader compilation
  80674. * @param mesh defines the mesh that will use this material
  80675. * @param options defines additional options for compiling the shaders
  80676. * @returns a promise that resolves when the compilation completes
  80677. */
  80678. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  80679. clipPlane: boolean;
  80680. }>): Promise<void>;
  80681. private static readonly _ImageProcessingDirtyCallBack;
  80682. private static readonly _TextureDirtyCallBack;
  80683. private static readonly _FresnelDirtyCallBack;
  80684. private static readonly _MiscDirtyCallBack;
  80685. private static readonly _LightsDirtyCallBack;
  80686. private static readonly _AttributeDirtyCallBack;
  80687. private static _FresnelAndMiscDirtyCallBack;
  80688. private static _TextureAndMiscDirtyCallBack;
  80689. private static readonly _DirtyCallbackArray;
  80690. private static readonly _RunDirtyCallBacks;
  80691. /**
  80692. * Marks a define in the material to indicate that it needs to be re-computed
  80693. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  80694. */
  80695. markAsDirty(flag: number): void;
  80696. /**
  80697. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  80698. * @param func defines a function which checks material defines against the submeshes
  80699. */
  80700. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  80701. /**
  80702. * Indicates that image processing needs to be re-calculated for all submeshes
  80703. */
  80704. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  80705. /**
  80706. * Indicates that textures need to be re-calculated for all submeshes
  80707. */
  80708. protected _markAllSubMeshesAsTexturesDirty(): void;
  80709. /**
  80710. * Indicates that fresnel needs to be re-calculated for all submeshes
  80711. */
  80712. protected _markAllSubMeshesAsFresnelDirty(): void;
  80713. /**
  80714. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  80715. */
  80716. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  80717. /**
  80718. * Indicates that lights need to be re-calculated for all submeshes
  80719. */
  80720. protected _markAllSubMeshesAsLightsDirty(): void;
  80721. /**
  80722. * Indicates that attributes need to be re-calculated for all submeshes
  80723. */
  80724. protected _markAllSubMeshesAsAttributesDirty(): void;
  80725. /**
  80726. * Indicates that misc needs to be re-calculated for all submeshes
  80727. */
  80728. protected _markAllSubMeshesAsMiscDirty(): void;
  80729. /**
  80730. * Indicates that textures and misc need to be re-calculated for all submeshes
  80731. */
  80732. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  80733. /**
  80734. * Disposes the material
  80735. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80736. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  80737. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  80738. */
  80739. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  80740. /** @hidden */
  80741. private releaseVertexArrayObject;
  80742. /**
  80743. * Serializes this material
  80744. * @returns the serialized material object
  80745. */
  80746. serialize(): any;
  80747. /**
  80748. * Creates a material from parsed material data
  80749. * @param parsedMaterial defines parsed material data
  80750. * @param scene defines the hosting scene
  80751. * @param rootUrl defines the root URL to use to load textures
  80752. * @returns a new material
  80753. */
  80754. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  80755. }
  80756. }
  80757. declare module BABYLON {
  80758. /**
  80759. * Base class for submeshes
  80760. */
  80761. export class BaseSubMesh {
  80762. /** @hidden */
  80763. _materialDefines: Nullable<MaterialDefines>;
  80764. /** @hidden */
  80765. _materialEffect: Nullable<Effect>;
  80766. /**
  80767. * Gets associated effect
  80768. */
  80769. readonly effect: Nullable<Effect>;
  80770. /**
  80771. * Sets associated effect (effect used to render this submesh)
  80772. * @param effect defines the effect to associate with
  80773. * @param defines defines the set of defines used to compile this effect
  80774. */
  80775. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  80776. }
  80777. /**
  80778. * Defines a subdivision inside a mesh
  80779. */
  80780. export class SubMesh extends BaseSubMesh implements ICullable {
  80781. /** the material index to use */
  80782. materialIndex: number;
  80783. /** vertex index start */
  80784. verticesStart: number;
  80785. /** vertices count */
  80786. verticesCount: number;
  80787. /** index start */
  80788. indexStart: number;
  80789. /** indices count */
  80790. indexCount: number;
  80791. /** @hidden */
  80792. _linesIndexCount: number;
  80793. private _mesh;
  80794. private _renderingMesh;
  80795. private _boundingInfo;
  80796. private _linesIndexBuffer;
  80797. /** @hidden */
  80798. _lastColliderWorldVertices: Nullable<Vector3[]>;
  80799. /** @hidden */
  80800. _trianglePlanes: Plane[];
  80801. /** @hidden */
  80802. _lastColliderTransformMatrix: Matrix;
  80803. /** @hidden */
  80804. _renderId: number;
  80805. /** @hidden */
  80806. _alphaIndex: number;
  80807. /** @hidden */
  80808. _distanceToCamera: number;
  80809. /** @hidden */
  80810. _id: number;
  80811. private _currentMaterial;
  80812. /**
  80813. * Add a new submesh to a mesh
  80814. * @param materialIndex defines the material index to use
  80815. * @param verticesStart defines vertex index start
  80816. * @param verticesCount defines vertices count
  80817. * @param indexStart defines index start
  80818. * @param indexCount defines indices count
  80819. * @param mesh defines the parent mesh
  80820. * @param renderingMesh defines an optional rendering mesh
  80821. * @param createBoundingBox defines if bounding box should be created for this submesh
  80822. * @returns the new submesh
  80823. */
  80824. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  80825. /**
  80826. * Creates a new submesh
  80827. * @param materialIndex defines the material index to use
  80828. * @param verticesStart defines vertex index start
  80829. * @param verticesCount defines vertices count
  80830. * @param indexStart defines index start
  80831. * @param indexCount defines indices count
  80832. * @param mesh defines the parent mesh
  80833. * @param renderingMesh defines an optional rendering mesh
  80834. * @param createBoundingBox defines if bounding box should be created for this submesh
  80835. */
  80836. constructor(
  80837. /** the material index to use */
  80838. materialIndex: number,
  80839. /** vertex index start */
  80840. verticesStart: number,
  80841. /** vertices count */
  80842. verticesCount: number,
  80843. /** index start */
  80844. indexStart: number,
  80845. /** indices count */
  80846. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  80847. /**
  80848. * Returns true if this submesh covers the entire parent mesh
  80849. * @ignorenaming
  80850. */
  80851. readonly IsGlobal: boolean;
  80852. /**
  80853. * Returns the submesh BoudingInfo object
  80854. * @returns current bounding info (or mesh's one if the submesh is global)
  80855. */
  80856. getBoundingInfo(): BoundingInfo;
  80857. /**
  80858. * Sets the submesh BoundingInfo
  80859. * @param boundingInfo defines the new bounding info to use
  80860. * @returns the SubMesh
  80861. */
  80862. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  80863. /**
  80864. * Returns the mesh of the current submesh
  80865. * @return the parent mesh
  80866. */
  80867. getMesh(): AbstractMesh;
  80868. /**
  80869. * Returns the rendering mesh of the submesh
  80870. * @returns the rendering mesh (could be different from parent mesh)
  80871. */
  80872. getRenderingMesh(): Mesh;
  80873. /**
  80874. * Returns the submesh material
  80875. * @returns null or the current material
  80876. */
  80877. getMaterial(): Nullable<Material>;
  80878. /**
  80879. * Sets a new updated BoundingInfo object to the submesh
  80880. * @returns the SubMesh
  80881. */
  80882. refreshBoundingInfo(): SubMesh;
  80883. /** @hidden */
  80884. _checkCollision(collider: Collider): boolean;
  80885. /**
  80886. * Updates the submesh BoundingInfo
  80887. * @param world defines the world matrix to use to update the bounding info
  80888. * @returns the submesh
  80889. */
  80890. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  80891. /**
  80892. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  80893. * @param frustumPlanes defines the frustum planes
  80894. * @returns true if the submesh is intersecting with the frustum
  80895. */
  80896. isInFrustum(frustumPlanes: Plane[]): boolean;
  80897. /**
  80898. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  80899. * @param frustumPlanes defines the frustum planes
  80900. * @returns true if the submesh is inside the frustum
  80901. */
  80902. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80903. /**
  80904. * Renders the submesh
  80905. * @param enableAlphaMode defines if alpha needs to be used
  80906. * @returns the submesh
  80907. */
  80908. render(enableAlphaMode: boolean): SubMesh;
  80909. /**
  80910. * @hidden
  80911. */
  80912. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  80913. /**
  80914. * Checks if the submesh intersects with a ray
  80915. * @param ray defines the ray to test
  80916. * @returns true is the passed ray intersects the submesh bounding box
  80917. */
  80918. canIntersects(ray: Ray): boolean;
  80919. /**
  80920. * Intersects current submesh with a ray
  80921. * @param ray defines the ray to test
  80922. * @param positions defines mesh's positions array
  80923. * @param indices defines mesh's indices array
  80924. * @param fastCheck defines if only bounding info should be used
  80925. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  80926. * @returns intersection info or null if no intersection
  80927. */
  80928. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  80929. /** @hidden */
  80930. private _intersectLines;
  80931. /** @hidden */
  80932. private _intersectTriangles;
  80933. /** @hidden */
  80934. _rebuild(): void;
  80935. /**
  80936. * Creates a new submesh from the passed mesh
  80937. * @param newMesh defines the new hosting mesh
  80938. * @param newRenderingMesh defines an optional rendering mesh
  80939. * @returns the new submesh
  80940. */
  80941. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  80942. /**
  80943. * Release associated resources
  80944. */
  80945. dispose(): void;
  80946. /**
  80947. * Gets the class name
  80948. * @returns the string "SubMesh".
  80949. */
  80950. getClassName(): string;
  80951. /**
  80952. * Creates a new submesh from indices data
  80953. * @param materialIndex the index of the main mesh material
  80954. * @param startIndex the index where to start the copy in the mesh indices array
  80955. * @param indexCount the number of indices to copy then from the startIndex
  80956. * @param mesh the main mesh to create the submesh from
  80957. * @param renderingMesh the optional rendering mesh
  80958. * @returns a new submesh
  80959. */
  80960. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  80961. }
  80962. }
  80963. declare module BABYLON {
  80964. /**
  80965. * Class used to store geometry data (vertex buffers + index buffer)
  80966. */
  80967. export class Geometry implements IGetSetVerticesData {
  80968. /**
  80969. * Gets or sets the ID of the geometry
  80970. */
  80971. id: string;
  80972. /**
  80973. * Gets or sets the unique ID of the geometry
  80974. */
  80975. uniqueId: number;
  80976. /**
  80977. * Gets the delay loading state of the geometry (none by default which means not delayed)
  80978. */
  80979. delayLoadState: number;
  80980. /**
  80981. * Gets the file containing the data to load when running in delay load state
  80982. */
  80983. delayLoadingFile: Nullable<string>;
  80984. /**
  80985. * Callback called when the geometry is updated
  80986. */
  80987. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  80988. private _scene;
  80989. private _engine;
  80990. private _meshes;
  80991. private _totalVertices;
  80992. /** @hidden */
  80993. _indices: IndicesArray;
  80994. /** @hidden */
  80995. _vertexBuffers: {
  80996. [key: string]: VertexBuffer;
  80997. };
  80998. private _isDisposed;
  80999. private _extend;
  81000. private _boundingBias;
  81001. /** @hidden */
  81002. _delayInfo: Array<string>;
  81003. private _indexBuffer;
  81004. private _indexBufferIsUpdatable;
  81005. /** @hidden */
  81006. _boundingInfo: Nullable<BoundingInfo>;
  81007. /** @hidden */
  81008. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  81009. /** @hidden */
  81010. _softwareSkinningFrameId: number;
  81011. private _vertexArrayObjects;
  81012. private _updatable;
  81013. /** @hidden */
  81014. _positions: Nullable<Vector3[]>;
  81015. /**
  81016. * 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
  81017. */
  81018. /**
  81019. * 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
  81020. */
  81021. boundingBias: Vector2;
  81022. /**
  81023. * Static function used to attach a new empty geometry to a mesh
  81024. * @param mesh defines the mesh to attach the geometry to
  81025. * @returns the new Geometry
  81026. */
  81027. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81028. /**
  81029. * Creates a new geometry
  81030. * @param id defines the unique ID
  81031. * @param scene defines the hosting scene
  81032. * @param vertexData defines the VertexData used to get geometry data
  81033. * @param updatable defines if geometry must be updatable (false by default)
  81034. * @param mesh defines the mesh that will be associated with the geometry
  81035. */
  81036. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81037. /**
  81038. * Gets the current extend of the geometry
  81039. */
  81040. readonly extend: {
  81041. minimum: Vector3;
  81042. maximum: Vector3;
  81043. };
  81044. /**
  81045. * Gets the hosting scene
  81046. * @returns the hosting Scene
  81047. */
  81048. getScene(): Scene;
  81049. /**
  81050. * Gets the hosting engine
  81051. * @returns the hosting Engine
  81052. */
  81053. getEngine(): Engine;
  81054. /**
  81055. * Defines if the geometry is ready to use
  81056. * @returns true if the geometry is ready to be used
  81057. */
  81058. isReady(): boolean;
  81059. /**
  81060. * Gets a value indicating that the geometry should not be serialized
  81061. */
  81062. readonly doNotSerialize: boolean;
  81063. /** @hidden */
  81064. _rebuild(): void;
  81065. /**
  81066. * Affects all geometry data in one call
  81067. * @param vertexData defines the geometry data
  81068. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81069. */
  81070. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81071. /**
  81072. * Set specific vertex data
  81073. * @param kind defines the data kind (Position, normal, etc...)
  81074. * @param data defines the vertex data to use
  81075. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81076. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81077. */
  81078. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81079. /**
  81080. * Removes a specific vertex data
  81081. * @param kind defines the data kind (Position, normal, etc...)
  81082. */
  81083. removeVerticesData(kind: string): void;
  81084. /**
  81085. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81086. * @param buffer defines the vertex buffer to use
  81087. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81088. */
  81089. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81090. /**
  81091. * Update a specific vertex buffer
  81092. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81093. * It will do nothing if the buffer is not updatable
  81094. * @param kind defines the data kind (Position, normal, etc...)
  81095. * @param data defines the data to use
  81096. * @param offset defines the offset in the target buffer where to store the data
  81097. * @param useBytes set to true if the offset is in bytes
  81098. */
  81099. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81100. /**
  81101. * Update a specific vertex buffer
  81102. * This function will create a new buffer if the current one is not updatable
  81103. * @param kind defines the data kind (Position, normal, etc...)
  81104. * @param data defines the data to use
  81105. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81106. */
  81107. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81108. private _updateBoundingInfo;
  81109. /** @hidden */
  81110. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81111. /**
  81112. * Gets total number of vertices
  81113. * @returns the total number of vertices
  81114. */
  81115. getTotalVertices(): number;
  81116. /**
  81117. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81118. * @param kind defines the data kind (Position, normal, etc...)
  81119. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81120. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81121. * @returns a float array containing vertex data
  81122. */
  81123. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81124. /**
  81125. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81126. * @param kind defines the data kind (Position, normal, etc...)
  81127. * @returns true if the vertex buffer with the specified kind is updatable
  81128. */
  81129. isVertexBufferUpdatable(kind: string): boolean;
  81130. /**
  81131. * Gets a specific vertex buffer
  81132. * @param kind defines the data kind (Position, normal, etc...)
  81133. * @returns a VertexBuffer
  81134. */
  81135. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81136. /**
  81137. * Returns all vertex buffers
  81138. * @return an object holding all vertex buffers indexed by kind
  81139. */
  81140. getVertexBuffers(): Nullable<{
  81141. [key: string]: VertexBuffer;
  81142. }>;
  81143. /**
  81144. * Gets a boolean indicating if specific vertex buffer is present
  81145. * @param kind defines the data kind (Position, normal, etc...)
  81146. * @returns true if data is present
  81147. */
  81148. isVerticesDataPresent(kind: string): boolean;
  81149. /**
  81150. * Gets a list of all attached data kinds (Position, normal, etc...)
  81151. * @returns a list of string containing all kinds
  81152. */
  81153. getVerticesDataKinds(): string[];
  81154. /**
  81155. * Update index buffer
  81156. * @param indices defines the indices to store in the index buffer
  81157. * @param offset defines the offset in the target buffer where to store the data
  81158. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  81159. */
  81160. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81161. /**
  81162. * Creates a new index buffer
  81163. * @param indices defines the indices to store in the index buffer
  81164. * @param totalVertices defines the total number of vertices (could be null)
  81165. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81166. */
  81167. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81168. /**
  81169. * Return the total number of indices
  81170. * @returns the total number of indices
  81171. */
  81172. getTotalIndices(): number;
  81173. /**
  81174. * Gets the index buffer array
  81175. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81176. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81177. * @returns the index buffer array
  81178. */
  81179. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81180. /**
  81181. * Gets the index buffer
  81182. * @return the index buffer
  81183. */
  81184. getIndexBuffer(): Nullable<WebGLBuffer>;
  81185. /** @hidden */
  81186. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81187. /**
  81188. * Release the associated resources for a specific mesh
  81189. * @param mesh defines the source mesh
  81190. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81191. */
  81192. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81193. /**
  81194. * Apply current geometry to a given mesh
  81195. * @param mesh defines the mesh to apply geometry to
  81196. */
  81197. applyToMesh(mesh: Mesh): void;
  81198. private _updateExtend;
  81199. private _applyToMesh;
  81200. private notifyUpdate;
  81201. /**
  81202. * Load the geometry if it was flagged as delay loaded
  81203. * @param scene defines the hosting scene
  81204. * @param onLoaded defines a callback called when the geometry is loaded
  81205. */
  81206. load(scene: Scene, onLoaded?: () => void): void;
  81207. private _queueLoad;
  81208. /**
  81209. * Invert the geometry to move from a right handed system to a left handed one.
  81210. */
  81211. toLeftHanded(): void;
  81212. /** @hidden */
  81213. _resetPointsArrayCache(): void;
  81214. /** @hidden */
  81215. _generatePointsArray(): boolean;
  81216. /**
  81217. * Gets a value indicating if the geometry is disposed
  81218. * @returns true if the geometry was disposed
  81219. */
  81220. isDisposed(): boolean;
  81221. private _disposeVertexArrayObjects;
  81222. /**
  81223. * Free all associated resources
  81224. */
  81225. dispose(): void;
  81226. /**
  81227. * Clone the current geometry into a new geometry
  81228. * @param id defines the unique ID of the new geometry
  81229. * @returns a new geometry object
  81230. */
  81231. copy(id: string): Geometry;
  81232. /**
  81233. * Serialize the current geometry info (and not the vertices data) into a JSON object
  81234. * @return a JSON representation of the current geometry data (without the vertices data)
  81235. */
  81236. serialize(): any;
  81237. private toNumberArray;
  81238. /**
  81239. * Serialize all vertices data into a JSON oject
  81240. * @returns a JSON representation of the current geometry data
  81241. */
  81242. serializeVerticeData(): any;
  81243. /**
  81244. * Extracts a clone of a mesh geometry
  81245. * @param mesh defines the source mesh
  81246. * @param id defines the unique ID of the new geometry object
  81247. * @returns the new geometry object
  81248. */
  81249. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  81250. /**
  81251. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  81252. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  81253. * Be aware Math.random() could cause collisions, but:
  81254. * "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"
  81255. * @returns a string containing a new GUID
  81256. */
  81257. static RandomId(): string;
  81258. /** @hidden */
  81259. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  81260. private static _CleanMatricesWeights;
  81261. /**
  81262. * Create a new geometry from persisted data (Using .babylon file format)
  81263. * @param parsedVertexData defines the persisted data
  81264. * @param scene defines the hosting scene
  81265. * @param rootUrl defines the root url to use to load assets (like delayed data)
  81266. * @returns the new geometry object
  81267. */
  81268. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  81269. }
  81270. }
  81271. declare module BABYLON {
  81272. /**
  81273. * Define an interface for all classes that will get and set the data on vertices
  81274. */
  81275. export interface IGetSetVerticesData {
  81276. /**
  81277. * Gets a boolean indicating if specific vertex data is present
  81278. * @param kind defines the vertex data kind to use
  81279. * @returns true is data kind is present
  81280. */
  81281. isVerticesDataPresent(kind: string): boolean;
  81282. /**
  81283. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81284. * @param kind defines the data kind (Position, normal, etc...)
  81285. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81286. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81287. * @returns a float array containing vertex data
  81288. */
  81289. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81290. /**
  81291. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81292. * @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.
  81293. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81294. * @returns the indices array or an empty array if the mesh has no geometry
  81295. */
  81296. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81297. /**
  81298. * Set specific vertex data
  81299. * @param kind defines the data kind (Position, normal, etc...)
  81300. * @param data defines the vertex data to use
  81301. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81302. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81303. */
  81304. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  81305. /**
  81306. * Update a specific associated vertex buffer
  81307. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81308. * - VertexBuffer.PositionKind
  81309. * - VertexBuffer.UVKind
  81310. * - VertexBuffer.UV2Kind
  81311. * - VertexBuffer.UV3Kind
  81312. * - VertexBuffer.UV4Kind
  81313. * - VertexBuffer.UV5Kind
  81314. * - VertexBuffer.UV6Kind
  81315. * - VertexBuffer.ColorKind
  81316. * - VertexBuffer.MatricesIndicesKind
  81317. * - VertexBuffer.MatricesIndicesExtraKind
  81318. * - VertexBuffer.MatricesWeightsKind
  81319. * - VertexBuffer.MatricesWeightsExtraKind
  81320. * @param data defines the data source
  81321. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81322. * @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)
  81323. */
  81324. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  81325. /**
  81326. * Creates a new index buffer
  81327. * @param indices defines the indices to store in the index buffer
  81328. * @param totalVertices defines the total number of vertices (could be null)
  81329. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81330. */
  81331. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  81332. }
  81333. /**
  81334. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  81335. */
  81336. export class VertexData {
  81337. /**
  81338. * Mesh side orientation : usually the external or front surface
  81339. */
  81340. static readonly FRONTSIDE: number;
  81341. /**
  81342. * Mesh side orientation : usually the internal or back surface
  81343. */
  81344. static readonly BACKSIDE: number;
  81345. /**
  81346. * Mesh side orientation : both internal and external or front and back surfaces
  81347. */
  81348. static readonly DOUBLESIDE: number;
  81349. /**
  81350. * Mesh side orientation : by default, `FRONTSIDE`
  81351. */
  81352. static readonly DEFAULTSIDE: number;
  81353. /**
  81354. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  81355. */
  81356. positions: Nullable<FloatArray>;
  81357. /**
  81358. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  81359. */
  81360. normals: Nullable<FloatArray>;
  81361. /**
  81362. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  81363. */
  81364. tangents: Nullable<FloatArray>;
  81365. /**
  81366. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81367. */
  81368. uvs: Nullable<FloatArray>;
  81369. /**
  81370. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81371. */
  81372. uvs2: Nullable<FloatArray>;
  81373. /**
  81374. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81375. */
  81376. uvs3: Nullable<FloatArray>;
  81377. /**
  81378. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81379. */
  81380. uvs4: Nullable<FloatArray>;
  81381. /**
  81382. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81383. */
  81384. uvs5: Nullable<FloatArray>;
  81385. /**
  81386. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81387. */
  81388. uvs6: Nullable<FloatArray>;
  81389. /**
  81390. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  81391. */
  81392. colors: Nullable<FloatArray>;
  81393. /**
  81394. * 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).
  81395. */
  81396. matricesIndices: Nullable<FloatArray>;
  81397. /**
  81398. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  81399. */
  81400. matricesWeights: Nullable<FloatArray>;
  81401. /**
  81402. * An array extending the number of possible indices
  81403. */
  81404. matricesIndicesExtra: Nullable<FloatArray>;
  81405. /**
  81406. * An array extending the number of possible weights when the number of indices is extended
  81407. */
  81408. matricesWeightsExtra: Nullable<FloatArray>;
  81409. /**
  81410. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  81411. */
  81412. indices: Nullable<IndicesArray>;
  81413. /**
  81414. * Uses the passed data array to set the set the values for the specified kind of data
  81415. * @param data a linear array of floating numbers
  81416. * @param kind the type of data that is being set, eg positions, colors etc
  81417. */
  81418. set(data: FloatArray, kind: string): void;
  81419. /**
  81420. * Associates the vertexData to the passed Mesh.
  81421. * Sets it as updatable or not (default `false`)
  81422. * @param mesh the mesh the vertexData is applied to
  81423. * @param updatable when used and having the value true allows new data to update the vertexData
  81424. * @returns the VertexData
  81425. */
  81426. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  81427. /**
  81428. * Associates the vertexData to the passed Geometry.
  81429. * Sets it as updatable or not (default `false`)
  81430. * @param geometry the geometry the vertexData is applied to
  81431. * @param updatable when used and having the value true allows new data to update the vertexData
  81432. * @returns VertexData
  81433. */
  81434. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  81435. /**
  81436. * Updates the associated mesh
  81437. * @param mesh the mesh to be updated
  81438. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81439. * @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
  81440. * @returns VertexData
  81441. */
  81442. updateMesh(mesh: Mesh): VertexData;
  81443. /**
  81444. * Updates the associated geometry
  81445. * @param geometry the geometry to be updated
  81446. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81447. * @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
  81448. * @returns VertexData.
  81449. */
  81450. updateGeometry(geometry: Geometry): VertexData;
  81451. private _applyTo;
  81452. private _update;
  81453. /**
  81454. * Transforms each position and each normal of the vertexData according to the passed Matrix
  81455. * @param matrix the transforming matrix
  81456. * @returns the VertexData
  81457. */
  81458. transform(matrix: Matrix): VertexData;
  81459. /**
  81460. * Merges the passed VertexData into the current one
  81461. * @param other the VertexData to be merged into the current one
  81462. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  81463. * @returns the modified VertexData
  81464. */
  81465. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  81466. private _mergeElement;
  81467. private _validate;
  81468. /**
  81469. * Serializes the VertexData
  81470. * @returns a serialized object
  81471. */
  81472. serialize(): any;
  81473. /**
  81474. * Extracts the vertexData from a mesh
  81475. * @param mesh the mesh from which to extract the VertexData
  81476. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  81477. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81478. * @returns the object VertexData associated to the passed mesh
  81479. */
  81480. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81481. /**
  81482. * Extracts the vertexData from the geometry
  81483. * @param geometry the geometry from which to extract the VertexData
  81484. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  81485. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81486. * @returns the object VertexData associated to the passed mesh
  81487. */
  81488. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81489. private static _ExtractFrom;
  81490. /**
  81491. * Creates the VertexData for a Ribbon
  81492. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  81493. * * pathArray array of paths, each of which an array of successive Vector3
  81494. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  81495. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  81496. * * 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
  81497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81498. * * 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)
  81499. * * 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)
  81500. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  81501. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  81502. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  81503. * @returns the VertexData of the ribbon
  81504. */
  81505. static CreateRibbon(options: {
  81506. pathArray: Vector3[][];
  81507. closeArray?: boolean;
  81508. closePath?: boolean;
  81509. offset?: number;
  81510. sideOrientation?: number;
  81511. frontUVs?: Vector4;
  81512. backUVs?: Vector4;
  81513. invertUV?: boolean;
  81514. uvs?: Vector2[];
  81515. colors?: Color4[];
  81516. }): VertexData;
  81517. /**
  81518. * Creates the VertexData for a box
  81519. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81520. * * size sets the width, height and depth of the box to the value of size, optional default 1
  81521. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  81522. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  81523. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  81524. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  81525. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  81526. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81527. * * 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)
  81528. * * 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)
  81529. * @returns the VertexData of the box
  81530. */
  81531. static CreateBox(options: {
  81532. size?: number;
  81533. width?: number;
  81534. height?: number;
  81535. depth?: number;
  81536. faceUV?: Vector4[];
  81537. faceColors?: Color4[];
  81538. sideOrientation?: number;
  81539. frontUVs?: Vector4;
  81540. backUVs?: Vector4;
  81541. }): VertexData;
  81542. /**
  81543. * Creates the VertexData for an ellipsoid, defaults to a sphere
  81544. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81545. * * segments sets the number of horizontal strips optional, default 32
  81546. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  81547. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  81548. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  81549. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  81550. * * 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
  81551. * * 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
  81552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81553. * * 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)
  81554. * * 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)
  81555. * @returns the VertexData of the ellipsoid
  81556. */
  81557. static CreateSphere(options: {
  81558. segments?: number;
  81559. diameter?: number;
  81560. diameterX?: number;
  81561. diameterY?: number;
  81562. diameterZ?: number;
  81563. arc?: number;
  81564. slice?: number;
  81565. sideOrientation?: number;
  81566. frontUVs?: Vector4;
  81567. backUVs?: Vector4;
  81568. }): VertexData;
  81569. /**
  81570. * Creates the VertexData for a cylinder, cone or prism
  81571. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81572. * * height sets the height (y direction) of the cylinder, optional, default 2
  81573. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  81574. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  81575. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  81576. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81577. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  81578. * * 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
  81579. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81580. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81581. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  81582. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  81583. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81584. * * 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)
  81585. * * 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)
  81586. * @returns the VertexData of the cylinder, cone or prism
  81587. */
  81588. static CreateCylinder(options: {
  81589. height?: number;
  81590. diameterTop?: number;
  81591. diameterBottom?: number;
  81592. diameter?: number;
  81593. tessellation?: number;
  81594. subdivisions?: number;
  81595. arc?: number;
  81596. faceColors?: Color4[];
  81597. faceUV?: Vector4[];
  81598. hasRings?: boolean;
  81599. enclose?: boolean;
  81600. sideOrientation?: number;
  81601. frontUVs?: Vector4;
  81602. backUVs?: Vector4;
  81603. }): VertexData;
  81604. /**
  81605. * Creates the VertexData for a torus
  81606. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81607. * * diameter the diameter of the torus, optional default 1
  81608. * * thickness the diameter of the tube forming the torus, optional default 0.5
  81609. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81610. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81611. * * 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)
  81612. * * 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)
  81613. * @returns the VertexData of the torus
  81614. */
  81615. static CreateTorus(options: {
  81616. diameter?: number;
  81617. thickness?: number;
  81618. tessellation?: number;
  81619. sideOrientation?: number;
  81620. frontUVs?: Vector4;
  81621. backUVs?: Vector4;
  81622. }): VertexData;
  81623. /**
  81624. * Creates the VertexData of the LineSystem
  81625. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  81626. * - lines an array of lines, each line being an array of successive Vector3
  81627. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  81628. * @returns the VertexData of the LineSystem
  81629. */
  81630. static CreateLineSystem(options: {
  81631. lines: Vector3[][];
  81632. colors?: Nullable<Color4[][]>;
  81633. }): VertexData;
  81634. /**
  81635. * Create the VertexData for a DashedLines
  81636. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  81637. * - points an array successive Vector3
  81638. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  81639. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  81640. * - dashNb the intended total number of dashes, optional, default 200
  81641. * @returns the VertexData for the DashedLines
  81642. */
  81643. static CreateDashedLines(options: {
  81644. points: Vector3[];
  81645. dashSize?: number;
  81646. gapSize?: number;
  81647. dashNb?: number;
  81648. }): VertexData;
  81649. /**
  81650. * Creates the VertexData for a Ground
  81651. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81652. * - width the width (x direction) of the ground, optional, default 1
  81653. * - height the height (z direction) of the ground, optional, default 1
  81654. * - subdivisions the number of subdivisions per side, optional, default 1
  81655. * @returns the VertexData of the Ground
  81656. */
  81657. static CreateGround(options: {
  81658. width?: number;
  81659. height?: number;
  81660. subdivisions?: number;
  81661. subdivisionsX?: number;
  81662. subdivisionsY?: number;
  81663. }): VertexData;
  81664. /**
  81665. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  81666. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81667. * * xmin the ground minimum X coordinate, optional, default -1
  81668. * * zmin the ground minimum Z coordinate, optional, default -1
  81669. * * xmax the ground maximum X coordinate, optional, default 1
  81670. * * zmax the ground maximum Z coordinate, optional, default 1
  81671. * * 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}
  81672. * * 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}
  81673. * @returns the VertexData of the TiledGround
  81674. */
  81675. static CreateTiledGround(options: {
  81676. xmin: number;
  81677. zmin: number;
  81678. xmax: number;
  81679. zmax: number;
  81680. subdivisions?: {
  81681. w: number;
  81682. h: number;
  81683. };
  81684. precision?: {
  81685. w: number;
  81686. h: number;
  81687. };
  81688. }): VertexData;
  81689. /**
  81690. * Creates the VertexData of the Ground designed from a heightmap
  81691. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  81692. * * width the width (x direction) of the ground
  81693. * * height the height (z direction) of the ground
  81694. * * subdivisions the number of subdivisions per side
  81695. * * minHeight the minimum altitude on the ground, optional, default 0
  81696. * * maxHeight the maximum altitude on the ground, optional default 1
  81697. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  81698. * * buffer the array holding the image color data
  81699. * * bufferWidth the width of image
  81700. * * bufferHeight the height of image
  81701. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  81702. * @returns the VertexData of the Ground designed from a heightmap
  81703. */
  81704. static CreateGroundFromHeightMap(options: {
  81705. width: number;
  81706. height: number;
  81707. subdivisions: number;
  81708. minHeight: number;
  81709. maxHeight: number;
  81710. colorFilter: Color3;
  81711. buffer: Uint8Array;
  81712. bufferWidth: number;
  81713. bufferHeight: number;
  81714. alphaFilter: number;
  81715. }): VertexData;
  81716. /**
  81717. * Creates the VertexData for a Plane
  81718. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  81719. * * size sets the width and height of the plane to the value of size, optional default 1
  81720. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  81721. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  81722. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81723. * * 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)
  81724. * * 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)
  81725. * @returns the VertexData of the box
  81726. */
  81727. static CreatePlane(options: {
  81728. size?: number;
  81729. width?: number;
  81730. height?: number;
  81731. sideOrientation?: number;
  81732. frontUVs?: Vector4;
  81733. backUVs?: Vector4;
  81734. }): VertexData;
  81735. /**
  81736. * Creates the VertexData of the Disc or regular Polygon
  81737. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  81738. * * radius the radius of the disc, optional default 0.5
  81739. * * tessellation the number of polygon sides, optional, default 64
  81740. * * 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
  81741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81742. * * 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)
  81743. * * 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)
  81744. * @returns the VertexData of the box
  81745. */
  81746. static CreateDisc(options: {
  81747. radius?: number;
  81748. tessellation?: number;
  81749. arc?: number;
  81750. sideOrientation?: number;
  81751. frontUVs?: Vector4;
  81752. backUVs?: Vector4;
  81753. }): VertexData;
  81754. /**
  81755. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  81756. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  81757. * @param polygon a mesh built from polygonTriangulation.build()
  81758. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81759. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81760. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81761. * @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)
  81762. * @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)
  81763. * @returns the VertexData of the Polygon
  81764. */
  81765. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  81766. /**
  81767. * Creates the VertexData of the IcoSphere
  81768. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  81769. * * radius the radius of the IcoSphere, optional default 1
  81770. * * radiusX allows stretching in the x direction, optional, default radius
  81771. * * radiusY allows stretching in the y direction, optional, default radius
  81772. * * radiusZ allows stretching in the z direction, optional, default radius
  81773. * * flat when true creates a flat shaded mesh, optional, default true
  81774. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81775. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81776. * * 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)
  81777. * * 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)
  81778. * @returns the VertexData of the IcoSphere
  81779. */
  81780. static CreateIcoSphere(options: {
  81781. radius?: number;
  81782. radiusX?: number;
  81783. radiusY?: number;
  81784. radiusZ?: number;
  81785. flat?: boolean;
  81786. subdivisions?: number;
  81787. sideOrientation?: number;
  81788. frontUVs?: Vector4;
  81789. backUVs?: Vector4;
  81790. }): VertexData;
  81791. /**
  81792. * Creates the VertexData for a Polyhedron
  81793. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  81794. * * type provided types are:
  81795. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  81796. * * 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)
  81797. * * size the size of the IcoSphere, optional default 1
  81798. * * sizeX allows stretching in the x direction, optional, default size
  81799. * * sizeY allows stretching in the y direction, optional, default size
  81800. * * sizeZ allows stretching in the z direction, optional, default size
  81801. * * 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
  81802. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81803. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81804. * * flat when true creates a flat shaded mesh, optional, default true
  81805. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81806. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81807. * * 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)
  81808. * * 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)
  81809. * @returns the VertexData of the Polyhedron
  81810. */
  81811. static CreatePolyhedron(options: {
  81812. type?: number;
  81813. size?: number;
  81814. sizeX?: number;
  81815. sizeY?: number;
  81816. sizeZ?: number;
  81817. custom?: any;
  81818. faceUV?: Vector4[];
  81819. faceColors?: Color4[];
  81820. flat?: boolean;
  81821. sideOrientation?: number;
  81822. frontUVs?: Vector4;
  81823. backUVs?: Vector4;
  81824. }): VertexData;
  81825. /**
  81826. * Creates the VertexData for a TorusKnot
  81827. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  81828. * * radius the radius of the torus knot, optional, default 2
  81829. * * tube the thickness of the tube, optional, default 0.5
  81830. * * radialSegments the number of sides on each tube segments, optional, default 32
  81831. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  81832. * * p the number of windings around the z axis, optional, default 2
  81833. * * q the number of windings around the x axis, optional, default 3
  81834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81835. * * 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)
  81836. * * 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)
  81837. * @returns the VertexData of the Torus Knot
  81838. */
  81839. static CreateTorusKnot(options: {
  81840. radius?: number;
  81841. tube?: number;
  81842. radialSegments?: number;
  81843. tubularSegments?: number;
  81844. p?: number;
  81845. q?: number;
  81846. sideOrientation?: number;
  81847. frontUVs?: Vector4;
  81848. backUVs?: Vector4;
  81849. }): VertexData;
  81850. /**
  81851. * Compute normals for given positions and indices
  81852. * @param positions an array of vertex positions, [...., x, y, z, ......]
  81853. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  81854. * @param normals an array of vertex normals, [...., x, y, z, ......]
  81855. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  81856. * * facetNormals : optional array of facet normals (vector3)
  81857. * * facetPositions : optional array of facet positions (vector3)
  81858. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  81859. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  81860. * * bInfo : optional bounding info, required for facetPartitioning computation
  81861. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  81862. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  81863. * * useRightHandedSystem: optional boolean to for right handed system computation
  81864. * * depthSort : optional boolean to enable the facet depth sort computation
  81865. * * distanceTo : optional Vector3 to compute the facet depth from this location
  81866. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  81867. */
  81868. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  81869. facetNormals?: any;
  81870. facetPositions?: any;
  81871. facetPartitioning?: any;
  81872. ratio?: number;
  81873. bInfo?: any;
  81874. bbSize?: Vector3;
  81875. subDiv?: any;
  81876. useRightHandedSystem?: boolean;
  81877. depthSort?: boolean;
  81878. distanceTo?: Vector3;
  81879. depthSortedFacets?: any;
  81880. }): void;
  81881. /** @hidden */
  81882. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  81883. /**
  81884. * Applies VertexData created from the imported parameters to the geometry
  81885. * @param parsedVertexData the parsed data from an imported file
  81886. * @param geometry the geometry to apply the VertexData to
  81887. */
  81888. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  81889. }
  81890. }
  81891. declare module BABYLON {
  81892. /**
  81893. * Class containing static functions to help procedurally build meshes
  81894. */
  81895. export class DiscBuilder {
  81896. /**
  81897. * Creates a plane polygonal mesh. By default, this is a disc
  81898. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  81899. * * 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
  81900. * * 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
  81901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81904. * @param name defines the name of the mesh
  81905. * @param options defines the options used to create the mesh
  81906. * @param scene defines the hosting scene
  81907. * @returns the plane polygonal mesh
  81908. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  81909. */
  81910. static CreateDisc(name: string, options: {
  81911. radius?: number;
  81912. tessellation?: number;
  81913. arc?: number;
  81914. updatable?: boolean;
  81915. sideOrientation?: number;
  81916. frontUVs?: Vector4;
  81917. backUVs?: Vector4;
  81918. }, scene?: Nullable<Scene>): Mesh;
  81919. }
  81920. }
  81921. declare module BABYLON {
  81922. /**
  81923. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  81924. *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.
  81925. * The SPS is also a particle system. It provides some methods to manage the particles.
  81926. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  81927. *
  81928. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  81929. */
  81930. export class SolidParticleSystem implements IDisposable {
  81931. /**
  81932. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  81933. * Example : var p = SPS.particles[i];
  81934. */
  81935. particles: SolidParticle[];
  81936. /**
  81937. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  81938. */
  81939. nbParticles: number;
  81940. /**
  81941. * If the particles must ever face the camera (default false). Useful for planar particles.
  81942. */
  81943. billboard: boolean;
  81944. /**
  81945. * Recompute normals when adding a shape
  81946. */
  81947. recomputeNormals: boolean;
  81948. /**
  81949. * This a counter ofr your own usage. It's not set by any SPS functions.
  81950. */
  81951. counter: number;
  81952. /**
  81953. * The SPS name. This name is also given to the underlying mesh.
  81954. */
  81955. name: string;
  81956. /**
  81957. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  81958. */
  81959. mesh: Mesh;
  81960. /**
  81961. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  81962. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  81963. */
  81964. vars: any;
  81965. /**
  81966. * This array is populated when the SPS is set as 'pickable'.
  81967. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  81968. * Each element of this array is an object `{idx: int, faceId: int}`.
  81969. * `idx` is the picked particle index in the `SPS.particles` array
  81970. * `faceId` is the picked face index counted within this particle.
  81971. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  81972. */
  81973. pickedParticles: {
  81974. idx: number;
  81975. faceId: number;
  81976. }[];
  81977. /**
  81978. * This array is populated when `enableDepthSort` is set to true.
  81979. * Each element of this array is an instance of the class DepthSortedParticle.
  81980. */
  81981. depthSortedParticles: DepthSortedParticle[];
  81982. /**
  81983. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  81984. * @hidden
  81985. */
  81986. _bSphereOnly: boolean;
  81987. /**
  81988. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  81989. * @hidden
  81990. */
  81991. _bSphereRadiusFactor: number;
  81992. private _scene;
  81993. private _positions;
  81994. private _indices;
  81995. private _normals;
  81996. private _colors;
  81997. private _uvs;
  81998. private _indices32;
  81999. private _positions32;
  82000. private _normals32;
  82001. private _fixedNormal32;
  82002. private _colors32;
  82003. private _uvs32;
  82004. private _index;
  82005. private _updatable;
  82006. private _pickable;
  82007. private _isVisibilityBoxLocked;
  82008. private _alwaysVisible;
  82009. private _depthSort;
  82010. private _shapeCounter;
  82011. private _copy;
  82012. private _color;
  82013. private _computeParticleColor;
  82014. private _computeParticleTexture;
  82015. private _computeParticleRotation;
  82016. private _computeParticleVertex;
  82017. private _computeBoundingBox;
  82018. private _depthSortParticles;
  82019. private _camera;
  82020. private _mustUnrotateFixedNormals;
  82021. private _particlesIntersect;
  82022. private _needs32Bits;
  82023. /**
  82024. * Creates a SPS (Solid Particle System) object.
  82025. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82026. * @param scene (Scene) is the scene in which the SPS is added.
  82027. * @param options defines the options of the sps e.g.
  82028. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82029. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82030. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82031. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82032. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82033. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82034. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82035. */
  82036. constructor(name: string, scene: Scene, options?: {
  82037. updatable?: boolean;
  82038. isPickable?: boolean;
  82039. enableDepthSort?: boolean;
  82040. particleIntersection?: boolean;
  82041. boundingSphereOnly?: boolean;
  82042. bSphereRadiusFactor?: number;
  82043. });
  82044. /**
  82045. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82046. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82047. * @returns the created mesh
  82048. */
  82049. buildMesh(): Mesh;
  82050. /**
  82051. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82052. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82053. * Thus the particles generated from `digest()` have their property `position` set yet.
  82054. * @param mesh ( Mesh ) is the mesh to be digested
  82055. * @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
  82056. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82057. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82058. * @returns the current SPS
  82059. */
  82060. digest(mesh: Mesh, options?: {
  82061. facetNb?: number;
  82062. number?: number;
  82063. delta?: number;
  82064. }): SolidParticleSystem;
  82065. private _unrotateFixedNormals;
  82066. private _resetCopy;
  82067. private _meshBuilder;
  82068. private _posToShape;
  82069. private _uvsToShapeUV;
  82070. private _addParticle;
  82071. /**
  82072. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82073. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82074. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82075. * @param nb (positive integer) the number of particles to be created from this model
  82076. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82077. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82078. * @returns the number of shapes in the system
  82079. */
  82080. addShape(mesh: Mesh, nb: number, options?: {
  82081. positionFunction?: any;
  82082. vertexFunction?: any;
  82083. }): number;
  82084. private _rebuildParticle;
  82085. /**
  82086. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82087. * @returns the SPS.
  82088. */
  82089. rebuildMesh(): SolidParticleSystem;
  82090. /**
  82091. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82092. * This method calls `updateParticle()` for each particle of the SPS.
  82093. * For an animated SPS, it is usually called within the render loop.
  82094. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82095. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82096. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82097. * @returns the SPS.
  82098. */
  82099. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82100. /**
  82101. * Disposes the SPS.
  82102. */
  82103. dispose(): void;
  82104. /**
  82105. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82106. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82107. * @returns the SPS.
  82108. */
  82109. refreshVisibleSize(): SolidParticleSystem;
  82110. /**
  82111. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82112. * @param size the size (float) of the visibility box
  82113. * note : this doesn't lock the SPS mesh bounding box.
  82114. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82115. */
  82116. setVisibilityBox(size: number): void;
  82117. /**
  82118. * Gets whether the SPS as always visible or not
  82119. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82120. */
  82121. /**
  82122. * Sets the SPS as always visible or not
  82123. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82124. */
  82125. isAlwaysVisible: boolean;
  82126. /**
  82127. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82128. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82129. */
  82130. /**
  82131. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82132. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82133. */
  82134. isVisibilityBoxLocked: boolean;
  82135. /**
  82136. * Tells to `setParticles()` to compute the particle rotations or not.
  82137. * Default value : true. The SPS is faster when it's set to false.
  82138. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82139. */
  82140. /**
  82141. * Gets if `setParticles()` computes the particle rotations or not.
  82142. * Default value : true. The SPS is faster when it's set to false.
  82143. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82144. */
  82145. computeParticleRotation: boolean;
  82146. /**
  82147. * Tells to `setParticles()` to compute the particle colors or not.
  82148. * Default value : true. The SPS is faster when it's set to false.
  82149. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82150. */
  82151. /**
  82152. * Gets if `setParticles()` computes the particle colors or not.
  82153. * Default value : true. The SPS is faster when it's set to false.
  82154. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82155. */
  82156. computeParticleColor: boolean;
  82157. /**
  82158. * Gets if `setParticles()` computes the particle textures or not.
  82159. * Default value : true. The SPS is faster when it's set to false.
  82160. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82161. */
  82162. computeParticleTexture: boolean;
  82163. /**
  82164. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82165. * Default value : false. The SPS is faster when it's set to false.
  82166. * Note : the particle custom vertex positions aren't stored values.
  82167. */
  82168. /**
  82169. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82170. * Default value : false. The SPS is faster when it's set to false.
  82171. * Note : the particle custom vertex positions aren't stored values.
  82172. */
  82173. computeParticleVertex: boolean;
  82174. /**
  82175. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82176. */
  82177. /**
  82178. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82179. */
  82180. computeBoundingBox: boolean;
  82181. /**
  82182. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82183. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82184. * Default : `true`
  82185. */
  82186. /**
  82187. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82188. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82189. * Default : `true`
  82190. */
  82191. depthSortParticles: boolean;
  82192. /**
  82193. * This function does nothing. It may be overwritten to set all the particle first values.
  82194. * The SPS doesn't call this function, you may have to call it by your own.
  82195. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82196. */
  82197. initParticles(): void;
  82198. /**
  82199. * This function does nothing. It may be overwritten to recycle a particle.
  82200. * The SPS doesn't call this function, you may have to call it by your own.
  82201. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82202. * @param particle The particle to recycle
  82203. * @returns the recycled particle
  82204. */
  82205. recycleParticle(particle: SolidParticle): SolidParticle;
  82206. /**
  82207. * Updates a particle : this function should be overwritten by the user.
  82208. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82209. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82210. * @example : just set a particle position or velocity and recycle conditions
  82211. * @param particle The particle to update
  82212. * @returns the updated particle
  82213. */
  82214. updateParticle(particle: SolidParticle): SolidParticle;
  82215. /**
  82216. * Updates a vertex of a particle : it can be overwritten by the user.
  82217. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82218. * @param particle the current particle
  82219. * @param vertex the current index of the current particle
  82220. * @param pt the index of the current vertex in the particle shape
  82221. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82222. * @example : just set a vertex particle position
  82223. * @returns the updated vertex
  82224. */
  82225. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  82226. /**
  82227. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  82228. * This does nothing and may be overwritten by the user.
  82229. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82230. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82231. * @param update the boolean update value actually passed to setParticles()
  82232. */
  82233. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82234. /**
  82235. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  82236. * This will be passed three parameters.
  82237. * This does nothing and may be overwritten by the user.
  82238. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82239. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82240. * @param update the boolean update value actually passed to setParticles()
  82241. */
  82242. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82243. }
  82244. }
  82245. declare module BABYLON {
  82246. /**
  82247. * Represents one particle of a solid particle system.
  82248. */
  82249. export class SolidParticle {
  82250. /**
  82251. * particle global index
  82252. */
  82253. idx: number;
  82254. /**
  82255. * The color of the particle
  82256. */
  82257. color: Nullable<Color4>;
  82258. /**
  82259. * The world space position of the particle.
  82260. */
  82261. position: Vector3;
  82262. /**
  82263. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  82264. */
  82265. rotation: Vector3;
  82266. /**
  82267. * The world space rotation quaternion of the particle.
  82268. */
  82269. rotationQuaternion: Nullable<Quaternion>;
  82270. /**
  82271. * The scaling of the particle.
  82272. */
  82273. scaling: Vector3;
  82274. /**
  82275. * The uvs of the particle.
  82276. */
  82277. uvs: Vector4;
  82278. /**
  82279. * The current speed of the particle.
  82280. */
  82281. velocity: Vector3;
  82282. /**
  82283. * The pivot point in the particle local space.
  82284. */
  82285. pivot: Vector3;
  82286. /**
  82287. * Must the particle be translated from its pivot point in its local space ?
  82288. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  82289. * Default : false
  82290. */
  82291. translateFromPivot: boolean;
  82292. /**
  82293. * Is the particle active or not ?
  82294. */
  82295. alive: boolean;
  82296. /**
  82297. * Is the particle visible or not ?
  82298. */
  82299. isVisible: boolean;
  82300. /**
  82301. * Index of this particle in the global "positions" array (Internal use)
  82302. * @hidden
  82303. */
  82304. _pos: number;
  82305. /**
  82306. * @hidden Index of this particle in the global "indices" array (Internal use)
  82307. */
  82308. _ind: number;
  82309. /**
  82310. * @hidden ModelShape of this particle (Internal use)
  82311. */
  82312. _model: ModelShape;
  82313. /**
  82314. * ModelShape id of this particle
  82315. */
  82316. shapeId: number;
  82317. /**
  82318. * Index of the particle in its shape id (Internal use)
  82319. */
  82320. idxInShape: number;
  82321. /**
  82322. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  82323. */
  82324. _modelBoundingInfo: BoundingInfo;
  82325. /**
  82326. * @hidden Particle BoundingInfo object (Internal use)
  82327. */
  82328. _boundingInfo: BoundingInfo;
  82329. /**
  82330. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  82331. */
  82332. _sps: SolidParticleSystem;
  82333. /**
  82334. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  82335. */
  82336. _stillInvisible: boolean;
  82337. /**
  82338. * @hidden Last computed particle rotation matrix
  82339. */
  82340. _rotationMatrix: number[];
  82341. /**
  82342. * Parent particle Id, if any.
  82343. * Default null.
  82344. */
  82345. parentId: Nullable<number>;
  82346. /**
  82347. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  82348. * The possible values are :
  82349. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82350. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82351. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82352. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82353. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82354. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  82355. * */
  82356. cullingStrategy: number;
  82357. /**
  82358. * @hidden Internal global position in the SPS.
  82359. */
  82360. _globalPosition: Vector3;
  82361. /**
  82362. * Creates a Solid Particle object.
  82363. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  82364. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  82365. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  82366. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  82367. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  82368. * @param shapeId (integer) is the model shape identifier in the SPS.
  82369. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  82370. * @param sps defines the sps it is associated to
  82371. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  82372. */
  82373. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  82374. /**
  82375. * Legacy support, changed scale to scaling
  82376. */
  82377. /**
  82378. * Legacy support, changed scale to scaling
  82379. */
  82380. scale: Vector3;
  82381. /**
  82382. * Legacy support, changed quaternion to rotationQuaternion
  82383. */
  82384. /**
  82385. * Legacy support, changed quaternion to rotationQuaternion
  82386. */
  82387. quaternion: Nullable<Quaternion>;
  82388. /**
  82389. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  82390. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  82391. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  82392. * @returns true if it intersects
  82393. */
  82394. intersectsMesh(target: Mesh | SolidParticle): boolean;
  82395. /**
  82396. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  82397. * A particle is in the frustum if its bounding box intersects the frustum
  82398. * @param frustumPlanes defines the frustum to test
  82399. * @returns true if the particle is in the frustum planes
  82400. */
  82401. isInFrustum(frustumPlanes: Plane[]): boolean;
  82402. /**
  82403. * get the rotation matrix of the particle
  82404. * @hidden
  82405. */
  82406. getRotationMatrix(m: Matrix): void;
  82407. }
  82408. /**
  82409. * Represents the shape of the model used by one particle of a solid particle system.
  82410. * SPS internal tool, don't use it manually.
  82411. */
  82412. export class ModelShape {
  82413. /**
  82414. * The shape id
  82415. * @hidden
  82416. */
  82417. shapeID: number;
  82418. /**
  82419. * flat array of model positions (internal use)
  82420. * @hidden
  82421. */
  82422. _shape: Vector3[];
  82423. /**
  82424. * flat array of model UVs (internal use)
  82425. * @hidden
  82426. */
  82427. _shapeUV: number[];
  82428. /**
  82429. * length of the shape in the model indices array (internal use)
  82430. * @hidden
  82431. */
  82432. _indicesLength: number;
  82433. /**
  82434. * Custom position function (internal use)
  82435. * @hidden
  82436. */
  82437. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  82438. /**
  82439. * Custom vertex function (internal use)
  82440. * @hidden
  82441. */
  82442. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  82443. /**
  82444. * 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.
  82445. * SPS internal tool, don't use it manually.
  82446. * @hidden
  82447. */
  82448. 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>);
  82449. }
  82450. /**
  82451. * Represents a Depth Sorted Particle in the solid particle system.
  82452. */
  82453. export class DepthSortedParticle {
  82454. /**
  82455. * Index of the particle in the "indices" array
  82456. */
  82457. ind: number;
  82458. /**
  82459. * Length of the particle shape in the "indices" array
  82460. */
  82461. indicesLength: number;
  82462. /**
  82463. * Squared distance from the particle to the camera
  82464. */
  82465. sqDistance: number;
  82466. }
  82467. }
  82468. declare module BABYLON {
  82469. /**
  82470. * Class used to store all common mesh properties
  82471. */
  82472. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  82473. /** No occlusion */
  82474. static OCCLUSION_TYPE_NONE: number;
  82475. /** Occlusion set to optimisitic */
  82476. static OCCLUSION_TYPE_OPTIMISTIC: number;
  82477. /** Occlusion set to strict */
  82478. static OCCLUSION_TYPE_STRICT: number;
  82479. /** Use an accurante occlusion algorithm */
  82480. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  82481. /** Use a conservative occlusion algorithm */
  82482. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  82483. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82484. * Test order :
  82485. * Is the bounding sphere outside the frustum ?
  82486. * If not, are the bounding box vertices outside the frustum ?
  82487. * It not, then the cullable object is in the frustum.
  82488. */
  82489. static readonly CULLINGSTRATEGY_STANDARD: number;
  82490. /** Culling strategy : Bounding Sphere Only.
  82491. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82492. * It's also less accurate than the standard because some not visible objects can still be selected.
  82493. * Test : is the bounding sphere outside the frustum ?
  82494. * If not, then the cullable object is in the frustum.
  82495. */
  82496. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82497. /** Culling strategy : Optimistic Inclusion.
  82498. * This in an inclusion test first, then the standard exclusion test.
  82499. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82500. * 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.
  82501. * Anyway, it's as accurate as the standard strategy.
  82502. * Test :
  82503. * Is the cullable object bounding sphere center in the frustum ?
  82504. * If not, apply the default culling strategy.
  82505. */
  82506. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82507. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82508. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82509. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82510. * 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.
  82511. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82512. * Test :
  82513. * Is the cullable object bounding sphere center in the frustum ?
  82514. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82515. */
  82516. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82517. /**
  82518. * No billboard
  82519. */
  82520. static readonly BILLBOARDMODE_NONE: number;
  82521. /** Billboard on X axis */
  82522. static readonly BILLBOARDMODE_X: number;
  82523. /** Billboard on Y axis */
  82524. static readonly BILLBOARDMODE_Y: number;
  82525. /** Billboard on Z axis */
  82526. static readonly BILLBOARDMODE_Z: number;
  82527. /** Billboard on all axes */
  82528. static readonly BILLBOARDMODE_ALL: number;
  82529. private _facetData;
  82530. /**
  82531. * The culling strategy to use to check whether the mesh must be rendered or not.
  82532. * This value can be changed at any time and will be used on the next render mesh selection.
  82533. * The possible values are :
  82534. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82535. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82536. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82537. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82538. * Please read each static variable documentation to get details about the culling process.
  82539. * */
  82540. cullingStrategy: number;
  82541. /**
  82542. * Gets the number of facets in the mesh
  82543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82544. */
  82545. readonly facetNb: number;
  82546. /**
  82547. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82549. */
  82550. partitioningSubdivisions: number;
  82551. /**
  82552. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82553. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82554. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82555. */
  82556. partitioningBBoxRatio: number;
  82557. /**
  82558. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82559. * Works only for updatable meshes.
  82560. * Doesn't work with multi-materials
  82561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82562. */
  82563. mustDepthSortFacets: boolean;
  82564. /**
  82565. * The location (Vector3) where the facet depth sort must be computed from.
  82566. * By default, the active camera position.
  82567. * Used only when facet depth sort is enabled
  82568. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82569. */
  82570. facetDepthSortFrom: Vector3;
  82571. /**
  82572. * gets a boolean indicating if facetData is enabled
  82573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82574. */
  82575. readonly isFacetDataEnabled: boolean;
  82576. /** @hidden */
  82577. _updateNonUniformScalingState(value: boolean): boolean;
  82578. /**
  82579. * An event triggered when this mesh collides with another one
  82580. */
  82581. onCollideObservable: Observable<AbstractMesh>;
  82582. private _onCollideObserver;
  82583. /** Set a function to call when this mesh collides with another one */
  82584. onCollide: () => void;
  82585. /**
  82586. * An event triggered when the collision's position changes
  82587. */
  82588. onCollisionPositionChangeObservable: Observable<Vector3>;
  82589. private _onCollisionPositionChangeObserver;
  82590. /** Set a function to call when the collision's position changes */
  82591. onCollisionPositionChange: () => void;
  82592. /**
  82593. * An event triggered when material is changed
  82594. */
  82595. onMaterialChangedObservable: Observable<AbstractMesh>;
  82596. /**
  82597. * Gets or sets the orientation for POV movement & rotation
  82598. */
  82599. definedFacingForward: boolean;
  82600. /** @hidden */
  82601. _occlusionQuery: Nullable<WebGLQuery>;
  82602. private _visibility;
  82603. /**
  82604. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82605. */
  82606. /**
  82607. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82608. */
  82609. visibility: number;
  82610. /** Gets or sets the alpha index used to sort transparent meshes
  82611. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  82612. */
  82613. alphaIndex: number;
  82614. /**
  82615. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  82616. */
  82617. isVisible: boolean;
  82618. /**
  82619. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82620. */
  82621. isPickable: boolean;
  82622. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  82623. showSubMeshesBoundingBox: boolean;
  82624. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  82625. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  82626. */
  82627. isBlocker: boolean;
  82628. /**
  82629. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  82630. */
  82631. enablePointerMoveEvents: boolean;
  82632. /**
  82633. * Specifies the rendering group id for this mesh (0 by default)
  82634. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82635. */
  82636. renderingGroupId: number;
  82637. private _material;
  82638. /** Gets or sets current material */
  82639. material: Nullable<Material>;
  82640. private _receiveShadows;
  82641. /**
  82642. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  82643. * @see http://doc.babylonjs.com/babylon101/shadows
  82644. */
  82645. receiveShadows: boolean;
  82646. /** Defines color to use when rendering outline */
  82647. outlineColor: Color3;
  82648. /** Define width to use when rendering outline */
  82649. outlineWidth: number;
  82650. /** Defines color to use when rendering overlay */
  82651. overlayColor: Color3;
  82652. /** Defines alpha to use when rendering overlay */
  82653. overlayAlpha: number;
  82654. private _hasVertexAlpha;
  82655. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  82656. hasVertexAlpha: boolean;
  82657. private _useVertexColors;
  82658. /** 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) */
  82659. useVertexColors: boolean;
  82660. private _computeBonesUsingShaders;
  82661. /**
  82662. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  82663. */
  82664. computeBonesUsingShaders: boolean;
  82665. private _numBoneInfluencers;
  82666. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  82667. numBoneInfluencers: number;
  82668. private _applyFog;
  82669. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  82670. applyFog: boolean;
  82671. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  82672. useOctreeForRenderingSelection: boolean;
  82673. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  82674. useOctreeForPicking: boolean;
  82675. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  82676. useOctreeForCollisions: boolean;
  82677. private _layerMask;
  82678. /**
  82679. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  82680. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  82681. */
  82682. layerMask: number;
  82683. /**
  82684. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  82685. */
  82686. alwaysSelectAsActiveMesh: boolean;
  82687. /**
  82688. * Gets or sets the current action manager
  82689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82690. */
  82691. actionManager: Nullable<AbstractActionManager>;
  82692. private _checkCollisions;
  82693. private _collisionMask;
  82694. private _collisionGroup;
  82695. /**
  82696. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  82697. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82698. */
  82699. ellipsoid: Vector3;
  82700. /**
  82701. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  82702. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82703. */
  82704. ellipsoidOffset: Vector3;
  82705. private _collider;
  82706. private _oldPositionForCollisions;
  82707. private _diffPositionForCollisions;
  82708. /**
  82709. * Gets or sets a collision mask used to mask collisions (default is -1).
  82710. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82711. */
  82712. collisionMask: number;
  82713. /**
  82714. * Gets or sets the current collision group mask (-1 by default).
  82715. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82716. */
  82717. collisionGroup: number;
  82718. /**
  82719. * Defines edge width used when edgesRenderer is enabled
  82720. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82721. */
  82722. edgesWidth: number;
  82723. /**
  82724. * Defines edge color used when edgesRenderer is enabled
  82725. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82726. */
  82727. edgesColor: Color4;
  82728. /** @hidden */
  82729. _edgesRenderer: Nullable<IEdgesRenderer>;
  82730. /** @hidden */
  82731. _masterMesh: Nullable<AbstractMesh>;
  82732. /** @hidden */
  82733. _boundingInfo: Nullable<BoundingInfo>;
  82734. /** @hidden */
  82735. _renderId: number;
  82736. /**
  82737. * Gets or sets the list of subMeshes
  82738. * @see http://doc.babylonjs.com/how_to/multi_materials
  82739. */
  82740. subMeshes: SubMesh[];
  82741. /** @hidden */
  82742. _intersectionsInProgress: AbstractMesh[];
  82743. /** @hidden */
  82744. _unIndexed: boolean;
  82745. /** @hidden */
  82746. _lightSources: Light[];
  82747. /** @hidden */
  82748. readonly _positions: Nullable<Vector3[]>;
  82749. /** @hidden */
  82750. _waitingActions: any;
  82751. /** @hidden */
  82752. _waitingFreezeWorldMatrix: Nullable<boolean>;
  82753. private _skeleton;
  82754. /** @hidden */
  82755. _bonesTransformMatrices: Nullable<Float32Array>;
  82756. /**
  82757. * Gets or sets a skeleton to apply skining transformations
  82758. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82759. */
  82760. skeleton: Nullable<Skeleton>;
  82761. /**
  82762. * An event triggered when the mesh is rebuilt.
  82763. */
  82764. onRebuildObservable: Observable<AbstractMesh>;
  82765. /**
  82766. * Creates a new AbstractMesh
  82767. * @param name defines the name of the mesh
  82768. * @param scene defines the hosting scene
  82769. */
  82770. constructor(name: string, scene?: Nullable<Scene>);
  82771. /**
  82772. * Returns the string "AbstractMesh"
  82773. * @returns "AbstractMesh"
  82774. */
  82775. getClassName(): string;
  82776. /**
  82777. * Gets a string representation of the current mesh
  82778. * @param fullDetails defines a boolean indicating if full details must be included
  82779. * @returns a string representation of the current mesh
  82780. */
  82781. toString(fullDetails?: boolean): string;
  82782. /** @hidden */
  82783. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82784. /** @hidden */
  82785. _rebuild(): void;
  82786. /** @hidden */
  82787. _resyncLightSources(): void;
  82788. /** @hidden */
  82789. _resyncLighSource(light: Light): void;
  82790. /** @hidden */
  82791. _unBindEffect(): void;
  82792. /** @hidden */
  82793. _removeLightSource(light: Light): void;
  82794. private _markSubMeshesAsDirty;
  82795. /** @hidden */
  82796. _markSubMeshesAsLightDirty(): void;
  82797. /** @hidden */
  82798. _markSubMeshesAsAttributesDirty(): void;
  82799. /** @hidden */
  82800. _markSubMeshesAsMiscDirty(): void;
  82801. /**
  82802. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  82803. */
  82804. scaling: Vector3;
  82805. /**
  82806. * Returns true if the mesh is blocked. Implemented by child classes
  82807. */
  82808. readonly isBlocked: boolean;
  82809. /**
  82810. * Returns the mesh itself by default. Implemented by child classes
  82811. * @param camera defines the camera to use to pick the right LOD level
  82812. * @returns the currentAbstractMesh
  82813. */
  82814. getLOD(camera: Camera): Nullable<AbstractMesh>;
  82815. /**
  82816. * Returns 0 by default. Implemented by child classes
  82817. * @returns an integer
  82818. */
  82819. getTotalVertices(): number;
  82820. /**
  82821. * Returns a positive integer : the total number of indices in this mesh geometry.
  82822. * @returns the numner of indices or zero if the mesh has no geometry.
  82823. */
  82824. getTotalIndices(): number;
  82825. /**
  82826. * Returns null by default. Implemented by child classes
  82827. * @returns null
  82828. */
  82829. getIndices(): Nullable<IndicesArray>;
  82830. /**
  82831. * Returns the array of the requested vertex data kind. Implemented by child classes
  82832. * @param kind defines the vertex data kind to use
  82833. * @returns null
  82834. */
  82835. getVerticesData(kind: string): Nullable<FloatArray>;
  82836. /**
  82837. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82838. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82839. * Note that a new underlying VertexBuffer object is created each call.
  82840. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82841. * @param kind defines vertex data kind:
  82842. * * VertexBuffer.PositionKind
  82843. * * VertexBuffer.UVKind
  82844. * * VertexBuffer.UV2Kind
  82845. * * VertexBuffer.UV3Kind
  82846. * * VertexBuffer.UV4Kind
  82847. * * VertexBuffer.UV5Kind
  82848. * * VertexBuffer.UV6Kind
  82849. * * VertexBuffer.ColorKind
  82850. * * VertexBuffer.MatricesIndicesKind
  82851. * * VertexBuffer.MatricesIndicesExtraKind
  82852. * * VertexBuffer.MatricesWeightsKind
  82853. * * VertexBuffer.MatricesWeightsExtraKind
  82854. * @param data defines the data source
  82855. * @param updatable defines if the data must be flagged as updatable (or static)
  82856. * @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
  82857. * @returns the current mesh
  82858. */
  82859. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  82860. /**
  82861. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82862. * If the mesh has no geometry, it is simply returned as it is.
  82863. * @param kind defines vertex data kind:
  82864. * * VertexBuffer.PositionKind
  82865. * * VertexBuffer.UVKind
  82866. * * VertexBuffer.UV2Kind
  82867. * * VertexBuffer.UV3Kind
  82868. * * VertexBuffer.UV4Kind
  82869. * * VertexBuffer.UV5Kind
  82870. * * VertexBuffer.UV6Kind
  82871. * * VertexBuffer.ColorKind
  82872. * * VertexBuffer.MatricesIndicesKind
  82873. * * VertexBuffer.MatricesIndicesExtraKind
  82874. * * VertexBuffer.MatricesWeightsKind
  82875. * * VertexBuffer.MatricesWeightsExtraKind
  82876. * @param data defines the data source
  82877. * @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
  82878. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  82879. * @returns the current mesh
  82880. */
  82881. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  82882. /**
  82883. * Sets the mesh indices,
  82884. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82885. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  82886. * @param totalVertices Defines the total number of vertices
  82887. * @returns the current mesh
  82888. */
  82889. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  82890. /**
  82891. * Gets a boolean indicating if specific vertex data is present
  82892. * @param kind defines the vertex data kind to use
  82893. * @returns true is data kind is present
  82894. */
  82895. isVerticesDataPresent(kind: string): boolean;
  82896. /**
  82897. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  82898. * @returns a BoundingInfo
  82899. */
  82900. getBoundingInfo(): BoundingInfo;
  82901. /**
  82902. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82903. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82904. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82905. * @returns the current mesh
  82906. */
  82907. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  82908. /**
  82909. * Overwrite the current bounding info
  82910. * @param boundingInfo defines the new bounding info
  82911. * @returns the current mesh
  82912. */
  82913. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  82914. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  82915. readonly useBones: boolean;
  82916. /** @hidden */
  82917. _preActivate(): void;
  82918. /** @hidden */
  82919. _preActivateForIntermediateRendering(renderId: number): void;
  82920. /** @hidden */
  82921. _activate(renderId: number): void;
  82922. /**
  82923. * Gets the current world matrix
  82924. * @returns a Matrix
  82925. */
  82926. getWorldMatrix(): Matrix;
  82927. /** @hidden */
  82928. _getWorldMatrixDeterminant(): number;
  82929. /**
  82930. * Perform relative position change from the point of view of behind the front of the mesh.
  82931. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82932. * Supports definition of mesh facing forward or backward
  82933. * @param amountRight defines the distance on the right axis
  82934. * @param amountUp defines the distance on the up axis
  82935. * @param amountForward defines the distance on the forward axis
  82936. * @returns the current mesh
  82937. */
  82938. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  82939. /**
  82940. * Calculate relative position change from the point of view of behind the front of the mesh.
  82941. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82942. * Supports definition of mesh facing forward or backward
  82943. * @param amountRight defines the distance on the right axis
  82944. * @param amountUp defines the distance on the up axis
  82945. * @param amountForward defines the distance on the forward axis
  82946. * @returns the new displacement vector
  82947. */
  82948. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  82949. /**
  82950. * Perform relative rotation change from the point of view of behind the front of the mesh.
  82951. * Supports definition of mesh facing forward or backward
  82952. * @param flipBack defines the flip
  82953. * @param twirlClockwise defines the twirl
  82954. * @param tiltRight defines the tilt
  82955. * @returns the current mesh
  82956. */
  82957. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  82958. /**
  82959. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  82960. * Supports definition of mesh facing forward or backward.
  82961. * @param flipBack defines the flip
  82962. * @param twirlClockwise defines the twirl
  82963. * @param tiltRight defines the tilt
  82964. * @returns the new rotation vector
  82965. */
  82966. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  82967. /**
  82968. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  82969. * @param includeDescendants Include bounding info from descendants as well (true by default)
  82970. * @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
  82971. * @returns the new bounding vectors
  82972. */
  82973. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  82974. min: Vector3;
  82975. max: Vector3;
  82976. };
  82977. /**
  82978. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82979. * This means the mesh underlying bounding box and sphere are recomputed.
  82980. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82981. * @returns the current mesh
  82982. */
  82983. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  82984. /** @hidden */
  82985. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  82986. /** @hidden */
  82987. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  82988. /** @hidden */
  82989. _updateBoundingInfo(): AbstractMesh;
  82990. /** @hidden */
  82991. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  82992. /** @hidden */
  82993. protected _afterComputeWorldMatrix(): void;
  82994. /** @hidden */
  82995. readonly _effectiveMesh: AbstractMesh;
  82996. /**
  82997. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  82998. * A mesh is in the frustum if its bounding box intersects the frustum
  82999. * @param frustumPlanes defines the frustum to test
  83000. * @returns true if the mesh is in the frustum planes
  83001. */
  83002. isInFrustum(frustumPlanes: Plane[]): boolean;
  83003. /**
  83004. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83005. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83006. * @param frustumPlanes defines the frustum to test
  83007. * @returns true if the mesh is completely in the frustum planes
  83008. */
  83009. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83010. /**
  83011. * True if the mesh intersects another mesh or a SolidParticle object
  83012. * @param mesh defines a target mesh or SolidParticle to test
  83013. * @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)
  83014. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83015. * @returns true if there is an intersection
  83016. */
  83017. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83018. /**
  83019. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83020. * @param point defines the point to test
  83021. * @returns true if there is an intersection
  83022. */
  83023. intersectsPoint(point: Vector3): boolean;
  83024. /**
  83025. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83026. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83027. */
  83028. checkCollisions: boolean;
  83029. /**
  83030. * Gets Collider object used to compute collisions (not physics)
  83031. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83032. */
  83033. readonly collider: Collider;
  83034. /**
  83035. * Move the mesh using collision engine
  83036. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83037. * @param displacement defines the requested displacement vector
  83038. * @returns the current mesh
  83039. */
  83040. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83041. private _onCollisionPositionChange;
  83042. /** @hidden */
  83043. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83044. /** @hidden */
  83045. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83046. /** @hidden */
  83047. _checkCollision(collider: Collider): AbstractMesh;
  83048. /** @hidden */
  83049. _generatePointsArray(): boolean;
  83050. /**
  83051. * Checks if the passed Ray intersects with the mesh
  83052. * @param ray defines the ray to use
  83053. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83054. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83055. * @returns the picking info
  83056. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83057. */
  83058. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83059. /**
  83060. * Clones the current mesh
  83061. * @param name defines the mesh name
  83062. * @param newParent defines the new mesh parent
  83063. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83064. * @returns the new mesh
  83065. */
  83066. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83067. /**
  83068. * Disposes all the submeshes of the current meshnp
  83069. * @returns the current mesh
  83070. */
  83071. releaseSubMeshes(): AbstractMesh;
  83072. /**
  83073. * Releases resources associated with this abstract mesh.
  83074. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83075. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83076. */
  83077. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83078. /**
  83079. * Adds the passed mesh as a child to the current mesh
  83080. * @param mesh defines the child mesh
  83081. * @returns the current mesh
  83082. */
  83083. addChild(mesh: AbstractMesh): AbstractMesh;
  83084. /**
  83085. * Removes the passed mesh from the current mesh children list
  83086. * @param mesh defines the child mesh
  83087. * @returns the current mesh
  83088. */
  83089. removeChild(mesh: AbstractMesh): AbstractMesh;
  83090. /** @hidden */
  83091. private _initFacetData;
  83092. /**
  83093. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83094. * This method can be called within the render loop.
  83095. * 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
  83096. * @returns the current mesh
  83097. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83098. */
  83099. updateFacetData(): AbstractMesh;
  83100. /**
  83101. * Returns the facetLocalNormals array.
  83102. * The normals are expressed in the mesh local spac
  83103. * @returns an array of Vector3
  83104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83105. */
  83106. getFacetLocalNormals(): Vector3[];
  83107. /**
  83108. * Returns the facetLocalPositions array.
  83109. * The facet positions are expressed in the mesh local space
  83110. * @returns an array of Vector3
  83111. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83112. */
  83113. getFacetLocalPositions(): Vector3[];
  83114. /**
  83115. * Returns the facetLocalPartioning array
  83116. * @returns an array of array of numbers
  83117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83118. */
  83119. getFacetLocalPartitioning(): number[][];
  83120. /**
  83121. * Returns the i-th facet position in the world system.
  83122. * This method allocates a new Vector3 per call
  83123. * @param i defines the facet index
  83124. * @returns a new Vector3
  83125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83126. */
  83127. getFacetPosition(i: number): Vector3;
  83128. /**
  83129. * Sets the reference Vector3 with the i-th facet position in the world system
  83130. * @param i defines the facet index
  83131. * @param ref defines the target vector
  83132. * @returns the current mesh
  83133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83134. */
  83135. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83136. /**
  83137. * Returns the i-th facet normal in the world system.
  83138. * This method allocates a new Vector3 per call
  83139. * @param i defines the facet index
  83140. * @returns a new Vector3
  83141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83142. */
  83143. getFacetNormal(i: number): Vector3;
  83144. /**
  83145. * Sets the reference Vector3 with the i-th facet normal in the world system
  83146. * @param i defines the facet index
  83147. * @param ref defines the target vector
  83148. * @returns the current mesh
  83149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83150. */
  83151. getFacetNormalToRef(i: number, ref: Vector3): this;
  83152. /**
  83153. * 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)
  83154. * @param x defines x coordinate
  83155. * @param y defines y coordinate
  83156. * @param z defines z coordinate
  83157. * @returns the array of facet indexes
  83158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83159. */
  83160. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83161. /**
  83162. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83163. * @param projected sets as the (x,y,z) world projection on the facet
  83164. * @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
  83165. * @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
  83166. * @param x defines x coordinate
  83167. * @param y defines y coordinate
  83168. * @param z defines z coordinate
  83169. * @returns the face index if found (or null instead)
  83170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83171. */
  83172. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83173. /**
  83174. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83175. * @param projected sets as the (x,y,z) local projection on the facet
  83176. * @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
  83177. * @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
  83178. * @param x defines x coordinate
  83179. * @param y defines y coordinate
  83180. * @param z defines z coordinate
  83181. * @returns the face index if found (or null instead)
  83182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83183. */
  83184. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83185. /**
  83186. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83187. * @returns the parameters
  83188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83189. */
  83190. getFacetDataParameters(): any;
  83191. /**
  83192. * Disables the feature FacetData and frees the related memory
  83193. * @returns the current mesh
  83194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83195. */
  83196. disableFacetData(): AbstractMesh;
  83197. /**
  83198. * Updates the AbstractMesh indices array
  83199. * @param indices defines the data source
  83200. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83201. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  83202. * @returns the current mesh
  83203. */
  83204. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83205. /**
  83206. * Creates new normals data for the mesh
  83207. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83208. * @returns the current mesh
  83209. */
  83210. createNormals(updatable: boolean): AbstractMesh;
  83211. /**
  83212. * Align the mesh with a normal
  83213. * @param normal defines the normal to use
  83214. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83215. * @returns the current mesh
  83216. */
  83217. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  83218. /** @hidden */
  83219. _checkOcclusionQuery(): boolean;
  83220. }
  83221. }
  83222. declare module BABYLON {
  83223. /**
  83224. * Interface used to define ActionEvent
  83225. */
  83226. export interface IActionEvent {
  83227. /** The mesh or sprite that triggered the action */
  83228. source: any;
  83229. /** The X mouse cursor position at the time of the event */
  83230. pointerX: number;
  83231. /** The Y mouse cursor position at the time of the event */
  83232. pointerY: number;
  83233. /** The mesh that is currently pointed at (can be null) */
  83234. meshUnderPointer: Nullable<AbstractMesh>;
  83235. /** the original (browser) event that triggered the ActionEvent */
  83236. sourceEvent?: any;
  83237. /** additional data for the event */
  83238. additionalData?: any;
  83239. }
  83240. /**
  83241. * ActionEvent is the event being sent when an action is triggered.
  83242. */
  83243. export class ActionEvent implements IActionEvent {
  83244. /** The mesh or sprite that triggered the action */
  83245. source: any;
  83246. /** The X mouse cursor position at the time of the event */
  83247. pointerX: number;
  83248. /** The Y mouse cursor position at the time of the event */
  83249. pointerY: number;
  83250. /** The mesh that is currently pointed at (can be null) */
  83251. meshUnderPointer: Nullable<AbstractMesh>;
  83252. /** the original (browser) event that triggered the ActionEvent */
  83253. sourceEvent?: any;
  83254. /** additional data for the event */
  83255. additionalData?: any;
  83256. /**
  83257. * Creates a new ActionEvent
  83258. * @param source The mesh or sprite that triggered the action
  83259. * @param pointerX The X mouse cursor position at the time of the event
  83260. * @param pointerY The Y mouse cursor position at the time of the event
  83261. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  83262. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  83263. * @param additionalData additional data for the event
  83264. */
  83265. constructor(
  83266. /** The mesh or sprite that triggered the action */
  83267. source: any,
  83268. /** The X mouse cursor position at the time of the event */
  83269. pointerX: number,
  83270. /** The Y mouse cursor position at the time of the event */
  83271. pointerY: number,
  83272. /** The mesh that is currently pointed at (can be null) */
  83273. meshUnderPointer: Nullable<AbstractMesh>,
  83274. /** the original (browser) event that triggered the ActionEvent */
  83275. sourceEvent?: any,
  83276. /** additional data for the event */
  83277. additionalData?: any);
  83278. /**
  83279. * Helper function to auto-create an ActionEvent from a source mesh.
  83280. * @param source The source mesh that triggered the event
  83281. * @param evt The original (browser) event
  83282. * @param additionalData additional data for the event
  83283. * @returns the new ActionEvent
  83284. */
  83285. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  83286. /**
  83287. * Helper function to auto-create an ActionEvent from a source sprite
  83288. * @param source The source sprite that triggered the event
  83289. * @param scene Scene associated with the sprite
  83290. * @param evt The original (browser) event
  83291. * @param additionalData additional data for the event
  83292. * @returns the new ActionEvent
  83293. */
  83294. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  83295. /**
  83296. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  83297. * @param scene the scene where the event occurred
  83298. * @param evt The original (browser) event
  83299. * @returns the new ActionEvent
  83300. */
  83301. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  83302. /**
  83303. * Helper function to auto-create an ActionEvent from a primitive
  83304. * @param prim defines the target primitive
  83305. * @param pointerPos defines the pointer position
  83306. * @param evt The original (browser) event
  83307. * @param additionalData additional data for the event
  83308. * @returns the new ActionEvent
  83309. */
  83310. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  83311. }
  83312. }
  83313. declare module BABYLON {
  83314. /**
  83315. * Abstract class used to decouple action Manager from scene and meshes.
  83316. * Do not instantiate.
  83317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83318. */
  83319. export abstract class AbstractActionManager implements IDisposable {
  83320. /** Gets the list of active triggers */
  83321. static Triggers: {
  83322. [key: string]: number;
  83323. };
  83324. /** Gets the cursor to use when hovering items */
  83325. hoverCursor: string;
  83326. /** Gets the list of actions */
  83327. actions: IAction[];
  83328. /**
  83329. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  83330. */
  83331. isRecursive: boolean;
  83332. /**
  83333. * Releases all associated resources
  83334. */
  83335. abstract dispose(): void;
  83336. /**
  83337. * Does this action manager has pointer triggers
  83338. */
  83339. abstract readonly hasPointerTriggers: boolean;
  83340. /**
  83341. * Does this action manager has pick triggers
  83342. */
  83343. abstract readonly hasPickTriggers: boolean;
  83344. /**
  83345. * Process a specific trigger
  83346. * @param trigger defines the trigger to process
  83347. * @param evt defines the event details to be processed
  83348. */
  83349. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  83350. /**
  83351. * Does this action manager handles actions of any of the given triggers
  83352. * @param triggers defines the triggers to be tested
  83353. * @return a boolean indicating whether one (or more) of the triggers is handled
  83354. */
  83355. abstract hasSpecificTriggers(triggers: number[]): boolean;
  83356. /**
  83357. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83358. * speed.
  83359. * @param triggerA defines the trigger to be tested
  83360. * @param triggerB defines the trigger to be tested
  83361. * @return a boolean indicating whether one (or more) of the triggers is handled
  83362. */
  83363. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  83364. /**
  83365. * Does this action manager handles actions of a given trigger
  83366. * @param trigger defines the trigger to be tested
  83367. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  83368. * @return whether the trigger is handled
  83369. */
  83370. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  83371. /**
  83372. * Serialize this manager to a JSON object
  83373. * @param name defines the property name to store this manager
  83374. * @returns a JSON representation of this manager
  83375. */
  83376. abstract serialize(name: string): any;
  83377. /**
  83378. * Registers an action to this action manager
  83379. * @param action defines the action to be registered
  83380. * @return the action amended (prepared) after registration
  83381. */
  83382. abstract registerAction(action: IAction): Nullable<IAction>;
  83383. /**
  83384. * Unregisters an action to this action manager
  83385. * @param action defines the action to be unregistered
  83386. * @return a boolean indicating whether the action has been unregistered
  83387. */
  83388. abstract unregisterAction(action: IAction): Boolean;
  83389. /**
  83390. * Does exist one action manager with at least one trigger
  83391. **/
  83392. static readonly HasTriggers: boolean;
  83393. /**
  83394. * Does exist one action manager with at least one pick trigger
  83395. **/
  83396. static readonly HasPickTriggers: boolean;
  83397. /**
  83398. * Does exist one action manager that handles actions of a given trigger
  83399. * @param trigger defines the trigger to be tested
  83400. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  83401. **/
  83402. static HasSpecificTrigger(trigger: number): boolean;
  83403. }
  83404. }
  83405. declare module BABYLON {
  83406. /**
  83407. * Defines how a node can be built from a string name.
  83408. */
  83409. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  83410. /**
  83411. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  83412. */
  83413. export class Node implements IBehaviorAware<Node> {
  83414. /** @hidden */
  83415. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  83416. private static _NodeConstructors;
  83417. /**
  83418. * Add a new node constructor
  83419. * @param type defines the type name of the node to construct
  83420. * @param constructorFunc defines the constructor function
  83421. */
  83422. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  83423. /**
  83424. * Returns a node constructor based on type name
  83425. * @param type defines the type name
  83426. * @param name defines the new node name
  83427. * @param scene defines the hosting scene
  83428. * @param options defines optional options to transmit to constructors
  83429. * @returns the new constructor or null
  83430. */
  83431. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  83432. /**
  83433. * Gets or sets the name of the node
  83434. */
  83435. name: string;
  83436. /**
  83437. * Gets or sets the id of the node
  83438. */
  83439. id: string;
  83440. /**
  83441. * Gets or sets the unique id of the node
  83442. */
  83443. uniqueId: number;
  83444. /**
  83445. * Gets or sets a string used to store user defined state for the node
  83446. */
  83447. state: string;
  83448. /**
  83449. * Gets or sets an object used to store user defined information for the node
  83450. */
  83451. metadata: any;
  83452. /**
  83453. * For internal use only. Please do not use.
  83454. */
  83455. reservedDataStore: any;
  83456. /**
  83457. * List of inspectable custom properties (used by the Inspector)
  83458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83459. */
  83460. inspectableCustomProperties: IInspectable[];
  83461. /**
  83462. * Gets or sets a boolean used to define if the node must be serialized
  83463. */
  83464. doNotSerialize: boolean;
  83465. /** @hidden */
  83466. _isDisposed: boolean;
  83467. /**
  83468. * Gets a list of Animations associated with the node
  83469. */
  83470. animations: Animation[];
  83471. protected _ranges: {
  83472. [name: string]: Nullable<AnimationRange>;
  83473. };
  83474. /**
  83475. * Callback raised when the node is ready to be used
  83476. */
  83477. onReady: (node: Node) => void;
  83478. private _isEnabled;
  83479. private _isParentEnabled;
  83480. private _isReady;
  83481. /** @hidden */
  83482. _currentRenderId: number;
  83483. private _parentRenderId;
  83484. protected _childRenderId: number;
  83485. /** @hidden */
  83486. _waitingParentId: Nullable<string>;
  83487. /** @hidden */
  83488. _scene: Scene;
  83489. /** @hidden */
  83490. _cache: any;
  83491. private _parentNode;
  83492. private _children;
  83493. /** @hidden */
  83494. _worldMatrix: Matrix;
  83495. /** @hidden */
  83496. _worldMatrixDeterminant: number;
  83497. /** @hidden */
  83498. private _sceneRootNodesIndex;
  83499. /**
  83500. * Gets a boolean indicating if the node has been disposed
  83501. * @returns true if the node was disposed
  83502. */
  83503. isDisposed(): boolean;
  83504. /**
  83505. * Gets or sets the parent of the node (without keeping the current position in the scene)
  83506. * @see https://doc.babylonjs.com/how_to/parenting
  83507. */
  83508. parent: Nullable<Node>;
  83509. private addToSceneRootNodes;
  83510. private removeFromSceneRootNodes;
  83511. private _animationPropertiesOverride;
  83512. /**
  83513. * Gets or sets the animation properties override
  83514. */
  83515. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83516. /**
  83517. * Gets a string idenfifying the name of the class
  83518. * @returns "Node" string
  83519. */
  83520. getClassName(): string;
  83521. /** @hidden */
  83522. readonly _isNode: boolean;
  83523. /**
  83524. * An event triggered when the mesh is disposed
  83525. */
  83526. onDisposeObservable: Observable<Node>;
  83527. private _onDisposeObserver;
  83528. /**
  83529. * Sets a callback that will be raised when the node will be disposed
  83530. */
  83531. onDispose: () => void;
  83532. /**
  83533. * Creates a new Node
  83534. * @param name the name and id to be given to this node
  83535. * @param scene the scene this node will be added to
  83536. * @param addToRootNodes the node will be added to scene.rootNodes
  83537. */
  83538. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  83539. /**
  83540. * Gets the scene of the node
  83541. * @returns a scene
  83542. */
  83543. getScene(): Scene;
  83544. /**
  83545. * Gets the engine of the node
  83546. * @returns a Engine
  83547. */
  83548. getEngine(): Engine;
  83549. private _behaviors;
  83550. /**
  83551. * Attach a behavior to the node
  83552. * @see http://doc.babylonjs.com/features/behaviour
  83553. * @param behavior defines the behavior to attach
  83554. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  83555. * @returns the current Node
  83556. */
  83557. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  83558. /**
  83559. * Remove an attached behavior
  83560. * @see http://doc.babylonjs.com/features/behaviour
  83561. * @param behavior defines the behavior to attach
  83562. * @returns the current Node
  83563. */
  83564. removeBehavior(behavior: Behavior<Node>): Node;
  83565. /**
  83566. * Gets the list of attached behaviors
  83567. * @see http://doc.babylonjs.com/features/behaviour
  83568. */
  83569. readonly behaviors: Behavior<Node>[];
  83570. /**
  83571. * Gets an attached behavior by name
  83572. * @param name defines the name of the behavior to look for
  83573. * @see http://doc.babylonjs.com/features/behaviour
  83574. * @returns null if behavior was not found else the requested behavior
  83575. */
  83576. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  83577. /**
  83578. * Returns the latest update of the World matrix
  83579. * @returns a Matrix
  83580. */
  83581. getWorldMatrix(): Matrix;
  83582. /** @hidden */
  83583. _getWorldMatrixDeterminant(): number;
  83584. /**
  83585. * Returns directly the latest state of the mesh World matrix.
  83586. * A Matrix is returned.
  83587. */
  83588. readonly worldMatrixFromCache: Matrix;
  83589. /** @hidden */
  83590. _initCache(): void;
  83591. /** @hidden */
  83592. updateCache(force?: boolean): void;
  83593. /** @hidden */
  83594. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83595. /** @hidden */
  83596. _updateCache(ignoreParentClass?: boolean): void;
  83597. /** @hidden */
  83598. _isSynchronized(): boolean;
  83599. /** @hidden */
  83600. _markSyncedWithParent(): void;
  83601. /** @hidden */
  83602. isSynchronizedWithParent(): boolean;
  83603. /** @hidden */
  83604. isSynchronized(): boolean;
  83605. /**
  83606. * Is this node ready to be used/rendered
  83607. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83608. * @return true if the node is ready
  83609. */
  83610. isReady(completeCheck?: boolean): boolean;
  83611. /**
  83612. * Is this node enabled?
  83613. * 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
  83614. * @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
  83615. * @return whether this node (and its parent) is enabled
  83616. */
  83617. isEnabled(checkAncestors?: boolean): boolean;
  83618. /** @hidden */
  83619. protected _syncParentEnabledState(): void;
  83620. /**
  83621. * Set the enabled state of this node
  83622. * @param value defines the new enabled state
  83623. */
  83624. setEnabled(value: boolean): void;
  83625. /**
  83626. * Is this node a descendant of the given node?
  83627. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  83628. * @param ancestor defines the parent node to inspect
  83629. * @returns a boolean indicating if this node is a descendant of the given node
  83630. */
  83631. isDescendantOf(ancestor: Node): boolean;
  83632. /** @hidden */
  83633. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  83634. /**
  83635. * Will return all nodes that have this node as ascendant
  83636. * @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
  83637. * @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
  83638. * @return all children nodes of all types
  83639. */
  83640. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  83641. /**
  83642. * Get all child-meshes of this node
  83643. * @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)
  83644. * @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
  83645. * @returns an array of AbstractMesh
  83646. */
  83647. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  83648. /**
  83649. * Get all direct children of this node
  83650. * @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
  83651. * @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)
  83652. * @returns an array of Node
  83653. */
  83654. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  83655. /** @hidden */
  83656. _setReady(state: boolean): void;
  83657. /**
  83658. * Get an animation by name
  83659. * @param name defines the name of the animation to look for
  83660. * @returns null if not found else the requested animation
  83661. */
  83662. getAnimationByName(name: string): Nullable<Animation>;
  83663. /**
  83664. * Creates an animation range for this node
  83665. * @param name defines the name of the range
  83666. * @param from defines the starting key
  83667. * @param to defines the end key
  83668. */
  83669. createAnimationRange(name: string, from: number, to: number): void;
  83670. /**
  83671. * Delete a specific animation range
  83672. * @param name defines the name of the range to delete
  83673. * @param deleteFrames defines if animation frames from the range must be deleted as well
  83674. */
  83675. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  83676. /**
  83677. * Get an animation range by name
  83678. * @param name defines the name of the animation range to look for
  83679. * @returns null if not found else the requested animation range
  83680. */
  83681. getAnimationRange(name: string): Nullable<AnimationRange>;
  83682. /**
  83683. * Gets the list of all animation ranges defined on this node
  83684. * @returns an array
  83685. */
  83686. getAnimationRanges(): Nullable<AnimationRange>[];
  83687. /**
  83688. * Will start the animation sequence
  83689. * @param name defines the range frames for animation sequence
  83690. * @param loop defines if the animation should loop (false by default)
  83691. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  83692. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  83693. * @returns the object created for this animation. If range does not exist, it will return null
  83694. */
  83695. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  83696. /**
  83697. * Serialize animation ranges into a JSON compatible object
  83698. * @returns serialization object
  83699. */
  83700. serializeAnimationRanges(): any;
  83701. /**
  83702. * Computes the world matrix of the node
  83703. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83704. * @returns the world matrix
  83705. */
  83706. computeWorldMatrix(force?: boolean): Matrix;
  83707. /**
  83708. * Releases resources associated with this node.
  83709. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83710. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83711. */
  83712. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83713. /**
  83714. * Parse animation range data from a serialization object and store them into a given node
  83715. * @param node defines where to store the animation ranges
  83716. * @param parsedNode defines the serialization object to read data from
  83717. * @param scene defines the hosting scene
  83718. */
  83719. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  83720. }
  83721. }
  83722. declare module BABYLON {
  83723. /**
  83724. * Class used to store any kind of animation
  83725. */
  83726. export class Animation {
  83727. /**Name of the animation */
  83728. name: string;
  83729. /**Property to animate */
  83730. targetProperty: string;
  83731. /**The frames per second of the animation */
  83732. framePerSecond: number;
  83733. /**The data type of the animation */
  83734. dataType: number;
  83735. /**The loop mode of the animation */
  83736. loopMode?: number | undefined;
  83737. /**Specifies if blending should be enabled */
  83738. enableBlending?: boolean | undefined;
  83739. /**
  83740. * Use matrix interpolation instead of using direct key value when animating matrices
  83741. */
  83742. static AllowMatricesInterpolation: boolean;
  83743. /**
  83744. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  83745. */
  83746. static AllowMatrixDecomposeForInterpolation: boolean;
  83747. /**
  83748. * Stores the key frames of the animation
  83749. */
  83750. private _keys;
  83751. /**
  83752. * Stores the easing function of the animation
  83753. */
  83754. private _easingFunction;
  83755. /**
  83756. * @hidden Internal use only
  83757. */
  83758. _runtimeAnimations: RuntimeAnimation[];
  83759. /**
  83760. * The set of event that will be linked to this animation
  83761. */
  83762. private _events;
  83763. /**
  83764. * Stores an array of target property paths
  83765. */
  83766. targetPropertyPath: string[];
  83767. /**
  83768. * Stores the blending speed of the animation
  83769. */
  83770. blendingSpeed: number;
  83771. /**
  83772. * Stores the animation ranges for the animation
  83773. */
  83774. private _ranges;
  83775. /**
  83776. * @hidden Internal use
  83777. */
  83778. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  83779. /**
  83780. * Sets up an animation
  83781. * @param property The property to animate
  83782. * @param animationType The animation type to apply
  83783. * @param framePerSecond The frames per second of the animation
  83784. * @param easingFunction The easing function used in the animation
  83785. * @returns The created animation
  83786. */
  83787. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  83788. /**
  83789. * Create and start an animation on a node
  83790. * @param name defines the name of the global animation that will be run on all nodes
  83791. * @param node defines the root node where the animation will take place
  83792. * @param targetProperty defines property to animate
  83793. * @param framePerSecond defines the number of frame per second yo use
  83794. * @param totalFrame defines the number of frames in total
  83795. * @param from defines the initial value
  83796. * @param to defines the final value
  83797. * @param loopMode defines which loop mode you want to use (off by default)
  83798. * @param easingFunction defines the easing function to use (linear by default)
  83799. * @param onAnimationEnd defines the callback to call when animation end
  83800. * @returns the animatable created for this animation
  83801. */
  83802. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83803. /**
  83804. * Create and start an animation on a node and its descendants
  83805. * @param name defines the name of the global animation that will be run on all nodes
  83806. * @param node defines the root node where the animation will take place
  83807. * @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
  83808. * @param targetProperty defines property to animate
  83809. * @param framePerSecond defines the number of frame per second to use
  83810. * @param totalFrame defines the number of frames in total
  83811. * @param from defines the initial value
  83812. * @param to defines the final value
  83813. * @param loopMode defines which loop mode you want to use (off by default)
  83814. * @param easingFunction defines the easing function to use (linear by default)
  83815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83816. * @returns the list of animatables created for all nodes
  83817. * @example https://www.babylonjs-playground.com/#MH0VLI
  83818. */
  83819. 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[]>;
  83820. /**
  83821. * Creates a new animation, merges it with the existing animations and starts it
  83822. * @param name Name of the animation
  83823. * @param node Node which contains the scene that begins the animations
  83824. * @param targetProperty Specifies which property to animate
  83825. * @param framePerSecond The frames per second of the animation
  83826. * @param totalFrame The total number of frames
  83827. * @param from The frame at the beginning of the animation
  83828. * @param to The frame at the end of the animation
  83829. * @param loopMode Specifies the loop mode of the animation
  83830. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  83831. * @param onAnimationEnd Callback to run once the animation is complete
  83832. * @returns Nullable animation
  83833. */
  83834. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83835. /**
  83836. * Transition property of an host to the target Value
  83837. * @param property The property to transition
  83838. * @param targetValue The target Value of the property
  83839. * @param host The object where the property to animate belongs
  83840. * @param scene Scene used to run the animation
  83841. * @param frameRate Framerate (in frame/s) to use
  83842. * @param transition The transition type we want to use
  83843. * @param duration The duration of the animation, in milliseconds
  83844. * @param onAnimationEnd Callback trigger at the end of the animation
  83845. * @returns Nullable animation
  83846. */
  83847. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  83848. /**
  83849. * Return the array of runtime animations currently using this animation
  83850. */
  83851. readonly runtimeAnimations: RuntimeAnimation[];
  83852. /**
  83853. * Specifies if any of the runtime animations are currently running
  83854. */
  83855. readonly hasRunningRuntimeAnimations: boolean;
  83856. /**
  83857. * Initializes the animation
  83858. * @param name Name of the animation
  83859. * @param targetProperty Property to animate
  83860. * @param framePerSecond The frames per second of the animation
  83861. * @param dataType The data type of the animation
  83862. * @param loopMode The loop mode of the animation
  83863. * @param enableBlending Specifies if blending should be enabled
  83864. */
  83865. constructor(
  83866. /**Name of the animation */
  83867. name: string,
  83868. /**Property to animate */
  83869. targetProperty: string,
  83870. /**The frames per second of the animation */
  83871. framePerSecond: number,
  83872. /**The data type of the animation */
  83873. dataType: number,
  83874. /**The loop mode of the animation */
  83875. loopMode?: number | undefined,
  83876. /**Specifies if blending should be enabled */
  83877. enableBlending?: boolean | undefined);
  83878. /**
  83879. * Converts the animation to a string
  83880. * @param fullDetails support for multiple levels of logging within scene loading
  83881. * @returns String form of the animation
  83882. */
  83883. toString(fullDetails?: boolean): string;
  83884. /**
  83885. * Add an event to this animation
  83886. * @param event Event to add
  83887. */
  83888. addEvent(event: AnimationEvent): void;
  83889. /**
  83890. * Remove all events found at the given frame
  83891. * @param frame The frame to remove events from
  83892. */
  83893. removeEvents(frame: number): void;
  83894. /**
  83895. * Retrieves all the events from the animation
  83896. * @returns Events from the animation
  83897. */
  83898. getEvents(): AnimationEvent[];
  83899. /**
  83900. * Creates an animation range
  83901. * @param name Name of the animation range
  83902. * @param from Starting frame of the animation range
  83903. * @param to Ending frame of the animation
  83904. */
  83905. createRange(name: string, from: number, to: number): void;
  83906. /**
  83907. * Deletes an animation range by name
  83908. * @param name Name of the animation range to delete
  83909. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  83910. */
  83911. deleteRange(name: string, deleteFrames?: boolean): void;
  83912. /**
  83913. * Gets the animation range by name, or null if not defined
  83914. * @param name Name of the animation range
  83915. * @returns Nullable animation range
  83916. */
  83917. getRange(name: string): Nullable<AnimationRange>;
  83918. /**
  83919. * Gets the key frames from the animation
  83920. * @returns The key frames of the animation
  83921. */
  83922. getKeys(): Array<IAnimationKey>;
  83923. /**
  83924. * Gets the highest frame rate of the animation
  83925. * @returns Highest frame rate of the animation
  83926. */
  83927. getHighestFrame(): number;
  83928. /**
  83929. * Gets the easing function of the animation
  83930. * @returns Easing function of the animation
  83931. */
  83932. getEasingFunction(): IEasingFunction;
  83933. /**
  83934. * Sets the easing function of the animation
  83935. * @param easingFunction A custom mathematical formula for animation
  83936. */
  83937. setEasingFunction(easingFunction: EasingFunction): void;
  83938. /**
  83939. * Interpolates a scalar linearly
  83940. * @param startValue Start value of the animation curve
  83941. * @param endValue End value of the animation curve
  83942. * @param gradient Scalar amount to interpolate
  83943. * @returns Interpolated scalar value
  83944. */
  83945. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  83946. /**
  83947. * Interpolates a scalar cubically
  83948. * @param startValue Start value of the animation curve
  83949. * @param outTangent End tangent of the animation
  83950. * @param endValue End value of the animation curve
  83951. * @param inTangent Start tangent of the animation curve
  83952. * @param gradient Scalar amount to interpolate
  83953. * @returns Interpolated scalar value
  83954. */
  83955. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  83956. /**
  83957. * Interpolates a quaternion using a spherical linear interpolation
  83958. * @param startValue Start value of the animation curve
  83959. * @param endValue End value of the animation curve
  83960. * @param gradient Scalar amount to interpolate
  83961. * @returns Interpolated quaternion value
  83962. */
  83963. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  83964. /**
  83965. * Interpolates a quaternion cubically
  83966. * @param startValue Start value of the animation curve
  83967. * @param outTangent End tangent of the animation curve
  83968. * @param endValue End value of the animation curve
  83969. * @param inTangent Start tangent of the animation curve
  83970. * @param gradient Scalar amount to interpolate
  83971. * @returns Interpolated quaternion value
  83972. */
  83973. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  83974. /**
  83975. * Interpolates a Vector3 linearl
  83976. * @param startValue Start value of the animation curve
  83977. * @param endValue End value of the animation curve
  83978. * @param gradient Scalar amount to interpolate
  83979. * @returns Interpolated scalar value
  83980. */
  83981. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  83982. /**
  83983. * Interpolates a Vector3 cubically
  83984. * @param startValue Start value of the animation curve
  83985. * @param outTangent End tangent of the animation
  83986. * @param endValue End value of the animation curve
  83987. * @param inTangent Start tangent of the animation curve
  83988. * @param gradient Scalar amount to interpolate
  83989. * @returns InterpolatedVector3 value
  83990. */
  83991. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  83992. /**
  83993. * Interpolates a Vector2 linearly
  83994. * @param startValue Start value of the animation curve
  83995. * @param endValue End value of the animation curve
  83996. * @param gradient Scalar amount to interpolate
  83997. * @returns Interpolated Vector2 value
  83998. */
  83999. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  84000. /**
  84001. * Interpolates a Vector2 cubically
  84002. * @param startValue Start value of the animation curve
  84003. * @param outTangent End tangent of the animation
  84004. * @param endValue End value of the animation curve
  84005. * @param inTangent Start tangent of the animation curve
  84006. * @param gradient Scalar amount to interpolate
  84007. * @returns Interpolated Vector2 value
  84008. */
  84009. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  84010. /**
  84011. * Interpolates a size linearly
  84012. * @param startValue Start value of the animation curve
  84013. * @param endValue End value of the animation curve
  84014. * @param gradient Scalar amount to interpolate
  84015. * @returns Interpolated Size value
  84016. */
  84017. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84018. /**
  84019. * Interpolates a Color3 linearly
  84020. * @param startValue Start value of the animation curve
  84021. * @param endValue End value of the animation curve
  84022. * @param gradient Scalar amount to interpolate
  84023. * @returns Interpolated Color3 value
  84024. */
  84025. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84026. /**
  84027. * @hidden Internal use only
  84028. */
  84029. _getKeyValue(value: any): any;
  84030. /**
  84031. * @hidden Internal use only
  84032. */
  84033. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  84034. /**
  84035. * Defines the function to use to interpolate matrices
  84036. * @param startValue defines the start matrix
  84037. * @param endValue defines the end matrix
  84038. * @param gradient defines the gradient between both matrices
  84039. * @param result defines an optional target matrix where to store the interpolation
  84040. * @returns the interpolated matrix
  84041. */
  84042. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84043. /**
  84044. * Makes a copy of the animation
  84045. * @returns Cloned animation
  84046. */
  84047. clone(): Animation;
  84048. /**
  84049. * Sets the key frames of the animation
  84050. * @param values The animation key frames to set
  84051. */
  84052. setKeys(values: Array<IAnimationKey>): void;
  84053. /**
  84054. * Serializes the animation to an object
  84055. * @returns Serialized object
  84056. */
  84057. serialize(): any;
  84058. /**
  84059. * Float animation type
  84060. */
  84061. private static _ANIMATIONTYPE_FLOAT;
  84062. /**
  84063. * Vector3 animation type
  84064. */
  84065. private static _ANIMATIONTYPE_VECTOR3;
  84066. /**
  84067. * Quaternion animation type
  84068. */
  84069. private static _ANIMATIONTYPE_QUATERNION;
  84070. /**
  84071. * Matrix animation type
  84072. */
  84073. private static _ANIMATIONTYPE_MATRIX;
  84074. /**
  84075. * Color3 animation type
  84076. */
  84077. private static _ANIMATIONTYPE_COLOR3;
  84078. /**
  84079. * Vector2 animation type
  84080. */
  84081. private static _ANIMATIONTYPE_VECTOR2;
  84082. /**
  84083. * Size animation type
  84084. */
  84085. private static _ANIMATIONTYPE_SIZE;
  84086. /**
  84087. * Relative Loop Mode
  84088. */
  84089. private static _ANIMATIONLOOPMODE_RELATIVE;
  84090. /**
  84091. * Cycle Loop Mode
  84092. */
  84093. private static _ANIMATIONLOOPMODE_CYCLE;
  84094. /**
  84095. * Constant Loop Mode
  84096. */
  84097. private static _ANIMATIONLOOPMODE_CONSTANT;
  84098. /**
  84099. * Get the float animation type
  84100. */
  84101. static readonly ANIMATIONTYPE_FLOAT: number;
  84102. /**
  84103. * Get the Vector3 animation type
  84104. */
  84105. static readonly ANIMATIONTYPE_VECTOR3: number;
  84106. /**
  84107. * Get the Vector2 animation type
  84108. */
  84109. static readonly ANIMATIONTYPE_VECTOR2: number;
  84110. /**
  84111. * Get the Size animation type
  84112. */
  84113. static readonly ANIMATIONTYPE_SIZE: number;
  84114. /**
  84115. * Get the Quaternion animation type
  84116. */
  84117. static readonly ANIMATIONTYPE_QUATERNION: number;
  84118. /**
  84119. * Get the Matrix animation type
  84120. */
  84121. static readonly ANIMATIONTYPE_MATRIX: number;
  84122. /**
  84123. * Get the Color3 animation type
  84124. */
  84125. static readonly ANIMATIONTYPE_COLOR3: number;
  84126. /**
  84127. * Get the Relative Loop Mode
  84128. */
  84129. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84130. /**
  84131. * Get the Cycle Loop Mode
  84132. */
  84133. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84134. /**
  84135. * Get the Constant Loop Mode
  84136. */
  84137. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84138. /** @hidden */
  84139. static _UniversalLerp(left: any, right: any, amount: number): any;
  84140. /**
  84141. * Parses an animation object and creates an animation
  84142. * @param parsedAnimation Parsed animation object
  84143. * @returns Animation object
  84144. */
  84145. static Parse(parsedAnimation: any): Animation;
  84146. /**
  84147. * Appends the serialized animations from the source animations
  84148. * @param source Source containing the animations
  84149. * @param destination Target to store the animations
  84150. */
  84151. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84152. }
  84153. }
  84154. declare module BABYLON {
  84155. /**
  84156. * Base class of all the textures in babylon.
  84157. * It groups all the common properties the materials, post process, lights... might need
  84158. * in order to make a correct use of the texture.
  84159. */
  84160. export class BaseTexture implements IAnimatable {
  84161. /**
  84162. * Default anisotropic filtering level for the application.
  84163. * It is set to 4 as a good tradeoff between perf and quality.
  84164. */
  84165. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84166. /**
  84167. * Gets or sets the unique id of the texture
  84168. */
  84169. uniqueId: number;
  84170. /**
  84171. * Define the name of the texture.
  84172. */
  84173. name: string;
  84174. /**
  84175. * Gets or sets an object used to store user defined information.
  84176. */
  84177. metadata: any;
  84178. /**
  84179. * For internal use only. Please do not use.
  84180. */
  84181. reservedDataStore: any;
  84182. private _hasAlpha;
  84183. /**
  84184. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84185. */
  84186. hasAlpha: boolean;
  84187. /**
  84188. * Defines if the alpha value should be determined via the rgb values.
  84189. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84190. */
  84191. getAlphaFromRGB: boolean;
  84192. /**
  84193. * Intensity or strength of the texture.
  84194. * It is commonly used by materials to fine tune the intensity of the texture
  84195. */
  84196. level: number;
  84197. /**
  84198. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84199. * This is part of the texture as textures usually maps to one uv set.
  84200. */
  84201. coordinatesIndex: number;
  84202. private _coordinatesMode;
  84203. /**
  84204. * How a texture is mapped.
  84205. *
  84206. * | Value | Type | Description |
  84207. * | ----- | ----------------------------------- | ----------- |
  84208. * | 0 | EXPLICIT_MODE | |
  84209. * | 1 | SPHERICAL_MODE | |
  84210. * | 2 | PLANAR_MODE | |
  84211. * | 3 | CUBIC_MODE | |
  84212. * | 4 | PROJECTION_MODE | |
  84213. * | 5 | SKYBOX_MODE | |
  84214. * | 6 | INVCUBIC_MODE | |
  84215. * | 7 | EQUIRECTANGULAR_MODE | |
  84216. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  84217. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  84218. */
  84219. coordinatesMode: number;
  84220. /**
  84221. * | Value | Type | Description |
  84222. * | ----- | ------------------ | ----------- |
  84223. * | 0 | CLAMP_ADDRESSMODE | |
  84224. * | 1 | WRAP_ADDRESSMODE | |
  84225. * | 2 | MIRROR_ADDRESSMODE | |
  84226. */
  84227. wrapU: number;
  84228. /**
  84229. * | Value | Type | Description |
  84230. * | ----- | ------------------ | ----------- |
  84231. * | 0 | CLAMP_ADDRESSMODE | |
  84232. * | 1 | WRAP_ADDRESSMODE | |
  84233. * | 2 | MIRROR_ADDRESSMODE | |
  84234. */
  84235. wrapV: number;
  84236. /**
  84237. * | Value | Type | Description |
  84238. * | ----- | ------------------ | ----------- |
  84239. * | 0 | CLAMP_ADDRESSMODE | |
  84240. * | 1 | WRAP_ADDRESSMODE | |
  84241. * | 2 | MIRROR_ADDRESSMODE | |
  84242. */
  84243. wrapR: number;
  84244. /**
  84245. * With compliant hardware and browser (supporting anisotropic filtering)
  84246. * this defines the level of anisotropic filtering in the texture.
  84247. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  84248. */
  84249. anisotropicFilteringLevel: number;
  84250. /**
  84251. * Define if the texture is a cube texture or if false a 2d texture.
  84252. */
  84253. isCube: boolean;
  84254. /**
  84255. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  84256. */
  84257. is3D: boolean;
  84258. /**
  84259. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  84260. * HDR texture are usually stored in linear space.
  84261. * This only impacts the PBR and Background materials
  84262. */
  84263. gammaSpace: boolean;
  84264. /**
  84265. * Gets whether or not the texture contains RGBD data.
  84266. */
  84267. readonly isRGBD: boolean;
  84268. /**
  84269. * Is Z inverted in the texture (useful in a cube texture).
  84270. */
  84271. invertZ: boolean;
  84272. /**
  84273. * Are mip maps generated for this texture or not.
  84274. */
  84275. readonly noMipmap: boolean;
  84276. /**
  84277. * @hidden
  84278. */
  84279. lodLevelInAlpha: boolean;
  84280. /**
  84281. * With prefiltered texture, defined the offset used during the prefiltering steps.
  84282. */
  84283. lodGenerationOffset: number;
  84284. /**
  84285. * With prefiltered texture, defined the scale used during the prefiltering steps.
  84286. */
  84287. lodGenerationScale: number;
  84288. /**
  84289. * Define if the texture is a render target.
  84290. */
  84291. isRenderTarget: boolean;
  84292. /**
  84293. * Define the unique id of the texture in the scene.
  84294. */
  84295. readonly uid: string;
  84296. /**
  84297. * Return a string representation of the texture.
  84298. * @returns the texture as a string
  84299. */
  84300. toString(): string;
  84301. /**
  84302. * Get the class name of the texture.
  84303. * @returns "BaseTexture"
  84304. */
  84305. getClassName(): string;
  84306. /**
  84307. * Define the list of animation attached to the texture.
  84308. */
  84309. animations: Animation[];
  84310. /**
  84311. * An event triggered when the texture is disposed.
  84312. */
  84313. onDisposeObservable: Observable<BaseTexture>;
  84314. private _onDisposeObserver;
  84315. /**
  84316. * Callback triggered when the texture has been disposed.
  84317. * Kept for back compatibility, you can use the onDisposeObservable instead.
  84318. */
  84319. onDispose: () => void;
  84320. /**
  84321. * Define the current state of the loading sequence when in delayed load mode.
  84322. */
  84323. delayLoadState: number;
  84324. private _scene;
  84325. /** @hidden */
  84326. _texture: Nullable<InternalTexture>;
  84327. private _uid;
  84328. /**
  84329. * Define if the texture is preventinga material to render or not.
  84330. * If not and the texture is not ready, the engine will use a default black texture instead.
  84331. */
  84332. readonly isBlocking: boolean;
  84333. /**
  84334. * Instantiates a new BaseTexture.
  84335. * Base class of all the textures in babylon.
  84336. * It groups all the common properties the materials, post process, lights... might need
  84337. * in order to make a correct use of the texture.
  84338. * @param scene Define the scene the texture blongs to
  84339. */
  84340. constructor(scene: Nullable<Scene>);
  84341. /**
  84342. * Get the scene the texture belongs to.
  84343. * @returns the scene or null if undefined
  84344. */
  84345. getScene(): Nullable<Scene>;
  84346. /**
  84347. * Get the texture transform matrix used to offset tile the texture for istance.
  84348. * @returns the transformation matrix
  84349. */
  84350. getTextureMatrix(): Matrix;
  84351. /**
  84352. * Get the texture reflection matrix used to rotate/transform the reflection.
  84353. * @returns the reflection matrix
  84354. */
  84355. getReflectionTextureMatrix(): Matrix;
  84356. /**
  84357. * Get the underlying lower level texture from Babylon.
  84358. * @returns the insternal texture
  84359. */
  84360. getInternalTexture(): Nullable<InternalTexture>;
  84361. /**
  84362. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  84363. * @returns true if ready or not blocking
  84364. */
  84365. isReadyOrNotBlocking(): boolean;
  84366. /**
  84367. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  84368. * @returns true if fully ready
  84369. */
  84370. isReady(): boolean;
  84371. private _cachedSize;
  84372. /**
  84373. * Get the size of the texture.
  84374. * @returns the texture size.
  84375. */
  84376. getSize(): ISize;
  84377. /**
  84378. * Get the base size of the texture.
  84379. * It can be different from the size if the texture has been resized for POT for instance
  84380. * @returns the base size
  84381. */
  84382. getBaseSize(): ISize;
  84383. /**
  84384. * Update the sampling mode of the texture.
  84385. * Default is Trilinear mode.
  84386. *
  84387. * | Value | Type | Description |
  84388. * | ----- | ------------------ | ----------- |
  84389. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  84390. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  84391. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  84392. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  84393. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  84394. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  84395. * | 7 | NEAREST_LINEAR | |
  84396. * | 8 | NEAREST_NEAREST | |
  84397. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  84398. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  84399. * | 11 | LINEAR_LINEAR | |
  84400. * | 12 | LINEAR_NEAREST | |
  84401. *
  84402. * > _mag_: magnification filter (close to the viewer)
  84403. * > _min_: minification filter (far from the viewer)
  84404. * > _mip_: filter used between mip map levels
  84405. *@param samplingMode Define the new sampling mode of the texture
  84406. */
  84407. updateSamplingMode(samplingMode: number): void;
  84408. /**
  84409. * Scales the texture if is `canRescale()`
  84410. * @param ratio the resize factor we want to use to rescale
  84411. */
  84412. scale(ratio: number): void;
  84413. /**
  84414. * Get if the texture can rescale.
  84415. */
  84416. readonly canRescale: boolean;
  84417. /** @hidden */
  84418. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  84419. /** @hidden */
  84420. _rebuild(): void;
  84421. /**
  84422. * Triggers the load sequence in delayed load mode.
  84423. */
  84424. delayLoad(): void;
  84425. /**
  84426. * Clones the texture.
  84427. * @returns the cloned texture
  84428. */
  84429. clone(): Nullable<BaseTexture>;
  84430. /**
  84431. * Get the texture underlying type (INT, FLOAT...)
  84432. */
  84433. readonly textureType: number;
  84434. /**
  84435. * Get the texture underlying format (RGB, RGBA...)
  84436. */
  84437. readonly textureFormat: number;
  84438. /**
  84439. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  84440. * This will returns an RGBA array buffer containing either in values (0-255) or
  84441. * float values (0-1) depending of the underlying buffer type.
  84442. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  84443. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  84444. * @param buffer defines a user defined buffer to fill with data (can be null)
  84445. * @returns The Array buffer containing the pixels data.
  84446. */
  84447. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  84448. /**
  84449. * Release and destroy the underlying lower level texture aka internalTexture.
  84450. */
  84451. releaseInternalTexture(): void;
  84452. /**
  84453. * Get the polynomial representation of the texture data.
  84454. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  84455. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  84456. */
  84457. sphericalPolynomial: Nullable<SphericalPolynomial>;
  84458. /** @hidden */
  84459. readonly _lodTextureHigh: Nullable<BaseTexture>;
  84460. /** @hidden */
  84461. readonly _lodTextureMid: Nullable<BaseTexture>;
  84462. /** @hidden */
  84463. readonly _lodTextureLow: Nullable<BaseTexture>;
  84464. /**
  84465. * Dispose the texture and release its associated resources.
  84466. */
  84467. dispose(): void;
  84468. /**
  84469. * Serialize the texture into a JSON representation that can be parsed later on.
  84470. * @returns the JSON representation of the texture
  84471. */
  84472. serialize(): any;
  84473. /**
  84474. * Helper function to be called back once a list of texture contains only ready textures.
  84475. * @param textures Define the list of textures to wait for
  84476. * @param callback Define the callback triggered once the entire list will be ready
  84477. */
  84478. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  84479. }
  84480. }
  84481. declare module BABYLON {
  84482. /**
  84483. * Uniform buffer objects.
  84484. *
  84485. * Handles blocks of uniform on the GPU.
  84486. *
  84487. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84488. *
  84489. * For more information, please refer to :
  84490. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84491. */
  84492. export class UniformBuffer {
  84493. private _engine;
  84494. private _buffer;
  84495. private _data;
  84496. private _bufferData;
  84497. private _dynamic?;
  84498. private _uniformLocations;
  84499. private _uniformSizes;
  84500. private _uniformLocationPointer;
  84501. private _needSync;
  84502. private _noUBO;
  84503. private _currentEffect;
  84504. private static _MAX_UNIFORM_SIZE;
  84505. private static _tempBuffer;
  84506. /**
  84507. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84508. * This is dynamic to allow compat with webgl 1 and 2.
  84509. * You will need to pass the name of the uniform as well as the value.
  84510. */
  84511. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84512. /**
  84513. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84514. * This is dynamic to allow compat with webgl 1 and 2.
  84515. * You will need to pass the name of the uniform as well as the value.
  84516. */
  84517. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84518. /**
  84519. * Lambda to Update a single float in a uniform buffer.
  84520. * This is dynamic to allow compat with webgl 1 and 2.
  84521. * You will need to pass the name of the uniform as well as the value.
  84522. */
  84523. updateFloat: (name: string, x: number) => void;
  84524. /**
  84525. * Lambda to Update a vec2 of float in a uniform buffer.
  84526. * This is dynamic to allow compat with webgl 1 and 2.
  84527. * You will need to pass the name of the uniform as well as the value.
  84528. */
  84529. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84530. /**
  84531. * Lambda to Update a vec3 of float in a uniform buffer.
  84532. * This is dynamic to allow compat with webgl 1 and 2.
  84533. * You will need to pass the name of the uniform as well as the value.
  84534. */
  84535. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84536. /**
  84537. * Lambda to Update a vec4 of float in a uniform buffer.
  84538. * This is dynamic to allow compat with webgl 1 and 2.
  84539. * You will need to pass the name of the uniform as well as the value.
  84540. */
  84541. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84542. /**
  84543. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84544. * This is dynamic to allow compat with webgl 1 and 2.
  84545. * You will need to pass the name of the uniform as well as the value.
  84546. */
  84547. updateMatrix: (name: string, mat: Matrix) => void;
  84548. /**
  84549. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84550. * This is dynamic to allow compat with webgl 1 and 2.
  84551. * You will need to pass the name of the uniform as well as the value.
  84552. */
  84553. updateVector3: (name: string, vector: Vector3) => void;
  84554. /**
  84555. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84556. * This is dynamic to allow compat with webgl 1 and 2.
  84557. * You will need to pass the name of the uniform as well as the value.
  84558. */
  84559. updateVector4: (name: string, vector: Vector4) => void;
  84560. /**
  84561. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84562. * This is dynamic to allow compat with webgl 1 and 2.
  84563. * You will need to pass the name of the uniform as well as the value.
  84564. */
  84565. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84566. /**
  84567. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84568. * This is dynamic to allow compat with webgl 1 and 2.
  84569. * You will need to pass the name of the uniform as well as the value.
  84570. */
  84571. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84572. /**
  84573. * Instantiates a new Uniform buffer objects.
  84574. *
  84575. * Handles blocks of uniform on the GPU.
  84576. *
  84577. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84578. *
  84579. * For more information, please refer to :
  84580. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84581. * @param engine Define the engine the buffer is associated with
  84582. * @param data Define the data contained in the buffer
  84583. * @param dynamic Define if the buffer is updatable
  84584. */
  84585. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84586. /**
  84587. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84588. * or just falling back on setUniformXXX calls.
  84589. */
  84590. readonly useUbo: boolean;
  84591. /**
  84592. * Indicates if the WebGL underlying uniform buffer is in sync
  84593. * with the javascript cache data.
  84594. */
  84595. readonly isSync: boolean;
  84596. /**
  84597. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84598. * Also, a dynamic UniformBuffer will disable cache verification and always
  84599. * update the underlying WebGL uniform buffer to the GPU.
  84600. * @returns if Dynamic, otherwise false
  84601. */
  84602. isDynamic(): boolean;
  84603. /**
  84604. * The data cache on JS side.
  84605. * @returns the underlying data as a float array
  84606. */
  84607. getData(): Float32Array;
  84608. /**
  84609. * The underlying WebGL Uniform buffer.
  84610. * @returns the webgl buffer
  84611. */
  84612. getBuffer(): Nullable<WebGLBuffer>;
  84613. /**
  84614. * std140 layout specifies how to align data within an UBO structure.
  84615. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84616. * for specs.
  84617. */
  84618. private _fillAlignment;
  84619. /**
  84620. * Adds an uniform in the buffer.
  84621. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84622. * for the layout to be correct !
  84623. * @param name Name of the uniform, as used in the uniform block in the shader.
  84624. * @param size Data size, or data directly.
  84625. */
  84626. addUniform(name: string, size: number | number[]): void;
  84627. /**
  84628. * Adds a Matrix 4x4 to the uniform buffer.
  84629. * @param name Name of the uniform, as used in the uniform block in the shader.
  84630. * @param mat A 4x4 matrix.
  84631. */
  84632. addMatrix(name: string, mat: Matrix): void;
  84633. /**
  84634. * Adds a vec2 to the uniform buffer.
  84635. * @param name Name of the uniform, as used in the uniform block in the shader.
  84636. * @param x Define the x component value of the vec2
  84637. * @param y Define the y component value of the vec2
  84638. */
  84639. addFloat2(name: string, x: number, y: number): void;
  84640. /**
  84641. * Adds a vec3 to the uniform buffer.
  84642. * @param name Name of the uniform, as used in the uniform block in the shader.
  84643. * @param x Define the x component value of the vec3
  84644. * @param y Define the y component value of the vec3
  84645. * @param z Define the z component value of the vec3
  84646. */
  84647. addFloat3(name: string, x: number, y: number, z: number): void;
  84648. /**
  84649. * Adds a vec3 to the uniform buffer.
  84650. * @param name Name of the uniform, as used in the uniform block in the shader.
  84651. * @param color Define the vec3 from a Color
  84652. */
  84653. addColor3(name: string, color: Color3): void;
  84654. /**
  84655. * Adds a vec4 to the uniform buffer.
  84656. * @param name Name of the uniform, as used in the uniform block in the shader.
  84657. * @param color Define the rgb components from a Color
  84658. * @param alpha Define the a component of the vec4
  84659. */
  84660. addColor4(name: string, color: Color3, alpha: number): void;
  84661. /**
  84662. * Adds a vec3 to the uniform buffer.
  84663. * @param name Name of the uniform, as used in the uniform block in the shader.
  84664. * @param vector Define the vec3 components from a Vector
  84665. */
  84666. addVector3(name: string, vector: Vector3): void;
  84667. /**
  84668. * Adds a Matrix 3x3 to the uniform buffer.
  84669. * @param name Name of the uniform, as used in the uniform block in the shader.
  84670. */
  84671. addMatrix3x3(name: string): void;
  84672. /**
  84673. * Adds a Matrix 2x2 to the uniform buffer.
  84674. * @param name Name of the uniform, as used in the uniform block in the shader.
  84675. */
  84676. addMatrix2x2(name: string): void;
  84677. /**
  84678. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84679. */
  84680. create(): void;
  84681. /** @hidden */
  84682. _rebuild(): void;
  84683. /**
  84684. * Updates the WebGL Uniform Buffer on the GPU.
  84685. * If the `dynamic` flag is set to true, no cache comparison is done.
  84686. * Otherwise, the buffer will be updated only if the cache differs.
  84687. */
  84688. update(): void;
  84689. /**
  84690. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84691. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84692. * @param data Define the flattened data
  84693. * @param size Define the size of the data.
  84694. */
  84695. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84696. private _updateMatrix3x3ForUniform;
  84697. private _updateMatrix3x3ForEffect;
  84698. private _updateMatrix2x2ForEffect;
  84699. private _updateMatrix2x2ForUniform;
  84700. private _updateFloatForEffect;
  84701. private _updateFloatForUniform;
  84702. private _updateFloat2ForEffect;
  84703. private _updateFloat2ForUniform;
  84704. private _updateFloat3ForEffect;
  84705. private _updateFloat3ForUniform;
  84706. private _updateFloat4ForEffect;
  84707. private _updateFloat4ForUniform;
  84708. private _updateMatrixForEffect;
  84709. private _updateMatrixForUniform;
  84710. private _updateVector3ForEffect;
  84711. private _updateVector3ForUniform;
  84712. private _updateVector4ForEffect;
  84713. private _updateVector4ForUniform;
  84714. private _updateColor3ForEffect;
  84715. private _updateColor3ForUniform;
  84716. private _updateColor4ForEffect;
  84717. private _updateColor4ForUniform;
  84718. /**
  84719. * Sets a sampler uniform on the effect.
  84720. * @param name Define the name of the sampler.
  84721. * @param texture Define the texture to set in the sampler
  84722. */
  84723. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84724. /**
  84725. * Directly updates the value of the uniform in the cache AND on the GPU.
  84726. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84727. * @param data Define the flattened data
  84728. */
  84729. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84730. /**
  84731. * Binds this uniform buffer to an effect.
  84732. * @param effect Define the effect to bind the buffer to
  84733. * @param name Name of the uniform block in the shader.
  84734. */
  84735. bindToEffect(effect: Effect, name: string): void;
  84736. /**
  84737. * Disposes the uniform buffer.
  84738. */
  84739. dispose(): void;
  84740. }
  84741. }
  84742. declare module BABYLON {
  84743. /**
  84744. * This represents the required contract to create a new type of texture loader.
  84745. */
  84746. export interface IInternalTextureLoader {
  84747. /**
  84748. * Defines wether the loader supports cascade loading the different faces.
  84749. */
  84750. supportCascades: boolean;
  84751. /**
  84752. * This returns if the loader support the current file information.
  84753. * @param extension defines the file extension of the file being loaded
  84754. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84755. * @param fallback defines the fallback internal texture if any
  84756. * @param isBase64 defines whether the texture is encoded as a base64
  84757. * @param isBuffer defines whether the texture data are stored as a buffer
  84758. * @returns true if the loader can load the specified file
  84759. */
  84760. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  84761. /**
  84762. * Transform the url before loading if required.
  84763. * @param rootUrl the url of the texture
  84764. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84765. * @returns the transformed texture
  84766. */
  84767. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  84768. /**
  84769. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  84770. * @param rootUrl the url of the texture
  84771. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84772. * @returns the fallback texture
  84773. */
  84774. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  84775. /**
  84776. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  84777. * @param data contains the texture data
  84778. * @param texture defines the BabylonJS internal texture
  84779. * @param createPolynomials will be true if polynomials have been requested
  84780. * @param onLoad defines the callback to trigger once the texture is ready
  84781. * @param onError defines the callback to trigger in case of error
  84782. */
  84783. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  84784. /**
  84785. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  84786. * @param data contains the texture data
  84787. * @param texture defines the BabylonJS internal texture
  84788. * @param callback defines the method to call once ready to upload
  84789. */
  84790. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  84791. }
  84792. }
  84793. declare module BABYLON {
  84794. /**
  84795. * Creation options of the multi render target texture.
  84796. */
  84797. export interface IMultiRenderTargetOptions {
  84798. /**
  84799. * Define if the texture needs to create mip maps after render.
  84800. */
  84801. generateMipMaps?: boolean;
  84802. /**
  84803. * Define the types of all the draw buffers we want to create
  84804. */
  84805. types?: number[];
  84806. /**
  84807. * Define the sampling modes of all the draw buffers we want to create
  84808. */
  84809. samplingModes?: number[];
  84810. /**
  84811. * Define if a depth buffer is required
  84812. */
  84813. generateDepthBuffer?: boolean;
  84814. /**
  84815. * Define if a stencil buffer is required
  84816. */
  84817. generateStencilBuffer?: boolean;
  84818. /**
  84819. * Define if a depth texture is required instead of a depth buffer
  84820. */
  84821. generateDepthTexture?: boolean;
  84822. /**
  84823. * Define the number of desired draw buffers
  84824. */
  84825. textureCount?: number;
  84826. /**
  84827. * Define if aspect ratio should be adapted to the texture or stay the scene one
  84828. */
  84829. doNotChangeAspectRatio?: boolean;
  84830. /**
  84831. * Define the default type of the buffers we are creating
  84832. */
  84833. defaultType?: number;
  84834. }
  84835. /**
  84836. * A multi render target, like a render target provides the ability to render to a texture.
  84837. * Unlike the render target, it can render to several draw buffers in one draw.
  84838. * This is specially interesting in deferred rendering or for any effects requiring more than
  84839. * just one color from a single pass.
  84840. */
  84841. export class MultiRenderTarget extends RenderTargetTexture {
  84842. private _internalTextures;
  84843. private _textures;
  84844. private _multiRenderTargetOptions;
  84845. /**
  84846. * Get if draw buffers are currently supported by the used hardware and browser.
  84847. */
  84848. readonly isSupported: boolean;
  84849. /**
  84850. * Get the list of textures generated by the multi render target.
  84851. */
  84852. readonly textures: Texture[];
  84853. /**
  84854. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  84855. */
  84856. readonly depthTexture: Texture;
  84857. /**
  84858. * Set the wrapping mode on U of all the textures we are rendering to.
  84859. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84860. */
  84861. wrapU: number;
  84862. /**
  84863. * Set the wrapping mode on V of all the textures we are rendering to.
  84864. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84865. */
  84866. wrapV: number;
  84867. /**
  84868. * Instantiate a new multi render target texture.
  84869. * A multi render target, like a render target provides the ability to render to a texture.
  84870. * Unlike the render target, it can render to several draw buffers in one draw.
  84871. * This is specially interesting in deferred rendering or for any effects requiring more than
  84872. * just one color from a single pass.
  84873. * @param name Define the name of the texture
  84874. * @param size Define the size of the buffers to render to
  84875. * @param count Define the number of target we are rendering into
  84876. * @param scene Define the scene the texture belongs to
  84877. * @param options Define the options used to create the multi render target
  84878. */
  84879. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  84880. /** @hidden */
  84881. _rebuild(): void;
  84882. private _createInternalTextures;
  84883. private _createTextures;
  84884. /**
  84885. * Define the number of samples used if MSAA is enabled.
  84886. */
  84887. samples: number;
  84888. /**
  84889. * Resize all the textures in the multi render target.
  84890. * Be carrefull as it will recreate all the data in the new texture.
  84891. * @param size Define the new size
  84892. */
  84893. resize(size: any): void;
  84894. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84895. /**
  84896. * Dispose the render targets and their associated resources
  84897. */
  84898. dispose(): void;
  84899. /**
  84900. * Release all the underlying texture used as draw buffers.
  84901. */
  84902. releaseInternalTextures(): void;
  84903. }
  84904. }
  84905. declare module BABYLON {
  84906. /**
  84907. * Class used to work with sound analyzer using fast fourier transform (FFT)
  84908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84909. */
  84910. export class Analyser {
  84911. /**
  84912. * Gets or sets the smoothing
  84913. * @ignorenaming
  84914. */
  84915. SMOOTHING: number;
  84916. /**
  84917. * Gets or sets the FFT table size
  84918. * @ignorenaming
  84919. */
  84920. FFT_SIZE: number;
  84921. /**
  84922. * Gets or sets the bar graph amplitude
  84923. * @ignorenaming
  84924. */
  84925. BARGRAPHAMPLITUDE: number;
  84926. /**
  84927. * Gets or sets the position of the debug canvas
  84928. * @ignorenaming
  84929. */
  84930. DEBUGCANVASPOS: {
  84931. x: number;
  84932. y: number;
  84933. };
  84934. /**
  84935. * Gets or sets the debug canvas size
  84936. * @ignorenaming
  84937. */
  84938. DEBUGCANVASSIZE: {
  84939. width: number;
  84940. height: number;
  84941. };
  84942. private _byteFreqs;
  84943. private _byteTime;
  84944. private _floatFreqs;
  84945. private _webAudioAnalyser;
  84946. private _debugCanvas;
  84947. private _debugCanvasContext;
  84948. private _scene;
  84949. private _registerFunc;
  84950. private _audioEngine;
  84951. /**
  84952. * Creates a new analyser
  84953. * @param scene defines hosting scene
  84954. */
  84955. constructor(scene: Scene);
  84956. /**
  84957. * Get the number of data values you will have to play with for the visualization
  84958. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  84959. * @returns a number
  84960. */
  84961. getFrequencyBinCount(): number;
  84962. /**
  84963. * Gets the current frequency data as a byte array
  84964. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84965. * @returns a Uint8Array
  84966. */
  84967. getByteFrequencyData(): Uint8Array;
  84968. /**
  84969. * Gets the current waveform as a byte array
  84970. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  84971. * @returns a Uint8Array
  84972. */
  84973. getByteTimeDomainData(): Uint8Array;
  84974. /**
  84975. * Gets the current frequency data as a float array
  84976. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84977. * @returns a Float32Array
  84978. */
  84979. getFloatFrequencyData(): Float32Array;
  84980. /**
  84981. * Renders the debug canvas
  84982. */
  84983. drawDebugCanvas(): void;
  84984. /**
  84985. * Stops rendering the debug canvas and removes it
  84986. */
  84987. stopDebugCanvas(): void;
  84988. /**
  84989. * Connects two audio nodes
  84990. * @param inputAudioNode defines first node to connect
  84991. * @param outputAudioNode defines second node to connect
  84992. */
  84993. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  84994. /**
  84995. * Releases all associated resources
  84996. */
  84997. dispose(): void;
  84998. }
  84999. }
  85000. declare module BABYLON {
  85001. /**
  85002. * This represents an audio engine and it is responsible
  85003. * to play, synchronize and analyse sounds throughout the application.
  85004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85005. */
  85006. export interface IAudioEngine extends IDisposable {
  85007. /**
  85008. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85009. */
  85010. readonly canUseWebAudio: boolean;
  85011. /**
  85012. * Gets the current AudioContext if available.
  85013. */
  85014. readonly audioContext: Nullable<AudioContext>;
  85015. /**
  85016. * The master gain node defines the global audio volume of your audio engine.
  85017. */
  85018. readonly masterGain: GainNode;
  85019. /**
  85020. * Gets whether or not mp3 are supported by your browser.
  85021. */
  85022. readonly isMP3supported: boolean;
  85023. /**
  85024. * Gets whether or not ogg are supported by your browser.
  85025. */
  85026. readonly isOGGsupported: boolean;
  85027. /**
  85028. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85029. * @ignoreNaming
  85030. */
  85031. WarnedWebAudioUnsupported: boolean;
  85032. /**
  85033. * Defines if the audio engine relies on a custom unlocked button.
  85034. * In this case, the embedded button will not be displayed.
  85035. */
  85036. useCustomUnlockedButton: boolean;
  85037. /**
  85038. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85039. */
  85040. readonly unlocked: boolean;
  85041. /**
  85042. * Event raised when audio has been unlocked on the browser.
  85043. */
  85044. onAudioUnlockedObservable: Observable<AudioEngine>;
  85045. /**
  85046. * Event raised when audio has been locked on the browser.
  85047. */
  85048. onAudioLockedObservable: Observable<AudioEngine>;
  85049. /**
  85050. * Flags the audio engine in Locked state.
  85051. * This happens due to new browser policies preventing audio to autoplay.
  85052. */
  85053. lock(): void;
  85054. /**
  85055. * Unlocks the audio engine once a user action has been done on the dom.
  85056. * This is helpful to resume play once browser policies have been satisfied.
  85057. */
  85058. unlock(): void;
  85059. }
  85060. /**
  85061. * This represents the default audio engine used in babylon.
  85062. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85064. */
  85065. export class AudioEngine implements IAudioEngine {
  85066. private _audioContext;
  85067. private _audioContextInitialized;
  85068. private _muteButton;
  85069. private _hostElement;
  85070. /**
  85071. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85072. */
  85073. canUseWebAudio: boolean;
  85074. /**
  85075. * The master gain node defines the global audio volume of your audio engine.
  85076. */
  85077. masterGain: GainNode;
  85078. /**
  85079. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85080. * @ignoreNaming
  85081. */
  85082. WarnedWebAudioUnsupported: boolean;
  85083. /**
  85084. * Gets whether or not mp3 are supported by your browser.
  85085. */
  85086. isMP3supported: boolean;
  85087. /**
  85088. * Gets whether or not ogg are supported by your browser.
  85089. */
  85090. isOGGsupported: boolean;
  85091. /**
  85092. * Gets whether audio has been unlocked on the device.
  85093. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85094. * a user interaction has happened.
  85095. */
  85096. unlocked: boolean;
  85097. /**
  85098. * Defines if the audio engine relies on a custom unlocked button.
  85099. * In this case, the embedded button will not be displayed.
  85100. */
  85101. useCustomUnlockedButton: boolean;
  85102. /**
  85103. * Event raised when audio has been unlocked on the browser.
  85104. */
  85105. onAudioUnlockedObservable: Observable<AudioEngine>;
  85106. /**
  85107. * Event raised when audio has been locked on the browser.
  85108. */
  85109. onAudioLockedObservable: Observable<AudioEngine>;
  85110. /**
  85111. * Gets the current AudioContext if available.
  85112. */
  85113. readonly audioContext: Nullable<AudioContext>;
  85114. private _connectedAnalyser;
  85115. /**
  85116. * Instantiates a new audio engine.
  85117. *
  85118. * There should be only one per page as some browsers restrict the number
  85119. * of audio contexts you can create.
  85120. * @param hostElement defines the host element where to display the mute icon if necessary
  85121. */
  85122. constructor(hostElement?: Nullable<HTMLElement>);
  85123. /**
  85124. * Flags the audio engine in Locked state.
  85125. * This happens due to new browser policies preventing audio to autoplay.
  85126. */
  85127. lock(): void;
  85128. /**
  85129. * Unlocks the audio engine once a user action has been done on the dom.
  85130. * This is helpful to resume play once browser policies have been satisfied.
  85131. */
  85132. unlock(): void;
  85133. private _resumeAudioContext;
  85134. private _initializeAudioContext;
  85135. private _tryToRun;
  85136. private _triggerRunningState;
  85137. private _triggerSuspendedState;
  85138. private _displayMuteButton;
  85139. private _moveButtonToTopLeft;
  85140. private _onResize;
  85141. private _hideMuteButton;
  85142. /**
  85143. * Destroy and release the resources associated with the audio ccontext.
  85144. */
  85145. dispose(): void;
  85146. /**
  85147. * Gets the global volume sets on the master gain.
  85148. * @returns the global volume if set or -1 otherwise
  85149. */
  85150. getGlobalVolume(): number;
  85151. /**
  85152. * Sets the global volume of your experience (sets on the master gain).
  85153. * @param newVolume Defines the new global volume of the application
  85154. */
  85155. setGlobalVolume(newVolume: number): void;
  85156. /**
  85157. * Connect the audio engine to an audio analyser allowing some amazing
  85158. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85160. * @param analyser The analyser to connect to the engine
  85161. */
  85162. connectToAnalyser(analyser: Analyser): void;
  85163. }
  85164. }
  85165. declare module BABYLON {
  85166. /**
  85167. * Interface used to present a loading screen while loading a scene
  85168. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85169. */
  85170. export interface ILoadingScreen {
  85171. /**
  85172. * Function called to display the loading screen
  85173. */
  85174. displayLoadingUI: () => void;
  85175. /**
  85176. * Function called to hide the loading screen
  85177. */
  85178. hideLoadingUI: () => void;
  85179. /**
  85180. * Gets or sets the color to use for the background
  85181. */
  85182. loadingUIBackgroundColor: string;
  85183. /**
  85184. * Gets or sets the text to display while loading
  85185. */
  85186. loadingUIText: string;
  85187. }
  85188. /**
  85189. * Class used for the default loading screen
  85190. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85191. */
  85192. export class DefaultLoadingScreen implements ILoadingScreen {
  85193. private _renderingCanvas;
  85194. private _loadingText;
  85195. private _loadingDivBackgroundColor;
  85196. private _loadingDiv;
  85197. private _loadingTextDiv;
  85198. /**
  85199. * Creates a new default loading screen
  85200. * @param _renderingCanvas defines the canvas used to render the scene
  85201. * @param _loadingText defines the default text to display
  85202. * @param _loadingDivBackgroundColor defines the default background color
  85203. */
  85204. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85205. /**
  85206. * Function called to display the loading screen
  85207. */
  85208. displayLoadingUI(): void;
  85209. /**
  85210. * Function called to hide the loading screen
  85211. */
  85212. hideLoadingUI(): void;
  85213. /**
  85214. * Gets or sets the text to display while loading
  85215. */
  85216. loadingUIText: string;
  85217. /**
  85218. * Gets or sets the color to use for the background
  85219. */
  85220. loadingUIBackgroundColor: string;
  85221. private _resizeLoadingUI;
  85222. }
  85223. }
  85224. declare module BABYLON {
  85225. /**
  85226. * Settings for finer control over video usage
  85227. */
  85228. export interface VideoTextureSettings {
  85229. /**
  85230. * Applies `autoplay` to video, if specified
  85231. */
  85232. autoPlay?: boolean;
  85233. /**
  85234. * Applies `loop` to video, if specified
  85235. */
  85236. loop?: boolean;
  85237. /**
  85238. * Automatically updates internal texture from video at every frame in the render loop
  85239. */
  85240. autoUpdateTexture: boolean;
  85241. /**
  85242. * Image src displayed during the video loading or until the user interacts with the video.
  85243. */
  85244. poster?: string;
  85245. }
  85246. /**
  85247. * If you want to display a video in your scene, this is the special texture for that.
  85248. * This special texture works similar to other textures, with the exception of a few parameters.
  85249. * @see https://doc.babylonjs.com/how_to/video_texture
  85250. */
  85251. export class VideoTexture extends Texture {
  85252. /**
  85253. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  85254. */
  85255. readonly autoUpdateTexture: boolean;
  85256. /**
  85257. * The video instance used by the texture internally
  85258. */
  85259. readonly video: HTMLVideoElement;
  85260. private _onUserActionRequestedObservable;
  85261. /**
  85262. * Event triggerd when a dom action is required by the user to play the video.
  85263. * This happens due to recent changes in browser policies preventing video to auto start.
  85264. */
  85265. readonly onUserActionRequestedObservable: Observable<Texture>;
  85266. private _generateMipMaps;
  85267. private _engine;
  85268. private _stillImageCaptured;
  85269. private _displayingPosterTexture;
  85270. private _settings;
  85271. private _createInternalTextureOnEvent;
  85272. /**
  85273. * Creates a video texture.
  85274. * If you want to display a video in your scene, this is the special texture for that.
  85275. * This special texture works similar to other textures, with the exception of a few parameters.
  85276. * @see https://doc.babylonjs.com/how_to/video_texture
  85277. * @param name optional name, will detect from video source, if not defined
  85278. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  85279. * @param scene is obviously the current scene.
  85280. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  85281. * @param invertY is false by default but can be used to invert video on Y axis
  85282. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  85283. * @param settings allows finer control over video usage
  85284. */
  85285. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  85286. private _getName;
  85287. private _getVideo;
  85288. private _createInternalTexture;
  85289. private reset;
  85290. /**
  85291. * @hidden Internal method to initiate `update`.
  85292. */
  85293. _rebuild(): void;
  85294. /**
  85295. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  85296. */
  85297. update(): void;
  85298. /**
  85299. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  85300. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  85301. */
  85302. updateTexture(isVisible: boolean): void;
  85303. protected _updateInternalTexture: () => void;
  85304. /**
  85305. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  85306. * @param url New url.
  85307. */
  85308. updateURL(url: string): void;
  85309. /**
  85310. * Dispose the texture and release its associated resources.
  85311. */
  85312. dispose(): void;
  85313. /**
  85314. * Creates a video texture straight from a stream.
  85315. * @param scene Define the scene the texture should be created in
  85316. * @param stream Define the stream the texture should be created from
  85317. * @returns The created video texture as a promise
  85318. */
  85319. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  85320. /**
  85321. * Creates a video texture straight from your WebCam video feed.
  85322. * @param scene Define the scene the texture should be created in
  85323. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85324. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85325. * @returns The created video texture as a promise
  85326. */
  85327. static CreateFromWebCamAsync(scene: Scene, constraints: {
  85328. minWidth: number;
  85329. maxWidth: number;
  85330. minHeight: number;
  85331. maxHeight: number;
  85332. deviceId: string;
  85333. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  85334. /**
  85335. * Creates a video texture straight from your WebCam video feed.
  85336. * @param scene Define the scene the texture should be created in
  85337. * @param onReady Define a callback to triggered once the texture will be ready
  85338. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85339. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85340. */
  85341. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  85342. minWidth: number;
  85343. maxWidth: number;
  85344. minHeight: number;
  85345. maxHeight: number;
  85346. deviceId: string;
  85347. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  85348. }
  85349. }
  85350. declare module BABYLON {
  85351. /**
  85352. * Interface for attribute information associated with buffer instanciation
  85353. */
  85354. export class InstancingAttributeInfo {
  85355. /**
  85356. * Index/offset of the attribute in the vertex shader
  85357. */
  85358. index: number;
  85359. /**
  85360. * size of the attribute, 1, 2, 3 or 4
  85361. */
  85362. attributeSize: number;
  85363. /**
  85364. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  85365. * default is FLOAT
  85366. */
  85367. attribyteType: number;
  85368. /**
  85369. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  85370. */
  85371. normalized: boolean;
  85372. /**
  85373. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  85374. */
  85375. offset: number;
  85376. /**
  85377. * Name of the GLSL attribute, for debugging purpose only
  85378. */
  85379. attributeName: string;
  85380. }
  85381. /**
  85382. * Define options used to create a depth texture
  85383. */
  85384. export class DepthTextureCreationOptions {
  85385. /** Specifies whether or not a stencil should be allocated in the texture */
  85386. generateStencil?: boolean;
  85387. /** Specifies whether or not bilinear filtering is enable on the texture */
  85388. bilinearFiltering?: boolean;
  85389. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85390. comparisonFunction?: number;
  85391. /** Specifies if the created texture is a cube texture */
  85392. isCube?: boolean;
  85393. }
  85394. /**
  85395. * Class used to describe the capabilities of the engine relatively to the current browser
  85396. */
  85397. export class EngineCapabilities {
  85398. /** Maximum textures units per fragment shader */
  85399. maxTexturesImageUnits: number;
  85400. /** Maximum texture units per vertex shader */
  85401. maxVertexTextureImageUnits: number;
  85402. /** Maximum textures units in the entire pipeline */
  85403. maxCombinedTexturesImageUnits: number;
  85404. /** Maximum texture size */
  85405. maxTextureSize: number;
  85406. /** Maximum cube texture size */
  85407. maxCubemapTextureSize: number;
  85408. /** Maximum render texture size */
  85409. maxRenderTextureSize: number;
  85410. /** Maximum number of vertex attributes */
  85411. maxVertexAttribs: number;
  85412. /** Maximum number of varyings */
  85413. maxVaryingVectors: number;
  85414. /** Maximum number of uniforms per vertex shader */
  85415. maxVertexUniformVectors: number;
  85416. /** Maximum number of uniforms per fragment shader */
  85417. maxFragmentUniformVectors: number;
  85418. /** Defines if standard derivates (dx/dy) are supported */
  85419. standardDerivatives: boolean;
  85420. /** Defines if s3tc texture compression is supported */
  85421. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  85422. /** Defines if pvrtc texture compression is supported */
  85423. pvrtc: any;
  85424. /** Defines if etc1 texture compression is supported */
  85425. etc1: any;
  85426. /** Defines if etc2 texture compression is supported */
  85427. etc2: any;
  85428. /** Defines if astc texture compression is supported */
  85429. astc: any;
  85430. /** Defines if float textures are supported */
  85431. textureFloat: boolean;
  85432. /** Defines if vertex array objects are supported */
  85433. vertexArrayObject: boolean;
  85434. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  85435. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  85436. /** Gets the maximum level of anisotropy supported */
  85437. maxAnisotropy: number;
  85438. /** Defines if instancing is supported */
  85439. instancedArrays: boolean;
  85440. /** Defines if 32 bits indices are supported */
  85441. uintIndices: boolean;
  85442. /** Defines if high precision shaders are supported */
  85443. highPrecisionShaderSupported: boolean;
  85444. /** Defines if depth reading in the fragment shader is supported */
  85445. fragmentDepthSupported: boolean;
  85446. /** Defines if float texture linear filtering is supported*/
  85447. textureFloatLinearFiltering: boolean;
  85448. /** Defines if rendering to float textures is supported */
  85449. textureFloatRender: boolean;
  85450. /** Defines if half float textures are supported*/
  85451. textureHalfFloat: boolean;
  85452. /** Defines if half float texture linear filtering is supported*/
  85453. textureHalfFloatLinearFiltering: boolean;
  85454. /** Defines if rendering to half float textures is supported */
  85455. textureHalfFloatRender: boolean;
  85456. /** Defines if textureLOD shader command is supported */
  85457. textureLOD: boolean;
  85458. /** Defines if draw buffers extension is supported */
  85459. drawBuffersExtension: boolean;
  85460. /** Defines if depth textures are supported */
  85461. depthTextureExtension: boolean;
  85462. /** Defines if float color buffer are supported */
  85463. colorBufferFloat: boolean;
  85464. /** Gets disjoint timer query extension (null if not supported) */
  85465. timerQuery: EXT_disjoint_timer_query;
  85466. /** Defines if timestamp can be used with timer query */
  85467. canUseTimestampForTimerQuery: boolean;
  85468. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  85469. multiview: any;
  85470. /** Function used to let the system compiles shaders in background */
  85471. parallelShaderCompile: {
  85472. COMPLETION_STATUS_KHR: number;
  85473. };
  85474. }
  85475. /** Interface defining initialization parameters for Engine class */
  85476. export interface EngineOptions extends WebGLContextAttributes {
  85477. /**
  85478. * Defines if the engine should no exceed a specified device ratio
  85479. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  85480. */
  85481. limitDeviceRatio?: number;
  85482. /**
  85483. * Defines if webvr should be enabled automatically
  85484. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85485. */
  85486. autoEnableWebVR?: boolean;
  85487. /**
  85488. * Defines if webgl2 should be turned off even if supported
  85489. * @see http://doc.babylonjs.com/features/webgl2
  85490. */
  85491. disableWebGL2Support?: boolean;
  85492. /**
  85493. * Defines if webaudio should be initialized as well
  85494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85495. */
  85496. audioEngine?: boolean;
  85497. /**
  85498. * Defines if animations should run using a deterministic lock step
  85499. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85500. */
  85501. deterministicLockstep?: boolean;
  85502. /** Defines the maximum steps to use with deterministic lock step mode */
  85503. lockstepMaxSteps?: number;
  85504. /**
  85505. * Defines that engine should ignore context lost events
  85506. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  85507. */
  85508. doNotHandleContextLost?: boolean;
  85509. /**
  85510. * Defines that engine should ignore modifying touch action attribute and style
  85511. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  85512. */
  85513. doNotHandleTouchAction?: boolean;
  85514. /**
  85515. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  85516. */
  85517. useHighPrecisionFloats?: boolean;
  85518. }
  85519. /**
  85520. * Defines the interface used by display changed events
  85521. */
  85522. export interface IDisplayChangedEventArgs {
  85523. /** Gets the vrDisplay object (if any) */
  85524. vrDisplay: Nullable<any>;
  85525. /** Gets a boolean indicating if webVR is supported */
  85526. vrSupported: boolean;
  85527. }
  85528. /**
  85529. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  85530. */
  85531. export class Engine {
  85532. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  85533. static ExceptionList: ({
  85534. key: string;
  85535. capture: string;
  85536. captureConstraint: number;
  85537. targets: string[];
  85538. } | {
  85539. key: string;
  85540. capture: null;
  85541. captureConstraint: null;
  85542. targets: string[];
  85543. })[];
  85544. /** Gets the list of created engines */
  85545. static readonly Instances: Engine[];
  85546. /**
  85547. * Gets the latest created engine
  85548. */
  85549. static readonly LastCreatedEngine: Nullable<Engine>;
  85550. /**
  85551. * Gets the latest created scene
  85552. */
  85553. static readonly LastCreatedScene: Nullable<Scene>;
  85554. /**
  85555. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  85556. * @param flag defines which part of the materials must be marked as dirty
  85557. * @param predicate defines a predicate used to filter which materials should be affected
  85558. */
  85559. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  85560. /**
  85561. * Hidden
  85562. */
  85563. static _TextureLoaders: IInternalTextureLoader[];
  85564. /** Defines that alpha blending is disabled */
  85565. static readonly ALPHA_DISABLE: number;
  85566. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  85567. static readonly ALPHA_ADD: number;
  85568. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85569. static readonly ALPHA_COMBINE: number;
  85570. /** Defines that alpha blending to DEST - SRC * DEST */
  85571. static readonly ALPHA_SUBTRACT: number;
  85572. /** Defines that alpha blending to SRC * DEST */
  85573. static readonly ALPHA_MULTIPLY: number;
  85574. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  85575. static readonly ALPHA_MAXIMIZED: number;
  85576. /** Defines that alpha blending to SRC + DEST */
  85577. static readonly ALPHA_ONEONE: number;
  85578. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  85579. static readonly ALPHA_PREMULTIPLIED: number;
  85580. /**
  85581. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  85582. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  85583. */
  85584. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  85585. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  85586. static readonly ALPHA_INTERPOLATE: number;
  85587. /**
  85588. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  85589. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  85590. */
  85591. static readonly ALPHA_SCREENMODE: number;
  85592. /** Defines that the ressource is not delayed*/
  85593. static readonly DELAYLOADSTATE_NONE: number;
  85594. /** Defines that the ressource was successfully delay loaded */
  85595. static readonly DELAYLOADSTATE_LOADED: number;
  85596. /** Defines that the ressource is currently delay loading */
  85597. static readonly DELAYLOADSTATE_LOADING: number;
  85598. /** Defines that the ressource is delayed and has not started loading */
  85599. static readonly DELAYLOADSTATE_NOTLOADED: number;
  85600. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  85601. static readonly NEVER: number;
  85602. /** 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 */
  85603. static readonly ALWAYS: number;
  85604. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  85605. static readonly LESS: number;
  85606. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  85607. static readonly EQUAL: number;
  85608. /** 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 */
  85609. static readonly LEQUAL: number;
  85610. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  85611. static readonly GREATER: number;
  85612. /** 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 */
  85613. static readonly GEQUAL: number;
  85614. /** 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 */
  85615. static readonly NOTEQUAL: number;
  85616. /** Passed to stencilOperation to specify that stencil value must be kept */
  85617. static readonly KEEP: number;
  85618. /** Passed to stencilOperation to specify that stencil value must be replaced */
  85619. static readonly REPLACE: number;
  85620. /** Passed to stencilOperation to specify that stencil value must be incremented */
  85621. static readonly INCR: number;
  85622. /** Passed to stencilOperation to specify that stencil value must be decremented */
  85623. static readonly DECR: number;
  85624. /** Passed to stencilOperation to specify that stencil value must be inverted */
  85625. static readonly INVERT: number;
  85626. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  85627. static readonly INCR_WRAP: number;
  85628. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  85629. static readonly DECR_WRAP: number;
  85630. /** Texture is not repeating outside of 0..1 UVs */
  85631. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  85632. /** Texture is repeating outside of 0..1 UVs */
  85633. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  85634. /** Texture is repeating and mirrored */
  85635. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  85636. /** ALPHA */
  85637. static readonly TEXTUREFORMAT_ALPHA: number;
  85638. /** LUMINANCE */
  85639. static readonly TEXTUREFORMAT_LUMINANCE: number;
  85640. /** LUMINANCE_ALPHA */
  85641. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  85642. /** RGB */
  85643. static readonly TEXTUREFORMAT_RGB: number;
  85644. /** RGBA */
  85645. static readonly TEXTUREFORMAT_RGBA: number;
  85646. /** RED */
  85647. static readonly TEXTUREFORMAT_RED: number;
  85648. /** RED (2nd reference) */
  85649. static readonly TEXTUREFORMAT_R: number;
  85650. /** RG */
  85651. static readonly TEXTUREFORMAT_RG: number;
  85652. /** RED_INTEGER */
  85653. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  85654. /** RED_INTEGER (2nd reference) */
  85655. static readonly TEXTUREFORMAT_R_INTEGER: number;
  85656. /** RG_INTEGER */
  85657. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  85658. /** RGB_INTEGER */
  85659. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  85660. /** RGBA_INTEGER */
  85661. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  85662. /** UNSIGNED_BYTE */
  85663. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  85664. /** UNSIGNED_BYTE (2nd reference) */
  85665. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  85666. /** FLOAT */
  85667. static readonly TEXTURETYPE_FLOAT: number;
  85668. /** HALF_FLOAT */
  85669. static readonly TEXTURETYPE_HALF_FLOAT: number;
  85670. /** BYTE */
  85671. static readonly TEXTURETYPE_BYTE: number;
  85672. /** SHORT */
  85673. static readonly TEXTURETYPE_SHORT: number;
  85674. /** UNSIGNED_SHORT */
  85675. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  85676. /** INT */
  85677. static readonly TEXTURETYPE_INT: number;
  85678. /** UNSIGNED_INT */
  85679. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  85680. /** UNSIGNED_SHORT_4_4_4_4 */
  85681. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  85682. /** UNSIGNED_SHORT_5_5_5_1 */
  85683. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  85684. /** UNSIGNED_SHORT_5_6_5 */
  85685. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  85686. /** UNSIGNED_INT_2_10_10_10_REV */
  85687. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  85688. /** UNSIGNED_INT_24_8 */
  85689. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  85690. /** UNSIGNED_INT_10F_11F_11F_REV */
  85691. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  85692. /** UNSIGNED_INT_5_9_9_9_REV */
  85693. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  85694. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  85695. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  85696. /** nearest is mag = nearest and min = nearest and mip = linear */
  85697. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  85698. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85699. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  85700. /** Trilinear is mag = linear and min = linear and mip = linear */
  85701. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  85702. /** nearest is mag = nearest and min = nearest and mip = linear */
  85703. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  85704. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85705. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  85706. /** Trilinear is mag = linear and min = linear and mip = linear */
  85707. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  85708. /** mag = nearest and min = nearest and mip = nearest */
  85709. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  85710. /** mag = nearest and min = linear and mip = nearest */
  85711. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  85712. /** mag = nearest and min = linear and mip = linear */
  85713. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  85714. /** mag = nearest and min = linear and mip = none */
  85715. static readonly TEXTURE_NEAREST_LINEAR: number;
  85716. /** mag = nearest and min = nearest and mip = none */
  85717. static readonly TEXTURE_NEAREST_NEAREST: number;
  85718. /** mag = linear and min = nearest and mip = nearest */
  85719. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  85720. /** mag = linear and min = nearest and mip = linear */
  85721. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  85722. /** mag = linear and min = linear and mip = none */
  85723. static readonly TEXTURE_LINEAR_LINEAR: number;
  85724. /** mag = linear and min = nearest and mip = none */
  85725. static readonly TEXTURE_LINEAR_NEAREST: number;
  85726. /** Explicit coordinates mode */
  85727. static readonly TEXTURE_EXPLICIT_MODE: number;
  85728. /** Spherical coordinates mode */
  85729. static readonly TEXTURE_SPHERICAL_MODE: number;
  85730. /** Planar coordinates mode */
  85731. static readonly TEXTURE_PLANAR_MODE: number;
  85732. /** Cubic coordinates mode */
  85733. static readonly TEXTURE_CUBIC_MODE: number;
  85734. /** Projection coordinates mode */
  85735. static readonly TEXTURE_PROJECTION_MODE: number;
  85736. /** Skybox coordinates mode */
  85737. static readonly TEXTURE_SKYBOX_MODE: number;
  85738. /** Inverse Cubic coordinates mode */
  85739. static readonly TEXTURE_INVCUBIC_MODE: number;
  85740. /** Equirectangular coordinates mode */
  85741. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  85742. /** Equirectangular Fixed coordinates mode */
  85743. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  85744. /** Equirectangular Fixed Mirrored coordinates mode */
  85745. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85746. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  85747. static readonly SCALEMODE_FLOOR: number;
  85748. /** Defines that texture rescaling will look for the nearest power of 2 size */
  85749. static readonly SCALEMODE_NEAREST: number;
  85750. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  85751. static readonly SCALEMODE_CEILING: number;
  85752. /**
  85753. * Returns the current npm package of the sdk
  85754. */
  85755. static readonly NpmPackage: string;
  85756. /**
  85757. * Returns the current version of the framework
  85758. */
  85759. static readonly Version: string;
  85760. /**
  85761. * Returns a string describing the current engine
  85762. */
  85763. readonly description: string;
  85764. /**
  85765. * Gets or sets the epsilon value used by collision engine
  85766. */
  85767. static CollisionsEpsilon: number;
  85768. /**
  85769. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85770. */
  85771. static ShadersRepository: string;
  85772. /**
  85773. * Method called to create the default loading screen.
  85774. * This can be overriden in your own app.
  85775. * @param canvas The rendering canvas element
  85776. * @returns The loading screen
  85777. */
  85778. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  85779. /**
  85780. * Method called to create the default rescale post process on each engine.
  85781. */
  85782. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  85783. /**
  85784. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  85785. */
  85786. forcePOTTextures: boolean;
  85787. /**
  85788. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  85789. */
  85790. isFullscreen: boolean;
  85791. /**
  85792. * Gets a boolean indicating if the pointer is currently locked
  85793. */
  85794. isPointerLock: boolean;
  85795. /**
  85796. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  85797. */
  85798. cullBackFaces: boolean;
  85799. /**
  85800. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  85801. */
  85802. renderEvenInBackground: boolean;
  85803. /**
  85804. * Gets or sets a boolean indicating that cache can be kept between frames
  85805. */
  85806. preventCacheWipeBetweenFrames: boolean;
  85807. /**
  85808. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  85809. **/
  85810. enableOfflineSupport: boolean;
  85811. /**
  85812. * 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)
  85813. **/
  85814. disableManifestCheck: boolean;
  85815. /**
  85816. * Gets the list of created scenes
  85817. */
  85818. scenes: Scene[];
  85819. /**
  85820. * Event raised when a new scene is created
  85821. */
  85822. onNewSceneAddedObservable: Observable<Scene>;
  85823. /**
  85824. * Gets the list of created postprocesses
  85825. */
  85826. postProcesses: PostProcess[];
  85827. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  85828. validateShaderPrograms: boolean;
  85829. /**
  85830. * Observable event triggered each time the rendering canvas is resized
  85831. */
  85832. onResizeObservable: Observable<Engine>;
  85833. /**
  85834. * Observable event triggered each time the canvas loses focus
  85835. */
  85836. onCanvasBlurObservable: Observable<Engine>;
  85837. /**
  85838. * Observable event triggered each time the canvas gains focus
  85839. */
  85840. onCanvasFocusObservable: Observable<Engine>;
  85841. /**
  85842. * Observable event triggered each time the canvas receives pointerout event
  85843. */
  85844. onCanvasPointerOutObservable: Observable<PointerEvent>;
  85845. /**
  85846. * Observable event triggered before each texture is initialized
  85847. */
  85848. onBeforeTextureInitObservable: Observable<Texture>;
  85849. private _vrDisplay;
  85850. private _vrSupported;
  85851. private _oldSize;
  85852. private _oldHardwareScaleFactor;
  85853. private _vrExclusivePointerMode;
  85854. private _webVRInitPromise;
  85855. /**
  85856. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85857. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85858. */
  85859. readonly isInVRExclusivePointerMode: boolean;
  85860. /**
  85861. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  85862. */
  85863. disableUniformBuffers: boolean;
  85864. /** @hidden */
  85865. _uniformBuffers: UniformBuffer[];
  85866. /**
  85867. * Gets a boolean indicating that the engine supports uniform buffers
  85868. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85869. */
  85870. readonly supportsUniformBuffers: boolean;
  85871. /**
  85872. * Observable raised when the engine begins a new frame
  85873. */
  85874. onBeginFrameObservable: Observable<Engine>;
  85875. /**
  85876. * If set, will be used to request the next animation frame for the render loop
  85877. */
  85878. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  85879. /**
  85880. * Observable raised when the engine ends the current frame
  85881. */
  85882. onEndFrameObservable: Observable<Engine>;
  85883. /**
  85884. * Observable raised when the engine is about to compile a shader
  85885. */
  85886. onBeforeShaderCompilationObservable: Observable<Engine>;
  85887. /**
  85888. * Observable raised when the engine has jsut compiled a shader
  85889. */
  85890. onAfterShaderCompilationObservable: Observable<Engine>;
  85891. /** @hidden */
  85892. _gl: WebGLRenderingContext;
  85893. private _renderingCanvas;
  85894. private _windowIsBackground;
  85895. private _webGLVersion;
  85896. protected _highPrecisionShadersAllowed: boolean;
  85897. /** @hidden */
  85898. readonly _shouldUseHighPrecisionShader: boolean;
  85899. /**
  85900. * Gets a boolean indicating that only power of 2 textures are supported
  85901. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  85902. */
  85903. readonly needPOTTextures: boolean;
  85904. /** @hidden */
  85905. _badOS: boolean;
  85906. /** @hidden */
  85907. _badDesktopOS: boolean;
  85908. /**
  85909. * Gets or sets a value indicating if we want to disable texture binding optimization.
  85910. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  85911. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  85912. */
  85913. disableTextureBindingOptimization: boolean;
  85914. /**
  85915. * Gets the audio engine
  85916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85917. * @ignorenaming
  85918. */
  85919. static audioEngine: IAudioEngine;
  85920. /**
  85921. * Default AudioEngine factory responsible of creating the Audio Engine.
  85922. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  85923. */
  85924. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  85925. /**
  85926. * Default offline support factory responsible of creating a tool used to store data locally.
  85927. * By default, this will create a Database object if the workload has been embedded.
  85928. */
  85929. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  85930. private _onFocus;
  85931. private _onBlur;
  85932. private _onCanvasPointerOut;
  85933. private _onCanvasBlur;
  85934. private _onCanvasFocus;
  85935. private _onFullscreenChange;
  85936. private _onPointerLockChange;
  85937. private _onVRDisplayPointerRestricted;
  85938. private _onVRDisplayPointerUnrestricted;
  85939. private _onVrDisplayConnect;
  85940. private _onVrDisplayDisconnect;
  85941. private _onVrDisplayPresentChange;
  85942. /**
  85943. * Observable signaled when VR display mode changes
  85944. */
  85945. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85946. /**
  85947. * Observable signaled when VR request present is complete
  85948. */
  85949. onVRRequestPresentComplete: Observable<boolean>;
  85950. /**
  85951. * Observable signaled when VR request present starts
  85952. */
  85953. onVRRequestPresentStart: Observable<Engine>;
  85954. private _hardwareScalingLevel;
  85955. /** @hidden */
  85956. protected _caps: EngineCapabilities;
  85957. private _pointerLockRequested;
  85958. private _isStencilEnable;
  85959. private _colorWrite;
  85960. private _loadingScreen;
  85961. /** @hidden */
  85962. _drawCalls: PerfCounter;
  85963. /** @hidden */
  85964. _textureCollisions: PerfCounter;
  85965. private _glVersion;
  85966. private _glRenderer;
  85967. private _glVendor;
  85968. private _videoTextureSupported;
  85969. private _renderingQueueLaunched;
  85970. private _activeRenderLoops;
  85971. private _deterministicLockstep;
  85972. private _lockstepMaxSteps;
  85973. /**
  85974. * Observable signaled when a context lost event is raised
  85975. */
  85976. onContextLostObservable: Observable<Engine>;
  85977. /**
  85978. * Observable signaled when a context restored event is raised
  85979. */
  85980. onContextRestoredObservable: Observable<Engine>;
  85981. private _onContextLost;
  85982. private _onContextRestored;
  85983. private _contextWasLost;
  85984. private _doNotHandleContextLost;
  85985. /**
  85986. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  85987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  85988. */
  85989. doNotHandleContextLost: boolean;
  85990. private _performanceMonitor;
  85991. private _fps;
  85992. private _deltaTime;
  85993. /**
  85994. * Turn this value on if you want to pause FPS computation when in background
  85995. */
  85996. disablePerformanceMonitorInBackground: boolean;
  85997. /**
  85998. * Gets the performance monitor attached to this engine
  85999. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  86000. */
  86001. readonly performanceMonitor: PerformanceMonitor;
  86002. /** @hidden */
  86003. protected _depthCullingState: _DepthCullingState;
  86004. /** @hidden */
  86005. protected _stencilState: _StencilState;
  86006. /** @hidden */
  86007. protected _alphaState: _AlphaState;
  86008. /** @hidden */
  86009. protected _alphaMode: number;
  86010. protected _internalTexturesCache: InternalTexture[];
  86011. /** @hidden */
  86012. protected _activeChannel: number;
  86013. private _currentTextureChannel;
  86014. /** @hidden */
  86015. protected _boundTexturesCache: {
  86016. [key: string]: Nullable<InternalTexture>;
  86017. };
  86018. /** @hidden */
  86019. protected _currentEffect: Nullable<Effect>;
  86020. /** @hidden */
  86021. protected _currentProgram: Nullable<WebGLProgram>;
  86022. private _compiledEffects;
  86023. private _vertexAttribArraysEnabled;
  86024. /** @hidden */
  86025. protected _cachedViewport: Nullable<Viewport>;
  86026. private _cachedVertexArrayObject;
  86027. /** @hidden */
  86028. protected _cachedVertexBuffers: any;
  86029. /** @hidden */
  86030. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86031. /** @hidden */
  86032. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86033. /** @hidden */
  86034. protected _currentRenderTarget: Nullable<InternalTexture>;
  86035. private _uintIndicesCurrentlySet;
  86036. private _currentBoundBuffer;
  86037. /** @hidden */
  86038. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86039. private _currentBufferPointers;
  86040. private _currentInstanceLocations;
  86041. private _currentInstanceBuffers;
  86042. private _textureUnits;
  86043. private _firstBoundInternalTextureTracker;
  86044. private _lastBoundInternalTextureTracker;
  86045. private _workingCanvas;
  86046. private _workingContext;
  86047. private _rescalePostProcess;
  86048. private _dummyFramebuffer;
  86049. private _externalData;
  86050. private _bindedRenderFunction;
  86051. private _vaoRecordInProgress;
  86052. private _mustWipeVertexAttributes;
  86053. private _emptyTexture;
  86054. private _emptyCubeTexture;
  86055. private _emptyTexture3D;
  86056. /** @hidden */
  86057. _frameHandler: number;
  86058. private _nextFreeTextureSlots;
  86059. private _maxSimultaneousTextures;
  86060. private _activeRequests;
  86061. private _texturesSupported;
  86062. private _textureFormatInUse;
  86063. /**
  86064. * Gets the list of texture formats supported
  86065. */
  86066. readonly texturesSupported: Array<string>;
  86067. /**
  86068. * Gets the list of texture formats in use
  86069. */
  86070. readonly textureFormatInUse: Nullable<string>;
  86071. /**
  86072. * Gets the current viewport
  86073. */
  86074. readonly currentViewport: Nullable<Viewport>;
  86075. /**
  86076. * Gets the default empty texture
  86077. */
  86078. readonly emptyTexture: InternalTexture;
  86079. /**
  86080. * Gets the default empty 3D texture
  86081. */
  86082. readonly emptyTexture3D: InternalTexture;
  86083. /**
  86084. * Gets the default empty cube texture
  86085. */
  86086. readonly emptyCubeTexture: InternalTexture;
  86087. /**
  86088. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86089. */
  86090. readonly premultipliedAlpha: boolean;
  86091. /**
  86092. * Creates a new engine
  86093. * @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
  86094. * @param antialias defines enable antialiasing (default: false)
  86095. * @param options defines further options to be sent to the getContext() function
  86096. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86097. */
  86098. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86099. private _disableTouchAction;
  86100. private _rebuildInternalTextures;
  86101. private _rebuildEffects;
  86102. /**
  86103. * Gets a boolean indicating if all created effects are ready
  86104. * @returns true if all effects are ready
  86105. */
  86106. areAllEffectsReady(): boolean;
  86107. private _rebuildBuffers;
  86108. private _initGLContext;
  86109. /**
  86110. * Gets version of the current webGL context
  86111. */
  86112. readonly webGLVersion: number;
  86113. /**
  86114. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86115. */
  86116. readonly isStencilEnable: boolean;
  86117. private _prepareWorkingCanvas;
  86118. /**
  86119. * Reset the texture cache to empty state
  86120. */
  86121. resetTextureCache(): void;
  86122. /**
  86123. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86125. * @returns true if engine is in deterministic lock step mode
  86126. */
  86127. isDeterministicLockStep(): boolean;
  86128. /**
  86129. * Gets the max steps when engine is running in deterministic lock step
  86130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86131. * @returns the max steps
  86132. */
  86133. getLockstepMaxSteps(): number;
  86134. /**
  86135. * Gets an object containing information about the current webGL context
  86136. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86137. */
  86138. getGlInfo(): {
  86139. vendor: string;
  86140. renderer: string;
  86141. version: string;
  86142. };
  86143. /**
  86144. * Gets current aspect ratio
  86145. * @param camera defines the camera to use to get the aspect ratio
  86146. * @param useScreen defines if screen size must be used (or the current render target if any)
  86147. * @returns a number defining the aspect ratio
  86148. */
  86149. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86150. /**
  86151. * Gets current screen aspect ratio
  86152. * @returns a number defining the aspect ratio
  86153. */
  86154. getScreenAspectRatio(): number;
  86155. /**
  86156. * Gets the current render width
  86157. * @param useScreen defines if screen size must be used (or the current render target if any)
  86158. * @returns a number defining the current render width
  86159. */
  86160. getRenderWidth(useScreen?: boolean): number;
  86161. /**
  86162. * Gets the current render height
  86163. * @param useScreen defines if screen size must be used (or the current render target if any)
  86164. * @returns a number defining the current render height
  86165. */
  86166. getRenderHeight(useScreen?: boolean): number;
  86167. /**
  86168. * Gets the HTML canvas attached with the current webGL context
  86169. * @returns a HTML canvas
  86170. */
  86171. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86172. /**
  86173. * Gets the client rect of the HTML canvas attached with the current webGL context
  86174. * @returns a client rectanglee
  86175. */
  86176. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86177. /**
  86178. * Defines the hardware scaling level.
  86179. * By default the hardware scaling level is computed from the window device ratio.
  86180. * 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.
  86181. * @param level defines the level to use
  86182. */
  86183. setHardwareScalingLevel(level: number): void;
  86184. /**
  86185. * Gets the current hardware scaling level.
  86186. * By default the hardware scaling level is computed from the window device ratio.
  86187. * 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.
  86188. * @returns a number indicating the current hardware scaling level
  86189. */
  86190. getHardwareScalingLevel(): number;
  86191. /**
  86192. * Gets the list of loaded textures
  86193. * @returns an array containing all loaded textures
  86194. */
  86195. getLoadedTexturesCache(): InternalTexture[];
  86196. /**
  86197. * Gets the object containing all engine capabilities
  86198. * @returns the EngineCapabilities object
  86199. */
  86200. getCaps(): EngineCapabilities;
  86201. /**
  86202. * Gets the current depth function
  86203. * @returns a number defining the depth function
  86204. */
  86205. getDepthFunction(): Nullable<number>;
  86206. /**
  86207. * Sets the current depth function
  86208. * @param depthFunc defines the function to use
  86209. */
  86210. setDepthFunction(depthFunc: number): void;
  86211. /**
  86212. * Sets the current depth function to GREATER
  86213. */
  86214. setDepthFunctionToGreater(): void;
  86215. /**
  86216. * Sets the current depth function to GEQUAL
  86217. */
  86218. setDepthFunctionToGreaterOrEqual(): void;
  86219. /**
  86220. * Sets the current depth function to LESS
  86221. */
  86222. setDepthFunctionToLess(): void;
  86223. private _cachedStencilBuffer;
  86224. private _cachedStencilFunction;
  86225. private _cachedStencilMask;
  86226. private _cachedStencilOperationPass;
  86227. private _cachedStencilOperationFail;
  86228. private _cachedStencilOperationDepthFail;
  86229. private _cachedStencilReference;
  86230. /**
  86231. * Caches the the state of the stencil buffer
  86232. */
  86233. cacheStencilState(): void;
  86234. /**
  86235. * Restores the state of the stencil buffer
  86236. */
  86237. restoreStencilState(): void;
  86238. /**
  86239. * Sets the current depth function to LEQUAL
  86240. */
  86241. setDepthFunctionToLessOrEqual(): void;
  86242. /**
  86243. * Gets a boolean indicating if stencil buffer is enabled
  86244. * @returns the current stencil buffer state
  86245. */
  86246. getStencilBuffer(): boolean;
  86247. /**
  86248. * Enable or disable the stencil buffer
  86249. * @param enable defines if the stencil buffer must be enabled or disabled
  86250. */
  86251. setStencilBuffer(enable: boolean): void;
  86252. /**
  86253. * Gets the current stencil mask
  86254. * @returns a number defining the new stencil mask to use
  86255. */
  86256. getStencilMask(): number;
  86257. /**
  86258. * Sets the current stencil mask
  86259. * @param mask defines the new stencil mask to use
  86260. */
  86261. setStencilMask(mask: number): void;
  86262. /**
  86263. * Gets the current stencil function
  86264. * @returns a number defining the stencil function to use
  86265. */
  86266. getStencilFunction(): number;
  86267. /**
  86268. * Gets the current stencil reference value
  86269. * @returns a number defining the stencil reference value to use
  86270. */
  86271. getStencilFunctionReference(): number;
  86272. /**
  86273. * Gets the current stencil mask
  86274. * @returns a number defining the stencil mask to use
  86275. */
  86276. getStencilFunctionMask(): number;
  86277. /**
  86278. * Sets the current stencil function
  86279. * @param stencilFunc defines the new stencil function to use
  86280. */
  86281. setStencilFunction(stencilFunc: number): void;
  86282. /**
  86283. * Sets the current stencil reference
  86284. * @param reference defines the new stencil reference to use
  86285. */
  86286. setStencilFunctionReference(reference: number): void;
  86287. /**
  86288. * Sets the current stencil mask
  86289. * @param mask defines the new stencil mask to use
  86290. */
  86291. setStencilFunctionMask(mask: number): void;
  86292. /**
  86293. * Gets the current stencil operation when stencil fails
  86294. * @returns a number defining stencil operation to use when stencil fails
  86295. */
  86296. getStencilOperationFail(): number;
  86297. /**
  86298. * Gets the current stencil operation when depth fails
  86299. * @returns a number defining stencil operation to use when depth fails
  86300. */
  86301. getStencilOperationDepthFail(): number;
  86302. /**
  86303. * Gets the current stencil operation when stencil passes
  86304. * @returns a number defining stencil operation to use when stencil passes
  86305. */
  86306. getStencilOperationPass(): number;
  86307. /**
  86308. * Sets the stencil operation to use when stencil fails
  86309. * @param operation defines the stencil operation to use when stencil fails
  86310. */
  86311. setStencilOperationFail(operation: number): void;
  86312. /**
  86313. * Sets the stencil operation to use when depth fails
  86314. * @param operation defines the stencil operation to use when depth fails
  86315. */
  86316. setStencilOperationDepthFail(operation: number): void;
  86317. /**
  86318. * Sets the stencil operation to use when stencil passes
  86319. * @param operation defines the stencil operation to use when stencil passes
  86320. */
  86321. setStencilOperationPass(operation: number): void;
  86322. /**
  86323. * Sets a boolean indicating if the dithering state is enabled or disabled
  86324. * @param value defines the dithering state
  86325. */
  86326. setDitheringState(value: boolean): void;
  86327. /**
  86328. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  86329. * @param value defines the rasterizer state
  86330. */
  86331. setRasterizerState(value: boolean): void;
  86332. /**
  86333. * stop executing a render loop function and remove it from the execution array
  86334. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  86335. */
  86336. stopRenderLoop(renderFunction?: () => void): void;
  86337. /** @hidden */
  86338. _renderLoop(): void;
  86339. /**
  86340. * Register and execute a render loop. The engine can have more than one render function
  86341. * @param renderFunction defines the function to continuously execute
  86342. */
  86343. runRenderLoop(renderFunction: () => void): void;
  86344. /**
  86345. * Toggle full screen mode
  86346. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86347. */
  86348. switchFullscreen(requestPointerLock: boolean): void;
  86349. /**
  86350. * Enters full screen mode
  86351. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86352. */
  86353. enterFullscreen(requestPointerLock: boolean): void;
  86354. /**
  86355. * Exits full screen mode
  86356. */
  86357. exitFullscreen(): void;
  86358. /**
  86359. * Clear the current render buffer or the current render target (if any is set up)
  86360. * @param color defines the color to use
  86361. * @param backBuffer defines if the back buffer must be cleared
  86362. * @param depth defines if the depth buffer must be cleared
  86363. * @param stencil defines if the stencil buffer must be cleared
  86364. */
  86365. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  86366. /**
  86367. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  86368. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86369. * @param y defines the y-coordinate of the corner of the clear rectangle
  86370. * @param width defines the width of the clear rectangle
  86371. * @param height defines the height of the clear rectangle
  86372. * @param clearColor defines the clear color
  86373. */
  86374. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  86375. /**
  86376. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  86377. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86378. * @param y defines the y-coordinate of the corner of the clear rectangle
  86379. * @param width defines the width of the clear rectangle
  86380. * @param height defines the height of the clear rectangle
  86381. */
  86382. enableScissor(x: number, y: number, width: number, height: number): void;
  86383. /**
  86384. * Disable previously set scissor test rectangle
  86385. */
  86386. disableScissor(): void;
  86387. private _viewportCached;
  86388. /** @hidden */
  86389. _viewport(x: number, y: number, width: number, height: number): void;
  86390. /**
  86391. * Set the WebGL's viewport
  86392. * @param viewport defines the viewport element to be used
  86393. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  86394. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  86395. */
  86396. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  86397. /**
  86398. * Directly set the WebGL Viewport
  86399. * @param x defines the x coordinate of the viewport (in screen space)
  86400. * @param y defines the y coordinate of the viewport (in screen space)
  86401. * @param width defines the width of the viewport (in screen space)
  86402. * @param height defines the height of the viewport (in screen space)
  86403. * @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
  86404. */
  86405. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  86406. /**
  86407. * Begin a new frame
  86408. */
  86409. beginFrame(): void;
  86410. /**
  86411. * Enf the current frame
  86412. */
  86413. endFrame(): void;
  86414. /**
  86415. * Resize the view according to the canvas' size
  86416. */
  86417. resize(): void;
  86418. /**
  86419. * Force a specific size of the canvas
  86420. * @param width defines the new canvas' width
  86421. * @param height defines the new canvas' height
  86422. */
  86423. setSize(width: number, height: number): void;
  86424. /**
  86425. * Gets a boolean indicating if a webVR device was detected
  86426. * @returns true if a webVR device was detected
  86427. */
  86428. isVRDevicePresent(): boolean;
  86429. /**
  86430. * Gets the current webVR device
  86431. * @returns the current webVR device (or null)
  86432. */
  86433. getVRDevice(): any;
  86434. /**
  86435. * Initializes a webVR display and starts listening to display change events
  86436. * The onVRDisplayChangedObservable will be notified upon these changes
  86437. * @returns The onVRDisplayChangedObservable
  86438. */
  86439. initWebVR(): Observable<IDisplayChangedEventArgs>;
  86440. /**
  86441. * Initializes a webVR display and starts listening to display change events
  86442. * The onVRDisplayChangedObservable will be notified upon these changes
  86443. * @returns A promise containing a VRDisplay and if vr is supported
  86444. */
  86445. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  86446. /**
  86447. * Call this function to switch to webVR mode
  86448. * Will do nothing if webVR is not supported or if there is no webVR device
  86449. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86450. */
  86451. enableVR(): void;
  86452. /**
  86453. * Call this function to leave webVR mode
  86454. * Will do nothing if webVR is not supported or if there is no webVR device
  86455. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86456. */
  86457. disableVR(): void;
  86458. private _onVRFullScreenTriggered;
  86459. private _getVRDisplaysAsync;
  86460. /**
  86461. * Binds the frame buffer to the specified texture.
  86462. * @param texture The texture to render to or null for the default canvas
  86463. * @param faceIndex The face of the texture to render to in case of cube texture
  86464. * @param requiredWidth The width of the target to render to
  86465. * @param requiredHeight The height of the target to render to
  86466. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  86467. * @param depthStencilTexture The depth stencil texture to use to render
  86468. * @param lodLevel defines le lod level to bind to the frame buffer
  86469. */
  86470. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  86471. private bindUnboundFramebuffer;
  86472. /**
  86473. * Unbind the current render target texture from the webGL context
  86474. * @param texture defines the render target texture to unbind
  86475. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86476. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86477. */
  86478. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86479. /**
  86480. * Unbind a list of render target textures from the webGL context
  86481. * This is used only when drawBuffer extension or webGL2 are active
  86482. * @param textures defines the render target textures to unbind
  86483. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86484. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86485. */
  86486. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86487. /**
  86488. * Force the mipmap generation for the given render target texture
  86489. * @param texture defines the render target texture to use
  86490. */
  86491. generateMipMapsForCubemap(texture: InternalTexture): void;
  86492. /**
  86493. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  86494. */
  86495. flushFramebuffer(): void;
  86496. /**
  86497. * Unbind the current render target and bind the default framebuffer
  86498. */
  86499. restoreDefaultFramebuffer(): void;
  86500. /**
  86501. * Create an uniform buffer
  86502. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86503. * @param elements defines the content of the uniform buffer
  86504. * @returns the webGL uniform buffer
  86505. */
  86506. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  86507. /**
  86508. * Create a dynamic uniform buffer
  86509. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86510. * @param elements defines the content of the uniform buffer
  86511. * @returns the webGL uniform buffer
  86512. */
  86513. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  86514. /**
  86515. * Update an existing uniform buffer
  86516. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86517. * @param uniformBuffer defines the target uniform buffer
  86518. * @param elements defines the content to update
  86519. * @param offset defines the offset in the uniform buffer where update should start
  86520. * @param count defines the size of the data to update
  86521. */
  86522. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86523. private _resetVertexBufferBinding;
  86524. /**
  86525. * Creates a vertex buffer
  86526. * @param data the data for the vertex buffer
  86527. * @returns the new WebGL static buffer
  86528. */
  86529. createVertexBuffer(data: DataArray): WebGLBuffer;
  86530. /**
  86531. * Creates a dynamic vertex buffer
  86532. * @param data the data for the dynamic vertex buffer
  86533. * @returns the new WebGL dynamic buffer
  86534. */
  86535. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  86536. /**
  86537. * Update a dynamic index buffer
  86538. * @param indexBuffer defines the target index buffer
  86539. * @param indices defines the data to update
  86540. * @param offset defines the offset in the target index buffer where update should start
  86541. */
  86542. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  86543. /**
  86544. * Updates a dynamic vertex buffer.
  86545. * @param vertexBuffer the vertex buffer to update
  86546. * @param data the data used to update the vertex buffer
  86547. * @param byteOffset the byte offset of the data
  86548. * @param byteLength the byte length of the data
  86549. */
  86550. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  86551. private _resetIndexBufferBinding;
  86552. /**
  86553. * Creates a new index buffer
  86554. * @param indices defines the content of the index buffer
  86555. * @param updatable defines if the index buffer must be updatable
  86556. * @returns a new webGL buffer
  86557. */
  86558. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  86559. /**
  86560. * Bind a webGL buffer to the webGL context
  86561. * @param buffer defines the buffer to bind
  86562. */
  86563. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  86564. /**
  86565. * Bind an uniform buffer to the current webGL context
  86566. * @param buffer defines the buffer to bind
  86567. */
  86568. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  86569. /**
  86570. * Bind a buffer to the current webGL context at a given location
  86571. * @param buffer defines the buffer to bind
  86572. * @param location defines the index where to bind the buffer
  86573. */
  86574. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  86575. /**
  86576. * Bind a specific block at a given index in a specific shader program
  86577. * @param shaderProgram defines the shader program
  86578. * @param blockName defines the block name
  86579. * @param index defines the index where to bind the block
  86580. */
  86581. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  86582. private bindIndexBuffer;
  86583. private bindBuffer;
  86584. /**
  86585. * update the bound buffer with the given data
  86586. * @param data defines the data to update
  86587. */
  86588. updateArrayBuffer(data: Float32Array): void;
  86589. private _vertexAttribPointer;
  86590. private _bindIndexBufferWithCache;
  86591. private _bindVertexBuffersAttributes;
  86592. /**
  86593. * Records a vertex array object
  86594. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86595. * @param vertexBuffers defines the list of vertex buffers to store
  86596. * @param indexBuffer defines the index buffer to store
  86597. * @param effect defines the effect to store
  86598. * @returns the new vertex array object
  86599. */
  86600. recordVertexArrayObject(vertexBuffers: {
  86601. [key: string]: VertexBuffer;
  86602. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  86603. /**
  86604. * Bind a specific vertex array object
  86605. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86606. * @param vertexArrayObject defines the vertex array object to bind
  86607. * @param indexBuffer defines the index buffer to bind
  86608. */
  86609. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  86610. /**
  86611. * Bind webGl buffers directly to the webGL context
  86612. * @param vertexBuffer defines the vertex buffer to bind
  86613. * @param indexBuffer defines the index buffer to bind
  86614. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  86615. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  86616. * @param effect defines the effect associated with the vertex buffer
  86617. */
  86618. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  86619. private _unbindVertexArrayObject;
  86620. /**
  86621. * Bind a list of vertex buffers to the webGL context
  86622. * @param vertexBuffers defines the list of vertex buffers to bind
  86623. * @param indexBuffer defines the index buffer to bind
  86624. * @param effect defines the effect associated with the vertex buffers
  86625. */
  86626. bindBuffers(vertexBuffers: {
  86627. [key: string]: Nullable<VertexBuffer>;
  86628. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  86629. /**
  86630. * Unbind all instance attributes
  86631. */
  86632. unbindInstanceAttributes(): void;
  86633. /**
  86634. * Release and free the memory of a vertex array object
  86635. * @param vao defines the vertex array object to delete
  86636. */
  86637. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  86638. /** @hidden */
  86639. _releaseBuffer(buffer: WebGLBuffer): boolean;
  86640. /**
  86641. * Creates a webGL buffer to use with instanciation
  86642. * @param capacity defines the size of the buffer
  86643. * @returns the webGL buffer
  86644. */
  86645. createInstancesBuffer(capacity: number): WebGLBuffer;
  86646. /**
  86647. * Delete a webGL buffer used with instanciation
  86648. * @param buffer defines the webGL buffer to delete
  86649. */
  86650. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  86651. /**
  86652. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  86653. * @param instancesBuffer defines the webGL buffer to update and bind
  86654. * @param data defines the data to store in the buffer
  86655. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  86656. */
  86657. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  86658. /**
  86659. * Apply all cached states (depth, culling, stencil and alpha)
  86660. */
  86661. applyStates(): void;
  86662. /**
  86663. * Send a draw order
  86664. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86665. * @param indexStart defines the starting index
  86666. * @param indexCount defines the number of index to draw
  86667. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86668. */
  86669. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  86670. /**
  86671. * Draw a list of points
  86672. * @param verticesStart defines the index of first vertex to draw
  86673. * @param verticesCount defines the count of vertices to draw
  86674. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86675. */
  86676. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86677. /**
  86678. * Draw a list of unindexed primitives
  86679. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86680. * @param verticesStart defines the index of first vertex to draw
  86681. * @param verticesCount defines the count of vertices to draw
  86682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86683. */
  86684. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86685. /**
  86686. * Draw a list of indexed primitives
  86687. * @param fillMode defines the primitive to use
  86688. * @param indexStart defines the starting index
  86689. * @param indexCount defines the number of index to draw
  86690. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86691. */
  86692. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  86693. /**
  86694. * Draw a list of unindexed primitives
  86695. * @param fillMode defines the primitive to use
  86696. * @param verticesStart defines the index of first vertex to draw
  86697. * @param verticesCount defines the count of vertices to draw
  86698. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86699. */
  86700. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86701. private _drawMode;
  86702. /** @hidden */
  86703. _releaseEffect(effect: Effect): void;
  86704. /** @hidden */
  86705. _deleteProgram(program: WebGLProgram): void;
  86706. /**
  86707. * Create a new effect (used to store vertex/fragment shaders)
  86708. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  86709. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  86710. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  86711. * @param samplers defines an array of string used to represent textures
  86712. * @param defines defines the string containing the defines to use to compile the shaders
  86713. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  86714. * @param onCompiled defines a function to call when the effect creation is successful
  86715. * @param onError defines a function to call when the effect creation has failed
  86716. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  86717. * @returns the new Effect
  86718. */
  86719. 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;
  86720. private _compileShader;
  86721. private _compileRawShader;
  86722. /**
  86723. * Directly creates a webGL program
  86724. * @param vertexCode defines the vertex shader code to use
  86725. * @param fragmentCode defines the fragment shader code to use
  86726. * @param context defines the webGL context to use (if not set, the current one will be used)
  86727. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86728. * @returns the new webGL program
  86729. */
  86730. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86731. /**
  86732. * Creates a webGL program
  86733. * @param vertexCode defines the vertex shader code to use
  86734. * @param fragmentCode defines the fragment shader code to use
  86735. * @param defines defines the string containing the defines to use to compile the shaders
  86736. * @param context defines the webGL context to use (if not set, the current one will be used)
  86737. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86738. * @returns the new webGL program
  86739. */
  86740. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86741. private _createShaderProgram;
  86742. private _finalizeProgram;
  86743. /** @hidden */
  86744. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  86745. /** @hidden */
  86746. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  86747. /**
  86748. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  86749. * @param shaderProgram defines the webGL program to use
  86750. * @param uniformsNames defines the list of uniform names
  86751. * @returns an array of webGL uniform locations
  86752. */
  86753. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  86754. /**
  86755. * Gets the lsit of active attributes for a given webGL program
  86756. * @param shaderProgram defines the webGL program to use
  86757. * @param attributesNames defines the list of attribute names to get
  86758. * @returns an array of indices indicating the offset of each attribute
  86759. */
  86760. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  86761. /**
  86762. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  86763. * @param effect defines the effect to activate
  86764. */
  86765. enableEffect(effect: Nullable<Effect>): void;
  86766. /**
  86767. * Set the value of an uniform to an array of int32
  86768. * @param uniform defines the webGL uniform location where to store the value
  86769. * @param array defines the array of int32 to store
  86770. */
  86771. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86772. /**
  86773. * Set the value of an uniform to an array of int32 (stored as vec2)
  86774. * @param uniform defines the webGL uniform location where to store the value
  86775. * @param array defines the array of int32 to store
  86776. */
  86777. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86778. /**
  86779. * Set the value of an uniform to an array of int32 (stored as vec3)
  86780. * @param uniform defines the webGL uniform location where to store the value
  86781. * @param array defines the array of int32 to store
  86782. */
  86783. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86784. /**
  86785. * Set the value of an uniform to an array of int32 (stored as vec4)
  86786. * @param uniform defines the webGL uniform location where to store the value
  86787. * @param array defines the array of int32 to store
  86788. */
  86789. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86790. /**
  86791. * Set the value of an uniform to an array of float32
  86792. * @param uniform defines the webGL uniform location where to store the value
  86793. * @param array defines the array of float32 to store
  86794. */
  86795. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86796. /**
  86797. * Set the value of an uniform to an array of float32 (stored as vec2)
  86798. * @param uniform defines the webGL uniform location where to store the value
  86799. * @param array defines the array of float32 to store
  86800. */
  86801. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86802. /**
  86803. * Set the value of an uniform to an array of float32 (stored as vec3)
  86804. * @param uniform defines the webGL uniform location where to store the value
  86805. * @param array defines the array of float32 to store
  86806. */
  86807. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86808. /**
  86809. * Set the value of an uniform to an array of float32 (stored as vec4)
  86810. * @param uniform defines the webGL uniform location where to store the value
  86811. * @param array defines the array of float32 to store
  86812. */
  86813. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86814. /**
  86815. * Set the value of an uniform to an array of number
  86816. * @param uniform defines the webGL uniform location where to store the value
  86817. * @param array defines the array of number to store
  86818. */
  86819. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86820. /**
  86821. * Set the value of an uniform to an array of number (stored as vec2)
  86822. * @param uniform defines the webGL uniform location where to store the value
  86823. * @param array defines the array of number to store
  86824. */
  86825. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86826. /**
  86827. * Set the value of an uniform to an array of number (stored as vec3)
  86828. * @param uniform defines the webGL uniform location where to store the value
  86829. * @param array defines the array of number to store
  86830. */
  86831. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86832. /**
  86833. * Set the value of an uniform to an array of number (stored as vec4)
  86834. * @param uniform defines the webGL uniform location where to store the value
  86835. * @param array defines the array of number to store
  86836. */
  86837. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86838. /**
  86839. * Set the value of an uniform to an array of float32 (stored as matrices)
  86840. * @param uniform defines the webGL uniform location where to store the value
  86841. * @param matrices defines the array of float32 to store
  86842. */
  86843. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  86844. /**
  86845. * Set the value of an uniform to a matrix
  86846. * @param uniform defines the webGL uniform location where to store the value
  86847. * @param matrix defines the matrix to store
  86848. */
  86849. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  86850. /**
  86851. * Set the value of an uniform to a matrix (3x3)
  86852. * @param uniform defines the webGL uniform location where to store the value
  86853. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  86854. */
  86855. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86856. /**
  86857. * Set the value of an uniform to a matrix (2x2)
  86858. * @param uniform defines the webGL uniform location where to store the value
  86859. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  86860. */
  86861. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86862. /**
  86863. * Set the value of an uniform to a number (int)
  86864. * @param uniform defines the webGL uniform location where to store the value
  86865. * @param value defines the int number to store
  86866. */
  86867. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86868. /**
  86869. * Set the value of an uniform to a number (float)
  86870. * @param uniform defines the webGL uniform location where to store the value
  86871. * @param value defines the float number to store
  86872. */
  86873. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86874. /**
  86875. * Set the value of an uniform to a vec2
  86876. * @param uniform defines the webGL uniform location where to store the value
  86877. * @param x defines the 1st component of the value
  86878. * @param y defines the 2nd component of the value
  86879. */
  86880. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  86881. /**
  86882. * Set the value of an uniform to a vec3
  86883. * @param uniform defines the webGL uniform location where to store the value
  86884. * @param x defines the 1st component of the value
  86885. * @param y defines the 2nd component of the value
  86886. * @param z defines the 3rd component of the value
  86887. */
  86888. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  86889. /**
  86890. * Set the value of an uniform to a boolean
  86891. * @param uniform defines the webGL uniform location where to store the value
  86892. * @param bool defines the boolean to store
  86893. */
  86894. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  86895. /**
  86896. * Set the value of an uniform to a vec4
  86897. * @param uniform defines the webGL uniform location where to store the value
  86898. * @param x defines the 1st component of the value
  86899. * @param y defines the 2nd component of the value
  86900. * @param z defines the 3rd component of the value
  86901. * @param w defines the 4th component of the value
  86902. */
  86903. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  86904. /**
  86905. * Set the value of an uniform to a Color3
  86906. * @param uniform defines the webGL uniform location where to store the value
  86907. * @param color3 defines the color to store
  86908. */
  86909. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  86910. /**
  86911. * Set the value of an uniform to a Color3 and an alpha value
  86912. * @param uniform defines the webGL uniform location where to store the value
  86913. * @param color3 defines the color to store
  86914. * @param alpha defines the alpha component to store
  86915. */
  86916. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  86917. /**
  86918. * Sets a Color4 on a uniform variable
  86919. * @param uniform defines the uniform location
  86920. * @param color4 defines the value to be set
  86921. */
  86922. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  86923. /**
  86924. * Set various states to the webGL context
  86925. * @param culling defines backface culling state
  86926. * @param zOffset defines the value to apply to zOffset (0 by default)
  86927. * @param force defines if states must be applied even if cache is up to date
  86928. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  86929. */
  86930. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  86931. /**
  86932. * Set the z offset to apply to current rendering
  86933. * @param value defines the offset to apply
  86934. */
  86935. setZOffset(value: number): void;
  86936. /**
  86937. * Gets the current value of the zOffset
  86938. * @returns the current zOffset state
  86939. */
  86940. getZOffset(): number;
  86941. /**
  86942. * Enable or disable depth buffering
  86943. * @param enable defines the state to set
  86944. */
  86945. setDepthBuffer(enable: boolean): void;
  86946. /**
  86947. * Gets a boolean indicating if depth writing is enabled
  86948. * @returns the current depth writing state
  86949. */
  86950. getDepthWrite(): boolean;
  86951. /**
  86952. * Enable or disable depth writing
  86953. * @param enable defines the state to set
  86954. */
  86955. setDepthWrite(enable: boolean): void;
  86956. /**
  86957. * Enable or disable color writing
  86958. * @param enable defines the state to set
  86959. */
  86960. setColorWrite(enable: boolean): void;
  86961. /**
  86962. * Gets a boolean indicating if color writing is enabled
  86963. * @returns the current color writing state
  86964. */
  86965. getColorWrite(): boolean;
  86966. /**
  86967. * Sets alpha constants used by some alpha blending modes
  86968. * @param r defines the red component
  86969. * @param g defines the green component
  86970. * @param b defines the blue component
  86971. * @param a defines the alpha component
  86972. */
  86973. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  86974. /**
  86975. * Sets the current alpha mode
  86976. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  86977. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  86978. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86979. */
  86980. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  86981. /**
  86982. * Gets the current alpha mode
  86983. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86984. * @returns the current alpha mode
  86985. */
  86986. getAlphaMode(): number;
  86987. /**
  86988. * Clears the list of texture accessible through engine.
  86989. * This can help preventing texture load conflict due to name collision.
  86990. */
  86991. clearInternalTexturesCache(): void;
  86992. /**
  86993. * Force the entire cache to be cleared
  86994. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  86995. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  86996. */
  86997. wipeCaches(bruteForce?: boolean): void;
  86998. /**
  86999. * Set the compressed texture format to use, based on the formats you have, and the formats
  87000. * supported by the hardware / browser.
  87001. *
  87002. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  87003. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  87004. * to API arguments needed to compressed textures. This puts the burden on the container
  87005. * generator to house the arcane code for determining these for current & future formats.
  87006. *
  87007. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  87008. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  87009. *
  87010. * Note: The result of this call is not taken into account when a texture is base64.
  87011. *
  87012. * @param formatsAvailable defines the list of those format families you have created
  87013. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87014. *
  87015. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87016. * @returns The extension selected.
  87017. */
  87018. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87019. private _getSamplingParameters;
  87020. private _partialLoadImg;
  87021. private _cascadeLoadImgs;
  87022. /** @hidden */
  87023. _createTexture(): WebGLTexture;
  87024. /**
  87025. * Usually called from Texture.ts.
  87026. * Passed information to create a WebGLTexture
  87027. * @param urlArg defines a value which contains one of the following:
  87028. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87029. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87030. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87031. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87032. * @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)
  87033. * @param scene needed for loading to the correct scene
  87034. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87035. * @param onLoad optional callback to be called upon successful completion
  87036. * @param onError optional callback to be called upon failure
  87037. * @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
  87038. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87039. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87040. * @param forcedExtension defines the extension to use to pick the right loader
  87041. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87042. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87043. */
  87044. 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;
  87045. private _rescaleTexture;
  87046. /**
  87047. * Update a raw texture
  87048. * @param texture defines the texture to update
  87049. * @param data defines the data to store in the texture
  87050. * @param format defines the format of the data
  87051. * @param invertY defines if data must be stored with Y axis inverted
  87052. * @param compression defines the compression used (null by default)
  87053. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87054. */
  87055. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87056. /**
  87057. * Creates a raw texture
  87058. * @param data defines the data to store in the texture
  87059. * @param width defines the width of the texture
  87060. * @param height defines the height of the texture
  87061. * @param format defines the format of the data
  87062. * @param generateMipMaps defines if the engine should generate the mip levels
  87063. * @param invertY defines if data must be stored with Y axis inverted
  87064. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87065. * @param compression defines the compression used (null by default)
  87066. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87067. * @returns the raw texture inside an InternalTexture
  87068. */
  87069. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87070. private _unpackFlipYCached;
  87071. /**
  87072. * In case you are sharing the context with other applications, it might
  87073. * be interested to not cache the unpack flip y state to ensure a consistent
  87074. * value would be set.
  87075. */
  87076. enableUnpackFlipYCached: boolean;
  87077. /** @hidden */
  87078. _unpackFlipY(value: boolean): void;
  87079. /** @hidden */
  87080. _getUnpackAlignement(): number;
  87081. /**
  87082. * Creates a dynamic texture
  87083. * @param width defines the width of the texture
  87084. * @param height defines the height of the texture
  87085. * @param generateMipMaps defines if the engine should generate the mip levels
  87086. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87087. * @returns the dynamic texture inside an InternalTexture
  87088. */
  87089. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87090. /**
  87091. * Update the sampling mode of a given texture
  87092. * @param samplingMode defines the required sampling mode
  87093. * @param texture defines the texture to update
  87094. */
  87095. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87096. /**
  87097. * Update the content of a dynamic texture
  87098. * @param texture defines the texture to update
  87099. * @param canvas defines the canvas containing the source
  87100. * @param invertY defines if data must be stored with Y axis inverted
  87101. * @param premulAlpha defines if alpha is stored as premultiplied
  87102. * @param format defines the format of the data
  87103. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87104. */
  87105. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87106. /**
  87107. * Update a video texture
  87108. * @param texture defines the texture to update
  87109. * @param video defines the video element to use
  87110. * @param invertY defines if data must be stored with Y axis inverted
  87111. */
  87112. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87113. /**
  87114. * Updates a depth texture Comparison Mode and Function.
  87115. * If the comparison Function is equal to 0, the mode will be set to none.
  87116. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87117. * @param texture The texture to set the comparison function for
  87118. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87119. */
  87120. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87121. private _setupDepthStencilTexture;
  87122. /**
  87123. * Creates a depth stencil texture.
  87124. * This is only available in WebGL 2 or with the depth texture extension available.
  87125. * @param size The size of face edge in the texture.
  87126. * @param options The options defining the texture.
  87127. * @returns The texture
  87128. */
  87129. createDepthStencilTexture(size: number | {
  87130. width: number;
  87131. height: number;
  87132. }, options: DepthTextureCreationOptions): InternalTexture;
  87133. /**
  87134. * Creates a depth stencil texture.
  87135. * This is only available in WebGL 2 or with the depth texture extension available.
  87136. * @param size The size of face edge in the texture.
  87137. * @param options The options defining the texture.
  87138. * @returns The texture
  87139. */
  87140. private _createDepthStencilTexture;
  87141. /**
  87142. * Creates a depth stencil cube texture.
  87143. * This is only available in WebGL 2.
  87144. * @param size The size of face edge in the cube texture.
  87145. * @param options The options defining the cube texture.
  87146. * @returns The cube texture
  87147. */
  87148. private _createDepthStencilCubeTexture;
  87149. /**
  87150. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87151. * @param renderTarget The render target to set the frame buffer for
  87152. */
  87153. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87154. /**
  87155. * Creates a new render target texture
  87156. * @param size defines the size of the texture
  87157. * @param options defines the options used to create the texture
  87158. * @returns a new render target texture stored in an InternalTexture
  87159. */
  87160. createRenderTargetTexture(size: number | {
  87161. width: number;
  87162. height: number;
  87163. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87164. /**
  87165. * Create a multi render target texture
  87166. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87167. * @param size defines the size of the texture
  87168. * @param options defines the creation options
  87169. * @returns the cube texture as an InternalTexture
  87170. */
  87171. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87172. private _setupFramebufferDepthAttachments;
  87173. /**
  87174. * Updates the sample count of a render target texture
  87175. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87176. * @param texture defines the texture to update
  87177. * @param samples defines the sample count to set
  87178. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87179. */
  87180. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87181. /**
  87182. * Update the sample count for a given multiple render target texture
  87183. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87184. * @param textures defines the textures to update
  87185. * @param samples defines the sample count to set
  87186. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87187. */
  87188. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87189. /** @hidden */
  87190. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87191. /** @hidden */
  87192. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87193. /** @hidden */
  87194. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87195. /** @hidden */
  87196. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87197. /**
  87198. * Creates a new multiview render target
  87199. * @param width defines the width of the texture
  87200. * @param height defines the height of the texture
  87201. * @returns the created multiview texture
  87202. */
  87203. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  87204. /**
  87205. * Binds a multiview framebuffer to be drawn to
  87206. * @param multiviewTexture texture to bind
  87207. */
  87208. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  87209. /**
  87210. * Creates a new render target cube texture
  87211. * @param size defines the size of the texture
  87212. * @param options defines the options used to create the texture
  87213. * @returns a new render target cube texture stored in an InternalTexture
  87214. */
  87215. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87216. /**
  87217. * Creates a cube texture
  87218. * @param rootUrl defines the url where the files to load is located
  87219. * @param scene defines the current scene
  87220. * @param files defines the list of files to load (1 per face)
  87221. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87222. * @param onLoad defines an optional callback raised when the texture is loaded
  87223. * @param onError defines an optional callback raised if there is an issue to load the texture
  87224. * @param format defines the format of the data
  87225. * @param forcedExtension defines the extension to use to pick the right loader
  87226. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87227. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87228. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87229. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87230. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  87231. * @returns the cube texture as an InternalTexture
  87232. */
  87233. 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;
  87234. /**
  87235. * @hidden
  87236. */
  87237. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87238. /**
  87239. * Update a raw cube texture
  87240. * @param texture defines the texture to udpdate
  87241. * @param data defines the data to store
  87242. * @param format defines the data format
  87243. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87244. * @param invertY defines if data must be stored with Y axis inverted
  87245. * @param compression defines the compression used (null by default)
  87246. * @param level defines which level of the texture to update
  87247. */
  87248. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  87249. /**
  87250. * Creates a new raw cube texture
  87251. * @param data defines the array of data to use to create each face
  87252. * @param size defines the size of the textures
  87253. * @param format defines the format of the data
  87254. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87255. * @param generateMipMaps defines if the engine should generate the mip levels
  87256. * @param invertY defines if data must be stored with Y axis inverted
  87257. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87258. * @param compression defines the compression used (null by default)
  87259. * @returns the cube texture as an InternalTexture
  87260. */
  87261. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  87262. /**
  87263. * Creates a new raw cube texture from a specified url
  87264. * @param url defines the url where the data is located
  87265. * @param scene defines the current scene
  87266. * @param size defines the size of the textures
  87267. * @param format defines the format of the data
  87268. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87269. * @param noMipmap defines if the engine should avoid generating the mip levels
  87270. * @param callback defines a callback used to extract texture data from loaded data
  87271. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  87272. * @param onLoad defines a callback called when texture is loaded
  87273. * @param onError defines a callback called if there is an error
  87274. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87275. * @param invertY defines if data must be stored with Y axis inverted
  87276. * @returns the cube texture as an InternalTexture
  87277. */
  87278. 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;
  87279. /**
  87280. * Update a raw 3D texture
  87281. * @param texture defines the texture to update
  87282. * @param data defines the data to store
  87283. * @param format defines the data format
  87284. * @param invertY defines if data must be stored with Y axis inverted
  87285. * @param compression defines the used compression (can be null)
  87286. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  87287. */
  87288. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  87289. /**
  87290. * Creates a new raw 3D texture
  87291. * @param data defines the data used to create the texture
  87292. * @param width defines the width of the texture
  87293. * @param height defines the height of the texture
  87294. * @param depth defines the depth of the texture
  87295. * @param format defines the format of the texture
  87296. * @param generateMipMaps defines if the engine must generate mip levels
  87297. * @param invertY defines if data must be stored with Y axis inverted
  87298. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87299. * @param compression defines the compressed used (can be null)
  87300. * @param textureType defines the compressed used (can be null)
  87301. * @returns a new raw 3D texture (stored in an InternalTexture)
  87302. */
  87303. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  87304. private _prepareWebGLTextureContinuation;
  87305. private _prepareWebGLTexture;
  87306. private _convertRGBtoRGBATextureData;
  87307. /** @hidden */
  87308. _releaseFramebufferObjects(texture: InternalTexture): void;
  87309. /** @hidden */
  87310. _releaseTexture(texture: InternalTexture): void;
  87311. private setProgram;
  87312. private _boundUniforms;
  87313. /**
  87314. * Binds an effect to the webGL context
  87315. * @param effect defines the effect to bind
  87316. */
  87317. bindSamplers(effect: Effect): void;
  87318. private _moveBoundTextureOnTop;
  87319. private _getCorrectTextureChannel;
  87320. private _linkTrackers;
  87321. private _removeDesignatedSlot;
  87322. private _activateCurrentTexture;
  87323. /** @hidden */
  87324. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  87325. /** @hidden */
  87326. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  87327. /**
  87328. * Sets a texture to the webGL context from a postprocess
  87329. * @param channel defines the channel to use
  87330. * @param postProcess defines the source postprocess
  87331. */
  87332. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  87333. /**
  87334. * Binds the output of the passed in post process to the texture channel specified
  87335. * @param channel The channel the texture should be bound to
  87336. * @param postProcess The post process which's output should be bound
  87337. */
  87338. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  87339. /**
  87340. * Unbind all textures from the webGL context
  87341. */
  87342. unbindAllTextures(): void;
  87343. /**
  87344. * Sets a texture to the according uniform.
  87345. * @param channel The texture channel
  87346. * @param uniform The uniform to set
  87347. * @param texture The texture to apply
  87348. */
  87349. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  87350. /**
  87351. * Sets a depth stencil texture from a render target to the according uniform.
  87352. * @param channel The texture channel
  87353. * @param uniform The uniform to set
  87354. * @param texture The render target texture containing the depth stencil texture to apply
  87355. */
  87356. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  87357. private _bindSamplerUniformToChannel;
  87358. private _getTextureWrapMode;
  87359. private _setTexture;
  87360. /**
  87361. * Sets an array of texture to the webGL context
  87362. * @param channel defines the channel where the texture array must be set
  87363. * @param uniform defines the associated uniform location
  87364. * @param textures defines the array of textures to bind
  87365. */
  87366. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  87367. /** @hidden */
  87368. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  87369. private _setTextureParameterFloat;
  87370. private _setTextureParameterInteger;
  87371. /**
  87372. * Reads pixels from the current frame buffer. Please note that this function can be slow
  87373. * @param x defines the x coordinate of the rectangle where pixels must be read
  87374. * @param y defines the y coordinate of the rectangle where pixels must be read
  87375. * @param width defines the width of the rectangle where pixels must be read
  87376. * @param height defines the height of the rectangle where pixels must be read
  87377. * @returns a Uint8Array containing RGBA colors
  87378. */
  87379. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  87380. /**
  87381. * Add an externaly attached data from its key.
  87382. * This method call will fail and return false, if such key already exists.
  87383. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  87384. * @param key the unique key that identifies the data
  87385. * @param data the data object to associate to the key for this Engine instance
  87386. * @return true if no such key were already present and the data was added successfully, false otherwise
  87387. */
  87388. addExternalData<T>(key: string, data: T): boolean;
  87389. /**
  87390. * Get an externaly attached data from its key
  87391. * @param key the unique key that identifies the data
  87392. * @return the associated data, if present (can be null), or undefined if not present
  87393. */
  87394. getExternalData<T>(key: string): T;
  87395. /**
  87396. * Get an externaly attached data from its key, create it using a factory if it's not already present
  87397. * @param key the unique key that identifies the data
  87398. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  87399. * @return the associated data, can be null if the factory returned null.
  87400. */
  87401. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  87402. /**
  87403. * Remove an externaly attached data from the Engine instance
  87404. * @param key the unique key that identifies the data
  87405. * @return true if the data was successfully removed, false if it doesn't exist
  87406. */
  87407. removeExternalData(key: string): boolean;
  87408. /**
  87409. * Unbind all vertex attributes from the webGL context
  87410. */
  87411. unbindAllAttributes(): void;
  87412. /**
  87413. * 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
  87414. */
  87415. releaseEffects(): void;
  87416. /**
  87417. * Dispose and release all associated resources
  87418. */
  87419. dispose(): void;
  87420. /**
  87421. * Display the loading screen
  87422. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87423. */
  87424. displayLoadingUI(): void;
  87425. /**
  87426. * Hide the loading screen
  87427. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87428. */
  87429. hideLoadingUI(): void;
  87430. /**
  87431. * Gets the current loading screen object
  87432. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87433. */
  87434. /**
  87435. * Sets the current loading screen object
  87436. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87437. */
  87438. loadingScreen: ILoadingScreen;
  87439. /**
  87440. * Sets the current loading screen text
  87441. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87442. */
  87443. loadingUIText: string;
  87444. /**
  87445. * Sets the current loading screen background color
  87446. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87447. */
  87448. loadingUIBackgroundColor: string;
  87449. /**
  87450. * Attach a new callback raised when context lost event is fired
  87451. * @param callback defines the callback to call
  87452. */
  87453. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87454. /**
  87455. * Attach a new callback raised when context restored event is fired
  87456. * @param callback defines the callback to call
  87457. */
  87458. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87459. /**
  87460. * Gets the source code of the vertex shader associated with a specific webGL program
  87461. * @param program defines the program to use
  87462. * @returns a string containing the source code of the vertex shader associated with the program
  87463. */
  87464. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  87465. /**
  87466. * Gets the source code of the fragment shader associated with a specific webGL program
  87467. * @param program defines the program to use
  87468. * @returns a string containing the source code of the fragment shader associated with the program
  87469. */
  87470. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  87471. /**
  87472. * Get the current error code of the webGL context
  87473. * @returns the error code
  87474. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  87475. */
  87476. getError(): number;
  87477. /**
  87478. * Gets the current framerate
  87479. * @returns a number representing the framerate
  87480. */
  87481. getFps(): number;
  87482. /**
  87483. * Gets the time spent between current and previous frame
  87484. * @returns a number representing the delta time in ms
  87485. */
  87486. getDeltaTime(): number;
  87487. private _measureFps;
  87488. /** @hidden */
  87489. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  87490. private _canRenderToFloatFramebuffer;
  87491. private _canRenderToHalfFloatFramebuffer;
  87492. private _canRenderToFramebuffer;
  87493. /** @hidden */
  87494. _getWebGLTextureType(type: number): number;
  87495. private _getInternalFormat;
  87496. /** @hidden */
  87497. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  87498. /** @hidden */
  87499. _getRGBAMultiSampleBufferFormat(type: number): number;
  87500. /** @hidden */
  87501. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  87502. /** @hidden */
  87503. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  87504. private _partialLoadFile;
  87505. private _cascadeLoadFiles;
  87506. /**
  87507. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  87508. * @returns true if the engine can be created
  87509. * @ignorenaming
  87510. */
  87511. static isSupported(): boolean;
  87512. }
  87513. }
  87514. declare module BABYLON {
  87515. /**
  87516. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87517. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87518. */
  87519. export class EffectFallbacks {
  87520. private _defines;
  87521. private _currentRank;
  87522. private _maxRank;
  87523. private _mesh;
  87524. /**
  87525. * Removes the fallback from the bound mesh.
  87526. */
  87527. unBindMesh(): void;
  87528. /**
  87529. * Adds a fallback on the specified property.
  87530. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87531. * @param define The name of the define in the shader
  87532. */
  87533. addFallback(rank: number, define: string): void;
  87534. /**
  87535. * Sets the mesh to use CPU skinning when needing to fallback.
  87536. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87537. * @param mesh The mesh to use the fallbacks.
  87538. */
  87539. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87540. /**
  87541. * Checks to see if more fallbacks are still availible.
  87542. */
  87543. readonly isMoreFallbacks: boolean;
  87544. /**
  87545. * Removes the defines that shoould be removed when falling back.
  87546. * @param currentDefines defines the current define statements for the shader.
  87547. * @param effect defines the current effect we try to compile
  87548. * @returns The resulting defines with defines of the current rank removed.
  87549. */
  87550. reduce(currentDefines: string, effect: Effect): string;
  87551. }
  87552. /**
  87553. * Options to be used when creating an effect.
  87554. */
  87555. export class EffectCreationOptions {
  87556. /**
  87557. * Atrributes that will be used in the shader.
  87558. */
  87559. attributes: string[];
  87560. /**
  87561. * Uniform varible names that will be set in the shader.
  87562. */
  87563. uniformsNames: string[];
  87564. /**
  87565. * Uniform buffer varible names that will be set in the shader.
  87566. */
  87567. uniformBuffersNames: string[];
  87568. /**
  87569. * Sampler texture variable names that will be set in the shader.
  87570. */
  87571. samplers: string[];
  87572. /**
  87573. * Define statements that will be set in the shader.
  87574. */
  87575. defines: any;
  87576. /**
  87577. * Possible fallbacks for this effect to improve performance when needed.
  87578. */
  87579. fallbacks: Nullable<EffectFallbacks>;
  87580. /**
  87581. * Callback that will be called when the shader is compiled.
  87582. */
  87583. onCompiled: Nullable<(effect: Effect) => void>;
  87584. /**
  87585. * Callback that will be called if an error occurs during shader compilation.
  87586. */
  87587. onError: Nullable<(effect: Effect, errors: string) => void>;
  87588. /**
  87589. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87590. */
  87591. indexParameters: any;
  87592. /**
  87593. * Max number of lights that can be used in the shader.
  87594. */
  87595. maxSimultaneousLights: number;
  87596. /**
  87597. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  87598. */
  87599. transformFeedbackVaryings: Nullable<string[]>;
  87600. }
  87601. /**
  87602. * Effect containing vertex and fragment shader that can be executed on an object.
  87603. */
  87604. export class Effect {
  87605. /**
  87606. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87607. */
  87608. static ShadersRepository: string;
  87609. /**
  87610. * Name of the effect.
  87611. */
  87612. name: any;
  87613. /**
  87614. * String container all the define statements that should be set on the shader.
  87615. */
  87616. defines: string;
  87617. /**
  87618. * Callback that will be called when the shader is compiled.
  87619. */
  87620. onCompiled: Nullable<(effect: Effect) => void>;
  87621. /**
  87622. * Callback that will be called if an error occurs during shader compilation.
  87623. */
  87624. onError: Nullable<(effect: Effect, errors: string) => void>;
  87625. /**
  87626. * Callback that will be called when effect is bound.
  87627. */
  87628. onBind: Nullable<(effect: Effect) => void>;
  87629. /**
  87630. * Unique ID of the effect.
  87631. */
  87632. uniqueId: number;
  87633. /**
  87634. * Observable that will be called when the shader is compiled.
  87635. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  87636. */
  87637. onCompileObservable: Observable<Effect>;
  87638. /**
  87639. * Observable that will be called if an error occurs during shader compilation.
  87640. */
  87641. onErrorObservable: Observable<Effect>;
  87642. /** @hidden */
  87643. _onBindObservable: Nullable<Observable<Effect>>;
  87644. /**
  87645. * Observable that will be called when effect is bound.
  87646. */
  87647. readonly onBindObservable: Observable<Effect>;
  87648. /** @hidden */
  87649. _bonesComputationForcedToCPU: boolean;
  87650. private static _uniqueIdSeed;
  87651. private _engine;
  87652. private _uniformBuffersNames;
  87653. private _uniformsNames;
  87654. private _samplers;
  87655. private _isReady;
  87656. private _compilationError;
  87657. private _attributesNames;
  87658. private _attributes;
  87659. private _uniforms;
  87660. /**
  87661. * Key for the effect.
  87662. * @hidden
  87663. */
  87664. _key: string;
  87665. private _indexParameters;
  87666. private _fallbacks;
  87667. private _vertexSourceCode;
  87668. private _fragmentSourceCode;
  87669. private _vertexSourceCodeOverride;
  87670. private _fragmentSourceCodeOverride;
  87671. private _transformFeedbackVaryings;
  87672. /**
  87673. * Compiled shader to webGL program.
  87674. * @hidden
  87675. */
  87676. _program: WebGLProgram;
  87677. private _valueCache;
  87678. private static _baseCache;
  87679. /**
  87680. * Instantiates an effect.
  87681. * An effect can be used to create/manage/execute vertex and fragment shaders.
  87682. * @param baseName Name of the effect.
  87683. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  87684. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  87685. * @param samplers List of sampler variables that will be passed to the shader.
  87686. * @param engine Engine to be used to render the effect
  87687. * @param defines Define statements to be added to the shader.
  87688. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  87689. * @param onCompiled Callback that will be called when the shader is compiled.
  87690. * @param onError Callback that will be called if an error occurs during shader compilation.
  87691. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87692. */
  87693. 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);
  87694. /**
  87695. * Unique key for this effect
  87696. */
  87697. readonly key: string;
  87698. /**
  87699. * If the effect has been compiled and prepared.
  87700. * @returns if the effect is compiled and prepared.
  87701. */
  87702. isReady(): boolean;
  87703. /**
  87704. * The engine the effect was initialized with.
  87705. * @returns the engine.
  87706. */
  87707. getEngine(): Engine;
  87708. /**
  87709. * The compiled webGL program for the effect
  87710. * @returns the webGL program.
  87711. */
  87712. getProgram(): WebGLProgram;
  87713. /**
  87714. * The set of names of attribute variables for the shader.
  87715. * @returns An array of attribute names.
  87716. */
  87717. getAttributesNames(): string[];
  87718. /**
  87719. * Returns the attribute at the given index.
  87720. * @param index The index of the attribute.
  87721. * @returns The location of the attribute.
  87722. */
  87723. getAttributeLocation(index: number): number;
  87724. /**
  87725. * Returns the attribute based on the name of the variable.
  87726. * @param name of the attribute to look up.
  87727. * @returns the attribute location.
  87728. */
  87729. getAttributeLocationByName(name: string): number;
  87730. /**
  87731. * The number of attributes.
  87732. * @returns the numnber of attributes.
  87733. */
  87734. getAttributesCount(): number;
  87735. /**
  87736. * Gets the index of a uniform variable.
  87737. * @param uniformName of the uniform to look up.
  87738. * @returns the index.
  87739. */
  87740. getUniformIndex(uniformName: string): number;
  87741. /**
  87742. * Returns the attribute based on the name of the variable.
  87743. * @param uniformName of the uniform to look up.
  87744. * @returns the location of the uniform.
  87745. */
  87746. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  87747. /**
  87748. * Returns an array of sampler variable names
  87749. * @returns The array of sampler variable neames.
  87750. */
  87751. getSamplers(): string[];
  87752. /**
  87753. * The error from the last compilation.
  87754. * @returns the error string.
  87755. */
  87756. getCompilationError(): string;
  87757. /**
  87758. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  87759. * @param func The callback to be used.
  87760. */
  87761. executeWhenCompiled(func: (effect: Effect) => void): void;
  87762. private _checkIsReady;
  87763. /** @hidden */
  87764. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  87765. /** @hidden */
  87766. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  87767. /** @hidden */
  87768. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  87769. private _processShaderConversion;
  87770. private _processIncludes;
  87771. private _processPrecision;
  87772. /**
  87773. * Recompiles the webGL program
  87774. * @param vertexSourceCode The source code for the vertex shader.
  87775. * @param fragmentSourceCode The source code for the fragment shader.
  87776. * @param onCompiled Callback called when completed.
  87777. * @param onError Callback called on error.
  87778. * @hidden
  87779. */
  87780. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  87781. /**
  87782. * Gets the uniform locations of the the specified variable names
  87783. * @param names THe names of the variables to lookup.
  87784. * @returns Array of locations in the same order as variable names.
  87785. */
  87786. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  87787. /**
  87788. * Prepares the effect
  87789. * @hidden
  87790. */
  87791. _prepareEffect(): void;
  87792. /**
  87793. * Checks if the effect is supported. (Must be called after compilation)
  87794. */
  87795. readonly isSupported: boolean;
  87796. /**
  87797. * Binds a texture to the engine to be used as output of the shader.
  87798. * @param channel Name of the output variable.
  87799. * @param texture Texture to bind.
  87800. * @hidden
  87801. */
  87802. _bindTexture(channel: string, texture: InternalTexture): void;
  87803. /**
  87804. * Sets a texture on the engine to be used in the shader.
  87805. * @param channel Name of the sampler variable.
  87806. * @param texture Texture to set.
  87807. */
  87808. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  87809. /**
  87810. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  87811. * @param channel Name of the sampler variable.
  87812. * @param texture Texture to set.
  87813. */
  87814. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  87815. /**
  87816. * Sets an array of textures on the engine to be used in the shader.
  87817. * @param channel Name of the variable.
  87818. * @param textures Textures to set.
  87819. */
  87820. setTextureArray(channel: string, textures: BaseTexture[]): void;
  87821. /**
  87822. * 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)
  87823. * @param channel Name of the sampler variable.
  87824. * @param postProcess Post process to get the input texture from.
  87825. */
  87826. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  87827. /**
  87828. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  87829. * 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)
  87830. * @param channel Name of the sampler variable.
  87831. * @param postProcess Post process to get the output texture from.
  87832. */
  87833. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  87834. /** @hidden */
  87835. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  87836. /** @hidden */
  87837. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  87838. /** @hidden */
  87839. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  87840. /** @hidden */
  87841. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  87842. /**
  87843. * Binds a buffer to a uniform.
  87844. * @param buffer Buffer to bind.
  87845. * @param name Name of the uniform variable to bind to.
  87846. */
  87847. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  87848. /**
  87849. * Binds block to a uniform.
  87850. * @param blockName Name of the block to bind.
  87851. * @param index Index to bind.
  87852. */
  87853. bindUniformBlock(blockName: string, index: number): void;
  87854. /**
  87855. * Sets an interger value on a uniform variable.
  87856. * @param uniformName Name of the variable.
  87857. * @param value Value to be set.
  87858. * @returns this effect.
  87859. */
  87860. setInt(uniformName: string, value: number): Effect;
  87861. /**
  87862. * Sets an int array on a uniform variable.
  87863. * @param uniformName Name of the variable.
  87864. * @param array array to be set.
  87865. * @returns this effect.
  87866. */
  87867. setIntArray(uniformName: string, array: Int32Array): Effect;
  87868. /**
  87869. * 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)
  87870. * @param uniformName Name of the variable.
  87871. * @param array array to be set.
  87872. * @returns this effect.
  87873. */
  87874. setIntArray2(uniformName: string, array: Int32Array): Effect;
  87875. /**
  87876. * 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)
  87877. * @param uniformName Name of the variable.
  87878. * @param array array to be set.
  87879. * @returns this effect.
  87880. */
  87881. setIntArray3(uniformName: string, array: Int32Array): Effect;
  87882. /**
  87883. * 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)
  87884. * @param uniformName Name of the variable.
  87885. * @param array array to be set.
  87886. * @returns this effect.
  87887. */
  87888. setIntArray4(uniformName: string, array: Int32Array): Effect;
  87889. /**
  87890. * Sets an float array on a uniform variable.
  87891. * @param uniformName Name of the variable.
  87892. * @param array array to be set.
  87893. * @returns this effect.
  87894. */
  87895. setFloatArray(uniformName: string, array: Float32Array): Effect;
  87896. /**
  87897. * 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)
  87898. * @param uniformName Name of the variable.
  87899. * @param array array to be set.
  87900. * @returns this effect.
  87901. */
  87902. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  87903. /**
  87904. * 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)
  87905. * @param uniformName Name of the variable.
  87906. * @param array array to be set.
  87907. * @returns this effect.
  87908. */
  87909. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  87910. /**
  87911. * 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)
  87912. * @param uniformName Name of the variable.
  87913. * @param array array to be set.
  87914. * @returns this effect.
  87915. */
  87916. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  87917. /**
  87918. * Sets an array on a uniform variable.
  87919. * @param uniformName Name of the variable.
  87920. * @param array array to be set.
  87921. * @returns this effect.
  87922. */
  87923. setArray(uniformName: string, array: number[]): Effect;
  87924. /**
  87925. * 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)
  87926. * @param uniformName Name of the variable.
  87927. * @param array array to be set.
  87928. * @returns this effect.
  87929. */
  87930. setArray2(uniformName: string, array: number[]): Effect;
  87931. /**
  87932. * 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)
  87933. * @param uniformName Name of the variable.
  87934. * @param array array to be set.
  87935. * @returns this effect.
  87936. */
  87937. setArray3(uniformName: string, array: number[]): Effect;
  87938. /**
  87939. * 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)
  87940. * @param uniformName Name of the variable.
  87941. * @param array array to be set.
  87942. * @returns this effect.
  87943. */
  87944. setArray4(uniformName: string, array: number[]): Effect;
  87945. /**
  87946. * Sets matrices on a uniform variable.
  87947. * @param uniformName Name of the variable.
  87948. * @param matrices matrices to be set.
  87949. * @returns this effect.
  87950. */
  87951. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  87952. /**
  87953. * Sets matrix on a uniform variable.
  87954. * @param uniformName Name of the variable.
  87955. * @param matrix matrix to be set.
  87956. * @returns this effect.
  87957. */
  87958. setMatrix(uniformName: string, matrix: Matrix): Effect;
  87959. /**
  87960. * 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)
  87961. * @param uniformName Name of the variable.
  87962. * @param matrix matrix to be set.
  87963. * @returns this effect.
  87964. */
  87965. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  87966. /**
  87967. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  87968. * @param uniformName Name of the variable.
  87969. * @param matrix matrix to be set.
  87970. * @returns this effect.
  87971. */
  87972. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  87973. /**
  87974. * Sets a float on a uniform variable.
  87975. * @param uniformName Name of the variable.
  87976. * @param value value to be set.
  87977. * @returns this effect.
  87978. */
  87979. setFloat(uniformName: string, value: number): Effect;
  87980. /**
  87981. * Sets a boolean on a uniform variable.
  87982. * @param uniformName Name of the variable.
  87983. * @param bool value to be set.
  87984. * @returns this effect.
  87985. */
  87986. setBool(uniformName: string, bool: boolean): Effect;
  87987. /**
  87988. * Sets a Vector2 on a uniform variable.
  87989. * @param uniformName Name of the variable.
  87990. * @param vector2 vector2 to be set.
  87991. * @returns this effect.
  87992. */
  87993. setVector2(uniformName: string, vector2: Vector2): Effect;
  87994. /**
  87995. * Sets a float2 on a uniform variable.
  87996. * @param uniformName Name of the variable.
  87997. * @param x First float in float2.
  87998. * @param y Second float in float2.
  87999. * @returns this effect.
  88000. */
  88001. setFloat2(uniformName: string, x: number, y: number): Effect;
  88002. /**
  88003. * Sets a Vector3 on a uniform variable.
  88004. * @param uniformName Name of the variable.
  88005. * @param vector3 Value to be set.
  88006. * @returns this effect.
  88007. */
  88008. setVector3(uniformName: string, vector3: Vector3): Effect;
  88009. /**
  88010. * Sets a float3 on a uniform variable.
  88011. * @param uniformName Name of the variable.
  88012. * @param x First float in float3.
  88013. * @param y Second float in float3.
  88014. * @param z Third float in float3.
  88015. * @returns this effect.
  88016. */
  88017. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88018. /**
  88019. * Sets a Vector4 on a uniform variable.
  88020. * @param uniformName Name of the variable.
  88021. * @param vector4 Value to be set.
  88022. * @returns this effect.
  88023. */
  88024. setVector4(uniformName: string, vector4: Vector4): Effect;
  88025. /**
  88026. * Sets a float4 on a uniform variable.
  88027. * @param uniformName Name of the variable.
  88028. * @param x First float in float4.
  88029. * @param y Second float in float4.
  88030. * @param z Third float in float4.
  88031. * @param w Fourth float in float4.
  88032. * @returns this effect.
  88033. */
  88034. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88035. /**
  88036. * Sets a Color3 on a uniform variable.
  88037. * @param uniformName Name of the variable.
  88038. * @param color3 Value to be set.
  88039. * @returns this effect.
  88040. */
  88041. setColor3(uniformName: string, color3: Color3): Effect;
  88042. /**
  88043. * Sets a Color4 on a uniform variable.
  88044. * @param uniformName Name of the variable.
  88045. * @param color3 Value to be set.
  88046. * @param alpha Alpha value to be set.
  88047. * @returns this effect.
  88048. */
  88049. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88050. /**
  88051. * Sets a Color4 on a uniform variable
  88052. * @param uniformName defines the name of the variable
  88053. * @param color4 defines the value to be set
  88054. * @returns this effect.
  88055. */
  88056. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88057. /**
  88058. * This function will add a new shader to the shader store
  88059. * @param name the name of the shader
  88060. * @param pixelShader optional pixel shader content
  88061. * @param vertexShader optional vertex shader content
  88062. */
  88063. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88064. /**
  88065. * Store of each shader (The can be looked up using effect.key)
  88066. */
  88067. static ShadersStore: {
  88068. [key: string]: string;
  88069. };
  88070. /**
  88071. * Store of each included file for a shader (The can be looked up using effect.key)
  88072. */
  88073. static IncludesShadersStore: {
  88074. [key: string]: string;
  88075. };
  88076. /**
  88077. * Resets the cache of effects.
  88078. */
  88079. static ResetCache(): void;
  88080. }
  88081. }
  88082. declare module BABYLON {
  88083. /**
  88084. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88085. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88086. * 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;
  88087. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88088. */
  88089. export class ColorCurves {
  88090. private _dirty;
  88091. private _tempColor;
  88092. private _globalCurve;
  88093. private _highlightsCurve;
  88094. private _midtonesCurve;
  88095. private _shadowsCurve;
  88096. private _positiveCurve;
  88097. private _negativeCurve;
  88098. private _globalHue;
  88099. private _globalDensity;
  88100. private _globalSaturation;
  88101. private _globalExposure;
  88102. /**
  88103. * Gets the global Hue value.
  88104. * 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).
  88105. */
  88106. /**
  88107. * Sets the global Hue value.
  88108. * 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).
  88109. */
  88110. globalHue: number;
  88111. /**
  88112. * Gets the global Density value.
  88113. * 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.
  88114. * Values less than zero provide a filter of opposite hue.
  88115. */
  88116. /**
  88117. * Sets the global Density value.
  88118. * 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.
  88119. * Values less than zero provide a filter of opposite hue.
  88120. */
  88121. globalDensity: number;
  88122. /**
  88123. * Gets the global Saturation value.
  88124. * 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.
  88125. */
  88126. /**
  88127. * Sets the global Saturation value.
  88128. * 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.
  88129. */
  88130. globalSaturation: number;
  88131. /**
  88132. * Gets the global Exposure value.
  88133. * 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.
  88134. */
  88135. /**
  88136. * Sets the global Exposure value.
  88137. * 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.
  88138. */
  88139. globalExposure: number;
  88140. private _highlightsHue;
  88141. private _highlightsDensity;
  88142. private _highlightsSaturation;
  88143. private _highlightsExposure;
  88144. /**
  88145. * Gets the highlights Hue value.
  88146. * 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).
  88147. */
  88148. /**
  88149. * Sets the highlights Hue value.
  88150. * 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).
  88151. */
  88152. highlightsHue: number;
  88153. /**
  88154. * Gets the highlights Density value.
  88155. * 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.
  88156. * Values less than zero provide a filter of opposite hue.
  88157. */
  88158. /**
  88159. * Sets the highlights Density value.
  88160. * 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.
  88161. * Values less than zero provide a filter of opposite hue.
  88162. */
  88163. highlightsDensity: number;
  88164. /**
  88165. * Gets the highlights Saturation value.
  88166. * 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.
  88167. */
  88168. /**
  88169. * Sets the highlights Saturation value.
  88170. * 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.
  88171. */
  88172. highlightsSaturation: number;
  88173. /**
  88174. * Gets the highlights Exposure value.
  88175. * 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.
  88176. */
  88177. /**
  88178. * Sets the highlights Exposure value.
  88179. * 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.
  88180. */
  88181. highlightsExposure: number;
  88182. private _midtonesHue;
  88183. private _midtonesDensity;
  88184. private _midtonesSaturation;
  88185. private _midtonesExposure;
  88186. /**
  88187. * Gets the midtones Hue value.
  88188. * 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).
  88189. */
  88190. /**
  88191. * Sets the midtones Hue value.
  88192. * 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).
  88193. */
  88194. midtonesHue: number;
  88195. /**
  88196. * Gets the midtones Density value.
  88197. * 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.
  88198. * Values less than zero provide a filter of opposite hue.
  88199. */
  88200. /**
  88201. * Sets the midtones Density value.
  88202. * 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.
  88203. * Values less than zero provide a filter of opposite hue.
  88204. */
  88205. midtonesDensity: number;
  88206. /**
  88207. * Gets the midtones Saturation value.
  88208. * 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.
  88209. */
  88210. /**
  88211. * Sets the midtones Saturation value.
  88212. * 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.
  88213. */
  88214. midtonesSaturation: number;
  88215. /**
  88216. * Gets the midtones Exposure value.
  88217. * 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.
  88218. */
  88219. /**
  88220. * Sets the midtones Exposure value.
  88221. * 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.
  88222. */
  88223. midtonesExposure: number;
  88224. private _shadowsHue;
  88225. private _shadowsDensity;
  88226. private _shadowsSaturation;
  88227. private _shadowsExposure;
  88228. /**
  88229. * Gets the shadows Hue value.
  88230. * 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).
  88231. */
  88232. /**
  88233. * Sets the shadows Hue value.
  88234. * 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).
  88235. */
  88236. shadowsHue: number;
  88237. /**
  88238. * Gets the shadows Density value.
  88239. * 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.
  88240. * Values less than zero provide a filter of opposite hue.
  88241. */
  88242. /**
  88243. * Sets the shadows Density value.
  88244. * 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.
  88245. * Values less than zero provide a filter of opposite hue.
  88246. */
  88247. shadowsDensity: number;
  88248. /**
  88249. * Gets the shadows Saturation value.
  88250. * 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.
  88251. */
  88252. /**
  88253. * Sets the shadows Saturation value.
  88254. * 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.
  88255. */
  88256. shadowsSaturation: number;
  88257. /**
  88258. * Gets the shadows Exposure value.
  88259. * 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.
  88260. */
  88261. /**
  88262. * Sets the shadows Exposure value.
  88263. * 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.
  88264. */
  88265. shadowsExposure: number;
  88266. /**
  88267. * Returns the class name
  88268. * @returns The class name
  88269. */
  88270. getClassName(): string;
  88271. /**
  88272. * Binds the color curves to the shader.
  88273. * @param colorCurves The color curve to bind
  88274. * @param effect The effect to bind to
  88275. * @param positiveUniform The positive uniform shader parameter
  88276. * @param neutralUniform The neutral uniform shader parameter
  88277. * @param negativeUniform The negative uniform shader parameter
  88278. */
  88279. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88280. /**
  88281. * Prepare the list of uniforms associated with the ColorCurves effects.
  88282. * @param uniformsList The list of uniforms used in the effect
  88283. */
  88284. static PrepareUniforms(uniformsList: string[]): void;
  88285. /**
  88286. * Returns color grading data based on a hue, density, saturation and exposure value.
  88287. * @param filterHue The hue of the color filter.
  88288. * @param filterDensity The density of the color filter.
  88289. * @param saturation The saturation.
  88290. * @param exposure The exposure.
  88291. * @param result The result data container.
  88292. */
  88293. private getColorGradingDataToRef;
  88294. /**
  88295. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88296. * @param value The input slider value in range [-100,100].
  88297. * @returns Adjusted value.
  88298. */
  88299. private static applyColorGradingSliderNonlinear;
  88300. /**
  88301. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88302. * @param hue The hue (H) input.
  88303. * @param saturation The saturation (S) input.
  88304. * @param brightness The brightness (B) input.
  88305. * @result An RGBA color represented as Vector4.
  88306. */
  88307. private static fromHSBToRef;
  88308. /**
  88309. * Returns a value clamped between min and max
  88310. * @param value The value to clamp
  88311. * @param min The minimum of value
  88312. * @param max The maximum of value
  88313. * @returns The clamped value.
  88314. */
  88315. private static clamp;
  88316. /**
  88317. * Clones the current color curve instance.
  88318. * @return The cloned curves
  88319. */
  88320. clone(): ColorCurves;
  88321. /**
  88322. * Serializes the current color curve instance to a json representation.
  88323. * @return a JSON representation
  88324. */
  88325. serialize(): any;
  88326. /**
  88327. * Parses the color curve from a json representation.
  88328. * @param source the JSON source to parse
  88329. * @return The parsed curves
  88330. */
  88331. static Parse(source: any): ColorCurves;
  88332. }
  88333. }
  88334. declare module BABYLON {
  88335. /**
  88336. * Interface to follow in your material defines to integrate easily the
  88337. * Image proccessing functions.
  88338. * @hidden
  88339. */
  88340. export interface IImageProcessingConfigurationDefines {
  88341. IMAGEPROCESSING: boolean;
  88342. VIGNETTE: boolean;
  88343. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88344. VIGNETTEBLENDMODEOPAQUE: boolean;
  88345. TONEMAPPING: boolean;
  88346. TONEMAPPING_ACES: boolean;
  88347. CONTRAST: boolean;
  88348. EXPOSURE: boolean;
  88349. COLORCURVES: boolean;
  88350. COLORGRADING: boolean;
  88351. COLORGRADING3D: boolean;
  88352. SAMPLER3DGREENDEPTH: boolean;
  88353. SAMPLER3DBGRMAP: boolean;
  88354. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88355. }
  88356. /**
  88357. * @hidden
  88358. */
  88359. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88360. IMAGEPROCESSING: boolean;
  88361. VIGNETTE: boolean;
  88362. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88363. VIGNETTEBLENDMODEOPAQUE: boolean;
  88364. TONEMAPPING: boolean;
  88365. TONEMAPPING_ACES: boolean;
  88366. CONTRAST: boolean;
  88367. COLORCURVES: boolean;
  88368. COLORGRADING: boolean;
  88369. COLORGRADING3D: boolean;
  88370. SAMPLER3DGREENDEPTH: boolean;
  88371. SAMPLER3DBGRMAP: boolean;
  88372. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88373. EXPOSURE: boolean;
  88374. constructor();
  88375. }
  88376. /**
  88377. * This groups together the common properties used for image processing either in direct forward pass
  88378. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88379. * or not.
  88380. */
  88381. export class ImageProcessingConfiguration {
  88382. /**
  88383. * Default tone mapping applied in BabylonJS.
  88384. */
  88385. static readonly TONEMAPPING_STANDARD: number;
  88386. /**
  88387. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88388. * to other engines rendering to increase portability.
  88389. */
  88390. static readonly TONEMAPPING_ACES: number;
  88391. /**
  88392. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88393. */
  88394. colorCurves: Nullable<ColorCurves>;
  88395. private _colorCurvesEnabled;
  88396. /**
  88397. * Gets wether the color curves effect is enabled.
  88398. */
  88399. /**
  88400. * Sets wether the color curves effect is enabled.
  88401. */
  88402. colorCurvesEnabled: boolean;
  88403. private _colorGradingTexture;
  88404. /**
  88405. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88406. */
  88407. /**
  88408. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88409. */
  88410. colorGradingTexture: Nullable<BaseTexture>;
  88411. private _colorGradingEnabled;
  88412. /**
  88413. * Gets wether the color grading effect is enabled.
  88414. */
  88415. /**
  88416. * Sets wether the color grading effect is enabled.
  88417. */
  88418. colorGradingEnabled: boolean;
  88419. private _colorGradingWithGreenDepth;
  88420. /**
  88421. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88422. */
  88423. /**
  88424. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88425. */
  88426. colorGradingWithGreenDepth: boolean;
  88427. private _colorGradingBGR;
  88428. /**
  88429. * Gets wether the color grading texture contains BGR values.
  88430. */
  88431. /**
  88432. * Sets wether the color grading texture contains BGR values.
  88433. */
  88434. colorGradingBGR: boolean;
  88435. /** @hidden */
  88436. _exposure: number;
  88437. /**
  88438. * Gets the Exposure used in the effect.
  88439. */
  88440. /**
  88441. * Sets the Exposure used in the effect.
  88442. */
  88443. exposure: number;
  88444. private _toneMappingEnabled;
  88445. /**
  88446. * Gets wether the tone mapping effect is enabled.
  88447. */
  88448. /**
  88449. * Sets wether the tone mapping effect is enabled.
  88450. */
  88451. toneMappingEnabled: boolean;
  88452. private _toneMappingType;
  88453. /**
  88454. * Gets the type of tone mapping effect.
  88455. */
  88456. /**
  88457. * Sets the type of tone mapping effect used in BabylonJS.
  88458. */
  88459. toneMappingType: number;
  88460. protected _contrast: number;
  88461. /**
  88462. * Gets the contrast used in the effect.
  88463. */
  88464. /**
  88465. * Sets the contrast used in the effect.
  88466. */
  88467. contrast: number;
  88468. /**
  88469. * Vignette stretch size.
  88470. */
  88471. vignetteStretch: number;
  88472. /**
  88473. * Vignette centre X Offset.
  88474. */
  88475. vignetteCentreX: number;
  88476. /**
  88477. * Vignette centre Y Offset.
  88478. */
  88479. vignetteCentreY: number;
  88480. /**
  88481. * Vignette weight or intensity of the vignette effect.
  88482. */
  88483. vignetteWeight: number;
  88484. /**
  88485. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88486. * if vignetteEnabled is set to true.
  88487. */
  88488. vignetteColor: Color4;
  88489. /**
  88490. * Camera field of view used by the Vignette effect.
  88491. */
  88492. vignetteCameraFov: number;
  88493. private _vignetteBlendMode;
  88494. /**
  88495. * Gets the vignette blend mode allowing different kind of effect.
  88496. */
  88497. /**
  88498. * Sets the vignette blend mode allowing different kind of effect.
  88499. */
  88500. vignetteBlendMode: number;
  88501. private _vignetteEnabled;
  88502. /**
  88503. * Gets wether the vignette effect is enabled.
  88504. */
  88505. /**
  88506. * Sets wether the vignette effect is enabled.
  88507. */
  88508. vignetteEnabled: boolean;
  88509. private _applyByPostProcess;
  88510. /**
  88511. * Gets wether the image processing is applied through a post process or not.
  88512. */
  88513. /**
  88514. * Sets wether the image processing is applied through a post process or not.
  88515. */
  88516. applyByPostProcess: boolean;
  88517. private _isEnabled;
  88518. /**
  88519. * Gets wether the image processing is enabled or not.
  88520. */
  88521. /**
  88522. * Sets wether the image processing is enabled or not.
  88523. */
  88524. isEnabled: boolean;
  88525. /**
  88526. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88527. */
  88528. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88529. /**
  88530. * Method called each time the image processing information changes requires to recompile the effect.
  88531. */
  88532. protected _updateParameters(): void;
  88533. /**
  88534. * Gets the current class name.
  88535. * @return "ImageProcessingConfiguration"
  88536. */
  88537. getClassName(): string;
  88538. /**
  88539. * Prepare the list of uniforms associated with the Image Processing effects.
  88540. * @param uniforms The list of uniforms used in the effect
  88541. * @param defines the list of defines currently in use
  88542. */
  88543. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88544. /**
  88545. * Prepare the list of samplers associated with the Image Processing effects.
  88546. * @param samplersList The list of uniforms used in the effect
  88547. * @param defines the list of defines currently in use
  88548. */
  88549. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88550. /**
  88551. * Prepare the list of defines associated to the shader.
  88552. * @param defines the list of defines to complete
  88553. * @param forPostProcess Define if we are currently in post process mode or not
  88554. */
  88555. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88556. /**
  88557. * Returns true if all the image processing information are ready.
  88558. * @returns True if ready, otherwise, false
  88559. */
  88560. isReady(): boolean;
  88561. /**
  88562. * Binds the image processing to the shader.
  88563. * @param effect The effect to bind to
  88564. * @param aspectRatio Define the current aspect ratio of the effect
  88565. */
  88566. bind(effect: Effect, aspectRatio?: number): void;
  88567. /**
  88568. * Clones the current image processing instance.
  88569. * @return The cloned image processing
  88570. */
  88571. clone(): ImageProcessingConfiguration;
  88572. /**
  88573. * Serializes the current image processing instance to a json representation.
  88574. * @return a JSON representation
  88575. */
  88576. serialize(): any;
  88577. /**
  88578. * Parses the image processing from a json representation.
  88579. * @param source the JSON source to parse
  88580. * @return The parsed image processing
  88581. */
  88582. static Parse(source: any): ImageProcessingConfiguration;
  88583. private static _VIGNETTEMODE_MULTIPLY;
  88584. private static _VIGNETTEMODE_OPAQUE;
  88585. /**
  88586. * Used to apply the vignette as a mix with the pixel color.
  88587. */
  88588. static readonly VIGNETTEMODE_MULTIPLY: number;
  88589. /**
  88590. * Used to apply the vignette as a replacement of the pixel color.
  88591. */
  88592. static readonly VIGNETTEMODE_OPAQUE: number;
  88593. }
  88594. }
  88595. declare module BABYLON {
  88596. /**
  88597. * This represents all the required information to add a fresnel effect on a material:
  88598. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  88599. */
  88600. export class FresnelParameters {
  88601. private _isEnabled;
  88602. /**
  88603. * Define if the fresnel effect is enable or not.
  88604. */
  88605. isEnabled: boolean;
  88606. /**
  88607. * Define the color used on edges (grazing angle)
  88608. */
  88609. leftColor: Color3;
  88610. /**
  88611. * Define the color used on center
  88612. */
  88613. rightColor: Color3;
  88614. /**
  88615. * Define bias applied to computed fresnel term
  88616. */
  88617. bias: number;
  88618. /**
  88619. * Defined the power exponent applied to fresnel term
  88620. */
  88621. power: number;
  88622. /**
  88623. * Clones the current fresnel and its valuues
  88624. * @returns a clone fresnel configuration
  88625. */
  88626. clone(): FresnelParameters;
  88627. /**
  88628. * Serializes the current fresnel parameters to a JSON representation.
  88629. * @return the JSON serialization
  88630. */
  88631. serialize(): any;
  88632. /**
  88633. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  88634. * @param parsedFresnelParameters Define the JSON representation
  88635. * @returns the parsed parameters
  88636. */
  88637. static Parse(parsedFresnelParameters: any): FresnelParameters;
  88638. }
  88639. }
  88640. declare module BABYLON {
  88641. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  88642. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88643. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88644. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88645. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88646. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88647. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88648. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88649. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88650. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88651. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88652. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88653. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88654. /**
  88655. * Decorator used to define property that can be serialized as reference to a camera
  88656. * @param sourceName defines the name of the property to decorate
  88657. */
  88658. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88659. /**
  88660. * Class used to help serialization objects
  88661. */
  88662. export class SerializationHelper {
  88663. /** hidden */
  88664. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  88665. /** hidden */
  88666. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  88667. /** hidden */
  88668. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  88669. /** hidden */
  88670. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  88671. /**
  88672. * Appends the serialized animations from the source animations
  88673. * @param source Source containing the animations
  88674. * @param destination Target to store the animations
  88675. */
  88676. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88677. /**
  88678. * Static function used to serialized a specific entity
  88679. * @param entity defines the entity to serialize
  88680. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  88681. * @returns a JSON compatible object representing the serialization of the entity
  88682. */
  88683. static Serialize<T>(entity: T, serializationObject?: any): any;
  88684. /**
  88685. * Creates a new entity from a serialization data object
  88686. * @param creationFunction defines a function used to instanciated the new entity
  88687. * @param source defines the source serialization data
  88688. * @param scene defines the hosting scene
  88689. * @param rootUrl defines the root url for resources
  88690. * @returns a new entity
  88691. */
  88692. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  88693. /**
  88694. * Clones an object
  88695. * @param creationFunction defines the function used to instanciate the new object
  88696. * @param source defines the source object
  88697. * @returns the cloned object
  88698. */
  88699. static Clone<T>(creationFunction: () => T, source: T): T;
  88700. /**
  88701. * Instanciates a new object based on a source one (some data will be shared between both object)
  88702. * @param creationFunction defines the function used to instanciate the new object
  88703. * @param source defines the source object
  88704. * @returns the new object
  88705. */
  88706. static Instanciate<T>(creationFunction: () => T, source: T): T;
  88707. }
  88708. }
  88709. declare module BABYLON {
  88710. /**
  88711. * This is the base class of all the camera used in the application.
  88712. * @see http://doc.babylonjs.com/features/cameras
  88713. */
  88714. export class Camera extends Node {
  88715. /** @hidden */
  88716. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88717. /**
  88718. * This is the default projection mode used by the cameras.
  88719. * It helps recreating a feeling of perspective and better appreciate depth.
  88720. * This is the best way to simulate real life cameras.
  88721. */
  88722. static readonly PERSPECTIVE_CAMERA: number;
  88723. /**
  88724. * This helps creating camera with an orthographic mode.
  88725. * 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.
  88726. */
  88727. static readonly ORTHOGRAPHIC_CAMERA: number;
  88728. /**
  88729. * This is the default FOV mode for perspective cameras.
  88730. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88731. */
  88732. static readonly FOVMODE_VERTICAL_FIXED: number;
  88733. /**
  88734. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88735. */
  88736. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88737. /**
  88738. * This specifies ther is no need for a camera rig.
  88739. * Basically only one eye is rendered corresponding to the camera.
  88740. */
  88741. static readonly RIG_MODE_NONE: number;
  88742. /**
  88743. * Simulates a camera Rig with one blue eye and one red eye.
  88744. * This can be use with 3d blue and red glasses.
  88745. */
  88746. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88747. /**
  88748. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88749. */
  88750. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88751. /**
  88752. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88753. */
  88754. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88755. /**
  88756. * Defines that both eyes of the camera will be rendered over under each other.
  88757. */
  88758. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88759. /**
  88760. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88761. */
  88762. static readonly RIG_MODE_VR: number;
  88763. /**
  88764. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88765. */
  88766. static readonly RIG_MODE_WEBVR: number;
  88767. /**
  88768. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88769. */
  88770. static readonly RIG_MODE_CUSTOM: number;
  88771. /**
  88772. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88773. */
  88774. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88775. /**
  88776. * Define the input manager associated with the camera.
  88777. */
  88778. inputs: CameraInputsManager<Camera>;
  88779. /** @hidden */
  88780. _position: Vector3;
  88781. /**
  88782. * Define the current local position of the camera in the scene
  88783. */
  88784. position: Vector3;
  88785. /**
  88786. * The vector the camera should consider as up.
  88787. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88788. */
  88789. upVector: Vector3;
  88790. /**
  88791. * Define the current limit on the left side for an orthographic camera
  88792. * In scene unit
  88793. */
  88794. orthoLeft: Nullable<number>;
  88795. /**
  88796. * Define the current limit on the right side for an orthographic camera
  88797. * In scene unit
  88798. */
  88799. orthoRight: Nullable<number>;
  88800. /**
  88801. * Define the current limit on the bottom side for an orthographic camera
  88802. * In scene unit
  88803. */
  88804. orthoBottom: Nullable<number>;
  88805. /**
  88806. * Define the current limit on the top side for an orthographic camera
  88807. * In scene unit
  88808. */
  88809. orthoTop: Nullable<number>;
  88810. /**
  88811. * Field Of View is set in Radians. (default is 0.8)
  88812. */
  88813. fov: number;
  88814. /**
  88815. * Define the minimum distance the camera can see from.
  88816. * This is important to note that the depth buffer are not infinite and the closer it starts
  88817. * the more your scene might encounter depth fighting issue.
  88818. */
  88819. minZ: number;
  88820. /**
  88821. * Define the maximum distance the camera can see to.
  88822. * This is important to note that the depth buffer are not infinite and the further it end
  88823. * the more your scene might encounter depth fighting issue.
  88824. */
  88825. maxZ: number;
  88826. /**
  88827. * Define the default inertia of the camera.
  88828. * This helps giving a smooth feeling to the camera movement.
  88829. */
  88830. inertia: number;
  88831. /**
  88832. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  88833. */
  88834. mode: number;
  88835. /**
  88836. * Define wether the camera is intermediate.
  88837. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88838. */
  88839. isIntermediate: boolean;
  88840. /**
  88841. * Define the viewport of the camera.
  88842. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88843. */
  88844. viewport: Viewport;
  88845. /**
  88846. * Restricts the camera to viewing objects with the same layerMask.
  88847. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88848. */
  88849. layerMask: number;
  88850. /**
  88851. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88852. */
  88853. fovMode: number;
  88854. /**
  88855. * Rig mode of the camera.
  88856. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88857. * This is normally controlled byt the camera themselves as internal use.
  88858. */
  88859. cameraRigMode: number;
  88860. /**
  88861. * Defines the distance between both "eyes" in case of a RIG
  88862. */
  88863. interaxialDistance: number;
  88864. /**
  88865. * Defines if stereoscopic rendering is done side by side or over under.
  88866. */
  88867. isStereoscopicSideBySide: boolean;
  88868. /**
  88869. * 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
  88870. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88871. * else in the scene.
  88872. */
  88873. customRenderTargets: RenderTargetTexture[];
  88874. /**
  88875. * When set, the camera will render to this render target instead of the default canvas
  88876. */
  88877. outputRenderTarget: Nullable<RenderTargetTexture>;
  88878. /**
  88879. * @hidden
  88880. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  88881. */
  88882. _useMultiviewToSingleView: boolean;
  88883. /**
  88884. * @hidden
  88885. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  88886. */
  88887. _multiviewTexture: Nullable<RenderTargetTexture>;
  88888. /**
  88889. * @hidden
  88890. * ensures the multiview texture of the camera exists and has the specified width/height
  88891. * @param width height to set on the multiview texture
  88892. * @param height width to set on the multiview texture
  88893. */
  88894. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  88895. /**
  88896. * Observable triggered when the camera view matrix has changed.
  88897. */
  88898. onViewMatrixChangedObservable: Observable<Camera>;
  88899. /**
  88900. * Observable triggered when the camera Projection matrix has changed.
  88901. */
  88902. onProjectionMatrixChangedObservable: Observable<Camera>;
  88903. /**
  88904. * Observable triggered when the inputs have been processed.
  88905. */
  88906. onAfterCheckInputsObservable: Observable<Camera>;
  88907. /**
  88908. * Observable triggered when reset has been called and applied to the camera.
  88909. */
  88910. onRestoreStateObservable: Observable<Camera>;
  88911. /** @hidden */
  88912. _cameraRigParams: any;
  88913. /** @hidden */
  88914. _rigCameras: Camera[];
  88915. /** @hidden */
  88916. _rigPostProcess: Nullable<PostProcess>;
  88917. protected _webvrViewMatrix: Matrix;
  88918. /** @hidden */
  88919. _skipRendering: boolean;
  88920. /** @hidden */
  88921. _projectionMatrix: Matrix;
  88922. /** @hidden */
  88923. _postProcesses: Nullable<PostProcess>[];
  88924. /** @hidden */
  88925. _activeMeshes: SmartArray<AbstractMesh>;
  88926. protected _globalPosition: Vector3;
  88927. /** hidden */
  88928. _computedViewMatrix: Matrix;
  88929. private _doNotComputeProjectionMatrix;
  88930. private _transformMatrix;
  88931. private _frustumPlanes;
  88932. private _refreshFrustumPlanes;
  88933. private _storedFov;
  88934. private _stateStored;
  88935. /**
  88936. * Instantiates a new camera object.
  88937. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88938. * @see http://doc.babylonjs.com/features/cameras
  88939. * @param name Defines the name of the camera in the scene
  88940. * @param position Defines the position of the camera
  88941. * @param scene Defines the scene the camera belongs too
  88942. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88943. */
  88944. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88945. /**
  88946. * Store current camera state (fov, position, etc..)
  88947. * @returns the camera
  88948. */
  88949. storeState(): Camera;
  88950. /**
  88951. * Restores the camera state values if it has been stored. You must call storeState() first
  88952. */
  88953. protected _restoreStateValues(): boolean;
  88954. /**
  88955. * Restored camera state. You must call storeState() first.
  88956. * @returns true if restored and false otherwise
  88957. */
  88958. restoreState(): boolean;
  88959. /**
  88960. * Gets the class name of the camera.
  88961. * @returns the class name
  88962. */
  88963. getClassName(): string;
  88964. /** @hidden */
  88965. readonly _isCamera: boolean;
  88966. /**
  88967. * Gets a string representation of the camera useful for debug purpose.
  88968. * @param fullDetails Defines that a more verboe level of logging is required
  88969. * @returns the string representation
  88970. */
  88971. toString(fullDetails?: boolean): string;
  88972. /**
  88973. * Gets the current world space position of the camera.
  88974. */
  88975. readonly globalPosition: Vector3;
  88976. /**
  88977. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88978. * @returns the active meshe list
  88979. */
  88980. getActiveMeshes(): SmartArray<AbstractMesh>;
  88981. /**
  88982. * Check wether a mesh is part of the current active mesh list of the camera
  88983. * @param mesh Defines the mesh to check
  88984. * @returns true if active, false otherwise
  88985. */
  88986. isActiveMesh(mesh: Mesh): boolean;
  88987. /**
  88988. * Is this camera ready to be used/rendered
  88989. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88990. * @return true if the camera is ready
  88991. */
  88992. isReady(completeCheck?: boolean): boolean;
  88993. /** @hidden */
  88994. _initCache(): void;
  88995. /** @hidden */
  88996. _updateCache(ignoreParentClass?: boolean): void;
  88997. /** @hidden */
  88998. _isSynchronized(): boolean;
  88999. /** @hidden */
  89000. _isSynchronizedViewMatrix(): boolean;
  89001. /** @hidden */
  89002. _isSynchronizedProjectionMatrix(): boolean;
  89003. /**
  89004. * Attach the input controls to a specific dom element to get the input from.
  89005. * @param element Defines the element the controls should be listened from
  89006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89007. */
  89008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89009. /**
  89010. * Detach the current controls from the specified dom element.
  89011. * @param element Defines the element to stop listening the inputs from
  89012. */
  89013. detachControl(element: HTMLElement): void;
  89014. /**
  89015. * Update the camera state according to the different inputs gathered during the frame.
  89016. */
  89017. update(): void;
  89018. /** @hidden */
  89019. _checkInputs(): void;
  89020. /** @hidden */
  89021. readonly rigCameras: Camera[];
  89022. /**
  89023. * Gets the post process used by the rig cameras
  89024. */
  89025. readonly rigPostProcess: Nullable<PostProcess>;
  89026. /**
  89027. * Internal, gets the first post proces.
  89028. * @returns the first post process to be run on this camera.
  89029. */
  89030. _getFirstPostProcess(): Nullable<PostProcess>;
  89031. private _cascadePostProcessesToRigCams;
  89032. /**
  89033. * Attach a post process to the camera.
  89034. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89035. * @param postProcess The post process to attach to the camera
  89036. * @param insertAt The position of the post process in case several of them are in use in the scene
  89037. * @returns the position the post process has been inserted at
  89038. */
  89039. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89040. /**
  89041. * Detach a post process to the camera.
  89042. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89043. * @param postProcess The post process to detach from the camera
  89044. */
  89045. detachPostProcess(postProcess: PostProcess): void;
  89046. /**
  89047. * Gets the current world matrix of the camera
  89048. */
  89049. getWorldMatrix(): Matrix;
  89050. /** @hidden */
  89051. _getViewMatrix(): Matrix;
  89052. /**
  89053. * Gets the current view matrix of the camera.
  89054. * @param force forces the camera to recompute the matrix without looking at the cached state
  89055. * @returns the view matrix
  89056. */
  89057. getViewMatrix(force?: boolean): Matrix;
  89058. /**
  89059. * Freeze the projection matrix.
  89060. * It will prevent the cache check of the camera projection compute and can speed up perf
  89061. * if no parameter of the camera are meant to change
  89062. * @param projection Defines manually a projection if necessary
  89063. */
  89064. freezeProjectionMatrix(projection?: Matrix): void;
  89065. /**
  89066. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89067. */
  89068. unfreezeProjectionMatrix(): void;
  89069. /**
  89070. * Gets the current projection matrix of the camera.
  89071. * @param force forces the camera to recompute the matrix without looking at the cached state
  89072. * @returns the projection matrix
  89073. */
  89074. getProjectionMatrix(force?: boolean): Matrix;
  89075. /**
  89076. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89077. * @returns a Matrix
  89078. */
  89079. getTransformationMatrix(): Matrix;
  89080. private _updateFrustumPlanes;
  89081. /**
  89082. * Checks if a cullable object (mesh...) is in the camera frustum
  89083. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89084. * @param target The object to check
  89085. * @returns true if the object is in frustum otherwise false
  89086. */
  89087. isInFrustum(target: ICullable): boolean;
  89088. /**
  89089. * Checks if a cullable object (mesh...) is in the camera frustum
  89090. * Unlike isInFrustum this cheks the full bounding box
  89091. * @param target The object to check
  89092. * @returns true if the object is in frustum otherwise false
  89093. */
  89094. isCompletelyInFrustum(target: ICullable): boolean;
  89095. /**
  89096. * Gets a ray in the forward direction from the camera.
  89097. * @param length Defines the length of the ray to create
  89098. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89099. * @param origin Defines the start point of the ray which defaults to the camera position
  89100. * @returns the forward ray
  89101. */
  89102. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89103. /**
  89104. * Releases resources associated with this node.
  89105. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89106. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89107. */
  89108. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89109. /** @hidden */
  89110. _isLeftCamera: boolean;
  89111. /**
  89112. * Gets the left camera of a rig setup in case of Rigged Camera
  89113. */
  89114. readonly isLeftCamera: boolean;
  89115. /** @hidden */
  89116. _isRightCamera: boolean;
  89117. /**
  89118. * Gets the right camera of a rig setup in case of Rigged Camera
  89119. */
  89120. readonly isRightCamera: boolean;
  89121. /**
  89122. * Gets the left camera of a rig setup in case of Rigged Camera
  89123. */
  89124. readonly leftCamera: Nullable<FreeCamera>;
  89125. /**
  89126. * Gets the right camera of a rig setup in case of Rigged Camera
  89127. */
  89128. readonly rightCamera: Nullable<FreeCamera>;
  89129. /**
  89130. * Gets the left camera target of a rig setup in case of Rigged Camera
  89131. * @returns the target position
  89132. */
  89133. getLeftTarget(): Nullable<Vector3>;
  89134. /**
  89135. * Gets the right camera target of a rig setup in case of Rigged Camera
  89136. * @returns the target position
  89137. */
  89138. getRightTarget(): Nullable<Vector3>;
  89139. /**
  89140. * @hidden
  89141. */
  89142. setCameraRigMode(mode: number, rigParams: any): void;
  89143. /** @hidden */
  89144. static _setStereoscopicRigMode(camera: Camera): void;
  89145. /** @hidden */
  89146. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89147. /** @hidden */
  89148. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89149. /** @hidden */
  89150. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89151. /** @hidden */
  89152. _getVRProjectionMatrix(): Matrix;
  89153. protected _updateCameraRotationMatrix(): void;
  89154. protected _updateWebVRCameraRotationMatrix(): void;
  89155. /**
  89156. * This function MUST be overwritten by the different WebVR cameras available.
  89157. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89158. * @hidden
  89159. */
  89160. _getWebVRProjectionMatrix(): Matrix;
  89161. /**
  89162. * This function MUST be overwritten by the different WebVR cameras available.
  89163. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89164. * @hidden
  89165. */
  89166. _getWebVRViewMatrix(): Matrix;
  89167. /** @hidden */
  89168. setCameraRigParameter(name: string, value: any): void;
  89169. /**
  89170. * needs to be overridden by children so sub has required properties to be copied
  89171. * @hidden
  89172. */
  89173. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89174. /**
  89175. * May need to be overridden by children
  89176. * @hidden
  89177. */
  89178. _updateRigCameras(): void;
  89179. /** @hidden */
  89180. _setupInputs(): void;
  89181. /**
  89182. * Serialiaze the camera setup to a json represention
  89183. * @returns the JSON representation
  89184. */
  89185. serialize(): any;
  89186. /**
  89187. * Clones the current camera.
  89188. * @param name The cloned camera name
  89189. * @returns the cloned camera
  89190. */
  89191. clone(name: string): Camera;
  89192. /**
  89193. * Gets the direction of the camera relative to a given local axis.
  89194. * @param localAxis Defines the reference axis to provide a relative direction.
  89195. * @return the direction
  89196. */
  89197. getDirection(localAxis: Vector3): Vector3;
  89198. /**
  89199. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89200. * @param localAxis Defines the reference axis to provide a relative direction.
  89201. * @param result Defines the vector to store the result in
  89202. */
  89203. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89204. /**
  89205. * Gets a camera constructor for a given camera type
  89206. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89207. * @param name The name of the camera the result will be able to instantiate
  89208. * @param scene The scene the result will construct the camera in
  89209. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89210. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89211. * @returns a factory method to construc the camera
  89212. */
  89213. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89214. /**
  89215. * Compute the world matrix of the camera.
  89216. * @returns the camera workd matrix
  89217. */
  89218. computeWorldMatrix(): Matrix;
  89219. /**
  89220. * Parse a JSON and creates the camera from the parsed information
  89221. * @param parsedCamera The JSON to parse
  89222. * @param scene The scene to instantiate the camera in
  89223. * @returns the newly constructed camera
  89224. */
  89225. static Parse(parsedCamera: any, scene: Scene): Camera;
  89226. }
  89227. }
  89228. declare module BABYLON {
  89229. /**
  89230. * Interface for any object that can request an animation frame
  89231. */
  89232. export interface ICustomAnimationFrameRequester {
  89233. /**
  89234. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89235. */
  89236. renderFunction?: Function;
  89237. /**
  89238. * Called to request the next frame to render to
  89239. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89240. */
  89241. requestAnimationFrame: Function;
  89242. /**
  89243. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89244. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89245. */
  89246. requestID?: number;
  89247. }
  89248. /**
  89249. * Interface containing an array of animations
  89250. */
  89251. export interface IAnimatable {
  89252. /**
  89253. * Array of animations
  89254. */
  89255. animations: Array<Animation>;
  89256. }
  89257. /** Interface used by value gradients (color, factor, ...) */
  89258. export interface IValueGradient {
  89259. /**
  89260. * Gets or sets the gradient value (between 0 and 1)
  89261. */
  89262. gradient: number;
  89263. }
  89264. /** Class used to store color4 gradient */
  89265. export class ColorGradient implements IValueGradient {
  89266. /**
  89267. * Gets or sets the gradient value (between 0 and 1)
  89268. */
  89269. gradient: number;
  89270. /**
  89271. * Gets or sets first associated color
  89272. */
  89273. color1: Color4;
  89274. /**
  89275. * Gets or sets second associated color
  89276. */
  89277. color2?: Color4;
  89278. /**
  89279. * Will get a color picked randomly between color1 and color2.
  89280. * If color2 is undefined then color1 will be used
  89281. * @param result defines the target Color4 to store the result in
  89282. */
  89283. getColorToRef(result: Color4): void;
  89284. }
  89285. /** Class used to store color 3 gradient */
  89286. export class Color3Gradient implements IValueGradient {
  89287. /**
  89288. * Gets or sets the gradient value (between 0 and 1)
  89289. */
  89290. gradient: number;
  89291. /**
  89292. * Gets or sets the associated color
  89293. */
  89294. color: Color3;
  89295. }
  89296. /** Class used to store factor gradient */
  89297. export class FactorGradient implements IValueGradient {
  89298. /**
  89299. * Gets or sets the gradient value (between 0 and 1)
  89300. */
  89301. gradient: number;
  89302. /**
  89303. * Gets or sets first associated factor
  89304. */
  89305. factor1: number;
  89306. /**
  89307. * Gets or sets second associated factor
  89308. */
  89309. factor2?: number;
  89310. /**
  89311. * Will get a number picked randomly between factor1 and factor2.
  89312. * If factor2 is undefined then factor1 will be used
  89313. * @returns the picked number
  89314. */
  89315. getFactor(): number;
  89316. }
  89317. /**
  89318. * @ignore
  89319. * Application error to support additional information when loading a file
  89320. */
  89321. export class LoadFileError extends Error {
  89322. /** defines the optional web request */
  89323. request?: WebRequest | undefined;
  89324. private static _setPrototypeOf;
  89325. /**
  89326. * Creates a new LoadFileError
  89327. * @param message defines the message of the error
  89328. * @param request defines the optional web request
  89329. */
  89330. constructor(message: string,
  89331. /** defines the optional web request */
  89332. request?: WebRequest | undefined);
  89333. }
  89334. /**
  89335. * Class used to define a retry strategy when error happens while loading assets
  89336. */
  89337. export class RetryStrategy {
  89338. /**
  89339. * Function used to defines an exponential back off strategy
  89340. * @param maxRetries defines the maximum number of retries (3 by default)
  89341. * @param baseInterval defines the interval between retries
  89342. * @returns the strategy function to use
  89343. */
  89344. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  89345. }
  89346. /**
  89347. * File request interface
  89348. */
  89349. export interface IFileRequest {
  89350. /**
  89351. * Raised when the request is complete (success or error).
  89352. */
  89353. onCompleteObservable: Observable<IFileRequest>;
  89354. /**
  89355. * Aborts the request for a file.
  89356. */
  89357. abort: () => void;
  89358. }
  89359. /**
  89360. * Class containing a set of static utilities functions
  89361. */
  89362. export class Tools {
  89363. /**
  89364. * Gets or sets the base URL to use to load assets
  89365. */
  89366. static BaseUrl: string;
  89367. /**
  89368. * Enable/Disable Custom HTTP Request Headers globally.
  89369. * default = false
  89370. * @see CustomRequestHeaders
  89371. */
  89372. static UseCustomRequestHeaders: boolean;
  89373. /**
  89374. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  89375. * i.e. when loading files, where the server/service expects an Authorization header
  89376. */
  89377. static CustomRequestHeaders: {
  89378. [key: string]: string;
  89379. };
  89380. /**
  89381. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  89382. */
  89383. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  89384. /**
  89385. * Default behaviour for cors in the application.
  89386. * It can be a string if the expected behavior is identical in the entire app.
  89387. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  89388. */
  89389. static CorsBehavior: string | ((url: string | string[]) => string);
  89390. /**
  89391. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  89392. * @ignorenaming
  89393. */
  89394. static UseFallbackTexture: boolean;
  89395. /**
  89396. * Use this object to register external classes like custom textures or material
  89397. * to allow the laoders to instantiate them
  89398. */
  89399. static RegisteredExternalClasses: {
  89400. [key: string]: Object;
  89401. };
  89402. /**
  89403. * Texture content used if a texture cannot loaded
  89404. * @ignorenaming
  89405. */
  89406. static fallbackTexture: string;
  89407. /**
  89408. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  89409. * @param u defines the coordinate on X axis
  89410. * @param v defines the coordinate on Y axis
  89411. * @param width defines the width of the source data
  89412. * @param height defines the height of the source data
  89413. * @param pixels defines the source byte array
  89414. * @param color defines the output color
  89415. */
  89416. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  89417. /**
  89418. * Interpolates between a and b via alpha
  89419. * @param a The lower value (returned when alpha = 0)
  89420. * @param b The upper value (returned when alpha = 1)
  89421. * @param alpha The interpolation-factor
  89422. * @return The mixed value
  89423. */
  89424. static Mix(a: number, b: number, alpha: number): number;
  89425. /**
  89426. * Tries to instantiate a new object from a given class name
  89427. * @param className defines the class name to instantiate
  89428. * @returns the new object or null if the system was not able to do the instantiation
  89429. */
  89430. static Instantiate(className: string): any;
  89431. /**
  89432. * Provides a slice function that will work even on IE
  89433. * @param data defines the array to slice
  89434. * @param start defines the start of the data (optional)
  89435. * @param end defines the end of the data (optional)
  89436. * @returns the new sliced array
  89437. */
  89438. static Slice<T>(data: T, start?: number, end?: number): T;
  89439. /**
  89440. * Polyfill for setImmediate
  89441. * @param action defines the action to execute after the current execution block
  89442. */
  89443. static SetImmediate(action: () => void): void;
  89444. /**
  89445. * Function indicating if a number is an exponent of 2
  89446. * @param value defines the value to test
  89447. * @returns true if the value is an exponent of 2
  89448. */
  89449. static IsExponentOfTwo(value: number): boolean;
  89450. private static _tmpFloatArray;
  89451. /**
  89452. * Returns the nearest 32-bit single precision float representation of a Number
  89453. * @param value A Number. If the parameter is of a different type, it will get converted
  89454. * to a number or to NaN if it cannot be converted
  89455. * @returns number
  89456. */
  89457. static FloatRound(value: number): number;
  89458. /**
  89459. * Find the next highest power of two.
  89460. * @param x Number to start search from.
  89461. * @return Next highest power of two.
  89462. */
  89463. static CeilingPOT(x: number): number;
  89464. /**
  89465. * Find the next lowest power of two.
  89466. * @param x Number to start search from.
  89467. * @return Next lowest power of two.
  89468. */
  89469. static FloorPOT(x: number): number;
  89470. /**
  89471. * Find the nearest power of two.
  89472. * @param x Number to start search from.
  89473. * @return Next nearest power of two.
  89474. */
  89475. static NearestPOT(x: number): number;
  89476. /**
  89477. * Get the closest exponent of two
  89478. * @param value defines the value to approximate
  89479. * @param max defines the maximum value to return
  89480. * @param mode defines how to define the closest value
  89481. * @returns closest exponent of two of the given value
  89482. */
  89483. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  89484. /**
  89485. * Extracts the filename from a path
  89486. * @param path defines the path to use
  89487. * @returns the filename
  89488. */
  89489. static GetFilename(path: string): string;
  89490. /**
  89491. * Extracts the "folder" part of a path (everything before the filename).
  89492. * @param uri The URI to extract the info from
  89493. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  89494. * @returns The "folder" part of the path
  89495. */
  89496. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  89497. /**
  89498. * Extracts text content from a DOM element hierarchy
  89499. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  89500. */
  89501. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  89502. /**
  89503. * Convert an angle in radians to degrees
  89504. * @param angle defines the angle to convert
  89505. * @returns the angle in degrees
  89506. */
  89507. static ToDegrees(angle: number): number;
  89508. /**
  89509. * Convert an angle in degrees to radians
  89510. * @param angle defines the angle to convert
  89511. * @returns the angle in radians
  89512. */
  89513. static ToRadians(angle: number): number;
  89514. /**
  89515. * Encode a buffer to a base64 string
  89516. * @param buffer defines the buffer to encode
  89517. * @returns the encoded string
  89518. */
  89519. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  89520. /**
  89521. * Extracts minimum and maximum values from a list of indexed positions
  89522. * @param positions defines the positions to use
  89523. * @param indices defines the indices to the positions
  89524. * @param indexStart defines the start index
  89525. * @param indexCount defines the end index
  89526. * @param bias defines bias value to add to the result
  89527. * @return minimum and maximum values
  89528. */
  89529. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89530. minimum: Vector3;
  89531. maximum: Vector3;
  89532. };
  89533. /**
  89534. * Extracts minimum and maximum values from a list of positions
  89535. * @param positions defines the positions to use
  89536. * @param start defines the start index in the positions array
  89537. * @param count defines the number of positions to handle
  89538. * @param bias defines bias value to add to the result
  89539. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89540. * @return minimum and maximum values
  89541. */
  89542. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89543. minimum: Vector3;
  89544. maximum: Vector3;
  89545. };
  89546. /**
  89547. * Returns an array if obj is not an array
  89548. * @param obj defines the object to evaluate as an array
  89549. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  89550. * @returns either obj directly if obj is an array or a new array containing obj
  89551. */
  89552. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  89553. /**
  89554. * Gets the pointer prefix to use
  89555. * @returns "pointer" if touch is enabled. Else returns "mouse"
  89556. */
  89557. static GetPointerPrefix(): string;
  89558. /**
  89559. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  89560. * @param func - the function to be called
  89561. * @param requester - the object that will request the next frame. Falls back to window.
  89562. * @returns frame number
  89563. */
  89564. static QueueNewFrame(func: () => void, requester?: any): number;
  89565. /**
  89566. * Ask the browser to promote the current element to fullscreen rendering mode
  89567. * @param element defines the DOM element to promote
  89568. */
  89569. static RequestFullscreen(element: HTMLElement): void;
  89570. /**
  89571. * Asks the browser to exit fullscreen mode
  89572. */
  89573. static ExitFullscreen(): void;
  89574. /**
  89575. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  89576. * @param url define the url we are trying
  89577. * @param element define the dom element where to configure the cors policy
  89578. */
  89579. static SetCorsBehavior(url: string | string[], element: {
  89580. crossOrigin: string | null;
  89581. }): void;
  89582. /**
  89583. * Removes unwanted characters from an url
  89584. * @param url defines the url to clean
  89585. * @returns the cleaned url
  89586. */
  89587. static CleanUrl(url: string): string;
  89588. /**
  89589. * Gets or sets a function used to pre-process url before using them to load assets
  89590. */
  89591. static PreprocessUrl: (url: string) => string;
  89592. /**
  89593. * Loads an image as an HTMLImageElement.
  89594. * @param input url string, ArrayBuffer, or Blob to load
  89595. * @param onLoad callback called when the image successfully loads
  89596. * @param onError callback called when the image fails to load
  89597. * @param offlineProvider offline provider for caching
  89598. * @returns the HTMLImageElement of the loaded image
  89599. */
  89600. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  89601. /**
  89602. * Loads a file
  89603. * @param url url string, ArrayBuffer, or Blob to load
  89604. * @param onSuccess callback called when the file successfully loads
  89605. * @param onProgress callback called while file is loading (if the server supports this mode)
  89606. * @param offlineProvider defines the offline provider for caching
  89607. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  89608. * @param onError callback called when the file fails to load
  89609. * @returns a file request object
  89610. */
  89611. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  89612. /**
  89613. * Load a script (identified by an url). When the url returns, the
  89614. * content of this file is added into a new script element, attached to the DOM (body element)
  89615. * @param scriptUrl defines the url of the script to laod
  89616. * @param onSuccess defines the callback called when the script is loaded
  89617. * @param onError defines the callback to call if an error occurs
  89618. */
  89619. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  89620. /**
  89621. * Loads a file from a blob
  89622. * @param fileToLoad defines the blob to use
  89623. * @param callback defines the callback to call when data is loaded
  89624. * @param progressCallback defines the callback to call during loading process
  89625. * @returns a file request object
  89626. */
  89627. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  89628. /**
  89629. * Loads a file
  89630. * @param fileToLoad defines the file to load
  89631. * @param callback defines the callback to call when data is loaded
  89632. * @param progressCallBack defines the callback to call during loading process
  89633. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  89634. * @returns a file request object
  89635. */
  89636. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  89637. /**
  89638. * Creates a data url from a given string content
  89639. * @param content defines the content to convert
  89640. * @returns the new data url link
  89641. */
  89642. static FileAsURL(content: string): string;
  89643. /**
  89644. * Format the given number to a specific decimal format
  89645. * @param value defines the number to format
  89646. * @param decimals defines the number of decimals to use
  89647. * @returns the formatted string
  89648. */
  89649. static Format(value: number, decimals?: number): string;
  89650. /**
  89651. * Checks if a given vector is inside a specific range
  89652. * @param v defines the vector to test
  89653. * @param min defines the minimum range
  89654. * @param max defines the maximum range
  89655. */
  89656. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  89657. /**
  89658. * Tries to copy an object by duplicating every property
  89659. * @param source defines the source object
  89660. * @param destination defines the target object
  89661. * @param doNotCopyList defines a list of properties to avoid
  89662. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  89663. */
  89664. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  89665. /**
  89666. * Gets a boolean indicating if the given object has no own property
  89667. * @param obj defines the object to test
  89668. * @returns true if object has no own property
  89669. */
  89670. static IsEmpty(obj: any): boolean;
  89671. /**
  89672. * Function used to register events at window level
  89673. * @param events defines the events to register
  89674. */
  89675. static RegisterTopRootEvents(events: {
  89676. name: string;
  89677. handler: Nullable<(e: FocusEvent) => any>;
  89678. }[]): void;
  89679. /**
  89680. * Function used to unregister events from window level
  89681. * @param events defines the events to unregister
  89682. */
  89683. static UnregisterTopRootEvents(events: {
  89684. name: string;
  89685. handler: Nullable<(e: FocusEvent) => any>;
  89686. }[]): void;
  89687. /**
  89688. * @ignore
  89689. */
  89690. static _ScreenshotCanvas: HTMLCanvasElement;
  89691. /**
  89692. * Dumps the current bound framebuffer
  89693. * @param width defines the rendering width
  89694. * @param height defines the rendering height
  89695. * @param engine defines the hosting engine
  89696. * @param successCallback defines the callback triggered once the data are available
  89697. * @param mimeType defines the mime type of the result
  89698. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  89699. */
  89700. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89701. /**
  89702. * Converts the canvas data to blob.
  89703. * This acts as a polyfill for browsers not supporting the to blob function.
  89704. * @param canvas Defines the canvas to extract the data from
  89705. * @param successCallback Defines the callback triggered once the data are available
  89706. * @param mimeType Defines the mime type of the result
  89707. */
  89708. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  89709. /**
  89710. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  89711. * @param successCallback defines the callback triggered once the data are available
  89712. * @param mimeType defines the mime type of the result
  89713. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  89714. */
  89715. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89716. /**
  89717. * Downloads a blob in the browser
  89718. * @param blob defines the blob to download
  89719. * @param fileName defines the name of the downloaded file
  89720. */
  89721. static Download(blob: Blob, fileName: string): void;
  89722. /**
  89723. * Captures a screenshot of the current rendering
  89724. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89725. * @param engine defines the rendering engine
  89726. * @param camera defines the source camera
  89727. * @param size This parameter can be set to a single number or to an object with the
  89728. * following (optional) properties: precision, width, height. If a single number is passed,
  89729. * it will be used for both width and height. If an object is passed, the screenshot size
  89730. * will be derived from the parameters. The precision property is a multiplier allowing
  89731. * rendering at a higher or lower resolution
  89732. * @param successCallback defines the callback receives a single parameter which contains the
  89733. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89734. * src parameter of an <img> to display it
  89735. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  89736. * Check your browser for supported MIME types
  89737. */
  89738. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  89739. /**
  89740. * Generates an image screenshot from the specified camera.
  89741. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89742. * @param engine The engine to use for rendering
  89743. * @param camera The camera to use for rendering
  89744. * @param size This parameter can be set to a single number or to an object with the
  89745. * following (optional) properties: precision, width, height. If a single number is passed,
  89746. * it will be used for both width and height. If an object is passed, the screenshot size
  89747. * will be derived from the parameters. The precision property is a multiplier allowing
  89748. * rendering at a higher or lower resolution
  89749. * @param successCallback The callback receives a single parameter which contains the
  89750. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89751. * src parameter of an <img> to display it
  89752. * @param mimeType The MIME type of the screenshot image (default: image/png).
  89753. * Check your browser for supported MIME types
  89754. * @param samples Texture samples (default: 1)
  89755. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  89756. * @param fileName A name for for the downloaded file.
  89757. */
  89758. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  89759. /**
  89760. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89761. * Be aware Math.random() could cause collisions, but:
  89762. * "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"
  89763. * @returns a pseudo random id
  89764. */
  89765. static RandomId(): string;
  89766. /**
  89767. * Test if the given uri is a base64 string
  89768. * @param uri The uri to test
  89769. * @return True if the uri is a base64 string or false otherwise
  89770. */
  89771. static IsBase64(uri: string): boolean;
  89772. /**
  89773. * Decode the given base64 uri.
  89774. * @param uri The uri to decode
  89775. * @return The decoded base64 data.
  89776. */
  89777. static DecodeBase64(uri: string): ArrayBuffer;
  89778. /**
  89779. * No log
  89780. */
  89781. static readonly NoneLogLevel: number;
  89782. /**
  89783. * Only message logs
  89784. */
  89785. static readonly MessageLogLevel: number;
  89786. /**
  89787. * Only warning logs
  89788. */
  89789. static readonly WarningLogLevel: number;
  89790. /**
  89791. * Only error logs
  89792. */
  89793. static readonly ErrorLogLevel: number;
  89794. /**
  89795. * All logs
  89796. */
  89797. static readonly AllLogLevel: number;
  89798. /**
  89799. * Gets a value indicating the number of loading errors
  89800. * @ignorenaming
  89801. */
  89802. static readonly errorsCount: number;
  89803. /**
  89804. * Callback called when a new log is added
  89805. */
  89806. static OnNewCacheEntry: (entry: string) => void;
  89807. /**
  89808. * Log a message to the console
  89809. * @param message defines the message to log
  89810. */
  89811. static Log(message: string): void;
  89812. /**
  89813. * Write a warning message to the console
  89814. * @param message defines the message to log
  89815. */
  89816. static Warn(message: string): void;
  89817. /**
  89818. * Write an error message to the console
  89819. * @param message defines the message to log
  89820. */
  89821. static Error(message: string): void;
  89822. /**
  89823. * Gets current log cache (list of logs)
  89824. */
  89825. static readonly LogCache: string;
  89826. /**
  89827. * Clears the log cache
  89828. */
  89829. static ClearLogCache(): void;
  89830. /**
  89831. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  89832. */
  89833. static LogLevels: number;
  89834. /**
  89835. * Checks if the loaded document was accessed via `file:`-Protocol.
  89836. * @returns boolean
  89837. */
  89838. static IsFileURL(): boolean;
  89839. /**
  89840. * Checks if the window object exists
  89841. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  89842. */
  89843. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  89844. /**
  89845. * No performance log
  89846. */
  89847. static readonly PerformanceNoneLogLevel: number;
  89848. /**
  89849. * Use user marks to log performance
  89850. */
  89851. static readonly PerformanceUserMarkLogLevel: number;
  89852. /**
  89853. * Log performance to the console
  89854. */
  89855. static readonly PerformanceConsoleLogLevel: number;
  89856. private static _performance;
  89857. /**
  89858. * Sets the current performance log level
  89859. */
  89860. static PerformanceLogLevel: number;
  89861. private static _StartPerformanceCounterDisabled;
  89862. private static _EndPerformanceCounterDisabled;
  89863. private static _StartUserMark;
  89864. private static _EndUserMark;
  89865. private static _StartPerformanceConsole;
  89866. private static _EndPerformanceConsole;
  89867. /**
  89868. * Starts a performance counter
  89869. */
  89870. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89871. /**
  89872. * Ends a specific performance coutner
  89873. */
  89874. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89875. /**
  89876. * Gets either window.performance.now() if supported or Date.now() else
  89877. */
  89878. static readonly Now: number;
  89879. /**
  89880. * This method will return the name of the class used to create the instance of the given object.
  89881. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  89882. * @param object the object to get the class name from
  89883. * @param isType defines if the object is actually a type
  89884. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  89885. */
  89886. static GetClassName(object: any, isType?: boolean): string;
  89887. /**
  89888. * Gets the first element of an array satisfying a given predicate
  89889. * @param array defines the array to browse
  89890. * @param predicate defines the predicate to use
  89891. * @returns null if not found or the element
  89892. */
  89893. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  89894. /**
  89895. * This method will return the name of the full name of the class, including its owning module (if any).
  89896. * 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).
  89897. * @param object the object to get the class name from
  89898. * @param isType defines if the object is actually a type
  89899. * @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.
  89900. * @ignorenaming
  89901. */
  89902. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  89903. /**
  89904. * Returns a promise that resolves after the given amount of time.
  89905. * @param delay Number of milliseconds to delay
  89906. * @returns Promise that resolves after the given amount of time
  89907. */
  89908. static DelayAsync(delay: number): Promise<void>;
  89909. /**
  89910. * Gets the current gradient from an array of IValueGradient
  89911. * @param ratio defines the current ratio to get
  89912. * @param gradients defines the array of IValueGradient
  89913. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89914. */
  89915. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89916. }
  89917. /**
  89918. * This class is used to track a performance counter which is number based.
  89919. * The user has access to many properties which give statistics of different nature.
  89920. *
  89921. * The implementer can track two kinds of Performance Counter: time and count.
  89922. * 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.
  89923. * 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.
  89924. */
  89925. export class PerfCounter {
  89926. /**
  89927. * Gets or sets a global boolean to turn on and off all the counters
  89928. */
  89929. static Enabled: boolean;
  89930. /**
  89931. * Returns the smallest value ever
  89932. */
  89933. readonly min: number;
  89934. /**
  89935. * Returns the biggest value ever
  89936. */
  89937. readonly max: number;
  89938. /**
  89939. * Returns the average value since the performance counter is running
  89940. */
  89941. readonly average: number;
  89942. /**
  89943. * Returns the average value of the last second the counter was monitored
  89944. */
  89945. readonly lastSecAverage: number;
  89946. /**
  89947. * Returns the current value
  89948. */
  89949. readonly current: number;
  89950. /**
  89951. * Gets the accumulated total
  89952. */
  89953. readonly total: number;
  89954. /**
  89955. * Gets the total value count
  89956. */
  89957. readonly count: number;
  89958. /**
  89959. * Creates a new counter
  89960. */
  89961. constructor();
  89962. /**
  89963. * Call this method to start monitoring a new frame.
  89964. * 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.
  89965. */
  89966. fetchNewFrame(): void;
  89967. /**
  89968. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  89969. * @param newCount the count value to add to the monitored count
  89970. * @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.
  89971. */
  89972. addCount(newCount: number, fetchResult: boolean): void;
  89973. /**
  89974. * Start monitoring this performance counter
  89975. */
  89976. beginMonitoring(): void;
  89977. /**
  89978. * Compute the time lapsed since the previous beginMonitoring() call.
  89979. * @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
  89980. */
  89981. endMonitoring(newFrame?: boolean): void;
  89982. private _fetchResult;
  89983. private _startMonitoringTime;
  89984. private _min;
  89985. private _max;
  89986. private _average;
  89987. private _current;
  89988. private _totalValueCount;
  89989. private _totalAccumulated;
  89990. private _lastSecAverage;
  89991. private _lastSecAccumulated;
  89992. private _lastSecTime;
  89993. private _lastSecValueCount;
  89994. }
  89995. /**
  89996. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  89997. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  89998. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  89999. * @param name The name of the class, case should be preserved
  90000. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90001. */
  90002. export function className(name: string, module?: string): (target: Object) => void;
  90003. /**
  90004. * An implementation of a loop for asynchronous functions.
  90005. */
  90006. export class AsyncLoop {
  90007. /**
  90008. * Defines the number of iterations for the loop
  90009. */
  90010. iterations: number;
  90011. /**
  90012. * Defines the current index of the loop.
  90013. */
  90014. index: number;
  90015. private _done;
  90016. private _fn;
  90017. private _successCallback;
  90018. /**
  90019. * Constructor.
  90020. * @param iterations the number of iterations.
  90021. * @param func the function to run each iteration
  90022. * @param successCallback the callback that will be called upon succesful execution
  90023. * @param offset starting offset.
  90024. */
  90025. constructor(
  90026. /**
  90027. * Defines the number of iterations for the loop
  90028. */
  90029. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90030. /**
  90031. * Execute the next iteration. Must be called after the last iteration was finished.
  90032. */
  90033. executeNext(): void;
  90034. /**
  90035. * Break the loop and run the success callback.
  90036. */
  90037. breakLoop(): void;
  90038. /**
  90039. * Create and run an async loop.
  90040. * @param iterations the number of iterations.
  90041. * @param fn the function to run each iteration
  90042. * @param successCallback the callback that will be called upon succesful execution
  90043. * @param offset starting offset.
  90044. * @returns the created async loop object
  90045. */
  90046. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90047. /**
  90048. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90049. * @param iterations total number of iterations
  90050. * @param syncedIterations number of synchronous iterations in each async iteration.
  90051. * @param fn the function to call each iteration.
  90052. * @param callback a success call back that will be called when iterating stops.
  90053. * @param breakFunction a break condition (optional)
  90054. * @param timeout timeout settings for the setTimeout function. default - 0.
  90055. * @returns the created async loop object
  90056. */
  90057. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90058. }
  90059. }
  90060. declare module BABYLON {
  90061. /** @hidden */
  90062. export interface ICollisionCoordinator {
  90063. createCollider(): Collider;
  90064. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90065. init(scene: Scene): void;
  90066. }
  90067. /** @hidden */
  90068. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90069. private _scene;
  90070. private _scaledPosition;
  90071. private _scaledVelocity;
  90072. private _finalPosition;
  90073. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90074. createCollider(): Collider;
  90075. init(scene: Scene): void;
  90076. private _collideWithWorld;
  90077. }
  90078. }
  90079. declare module BABYLON {
  90080. /**
  90081. * This class defines the direct association between an animation and a target
  90082. */
  90083. export class TargetedAnimation {
  90084. /**
  90085. * Animation to perform
  90086. */
  90087. animation: Animation;
  90088. /**
  90089. * Target to animate
  90090. */
  90091. target: any;
  90092. }
  90093. /**
  90094. * Use this class to create coordinated animations on multiple targets
  90095. */
  90096. export class AnimationGroup implements IDisposable {
  90097. /** The name of the animation group */
  90098. name: string;
  90099. private _scene;
  90100. private _targetedAnimations;
  90101. private _animatables;
  90102. private _from;
  90103. private _to;
  90104. private _isStarted;
  90105. private _isPaused;
  90106. private _speedRatio;
  90107. /**
  90108. * Gets or sets the unique id of the node
  90109. */
  90110. uniqueId: number;
  90111. /**
  90112. * This observable will notify when one animation have ended
  90113. */
  90114. onAnimationEndObservable: Observable<TargetedAnimation>;
  90115. /**
  90116. * Observer raised when one animation loops
  90117. */
  90118. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90119. /**
  90120. * This observable will notify when all animations have ended.
  90121. */
  90122. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90123. /**
  90124. * This observable will notify when all animations have paused.
  90125. */
  90126. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90127. /**
  90128. * This observable will notify when all animations are playing.
  90129. */
  90130. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90131. /**
  90132. * Gets the first frame
  90133. */
  90134. readonly from: number;
  90135. /**
  90136. * Gets the last frame
  90137. */
  90138. readonly to: number;
  90139. /**
  90140. * Define if the animations are started
  90141. */
  90142. readonly isStarted: boolean;
  90143. /**
  90144. * Gets a value indicating that the current group is playing
  90145. */
  90146. readonly isPlaying: boolean;
  90147. /**
  90148. * Gets or sets the speed ratio to use for all animations
  90149. */
  90150. /**
  90151. * Gets or sets the speed ratio to use for all animations
  90152. */
  90153. speedRatio: number;
  90154. /**
  90155. * Gets the targeted animations for this animation group
  90156. */
  90157. readonly targetedAnimations: Array<TargetedAnimation>;
  90158. /**
  90159. * returning the list of animatables controlled by this animation group.
  90160. */
  90161. readonly animatables: Array<Animatable>;
  90162. /**
  90163. * Instantiates a new Animation Group.
  90164. * This helps managing several animations at once.
  90165. * @see http://doc.babylonjs.com/how_to/group
  90166. * @param name Defines the name of the group
  90167. * @param scene Defines the scene the group belongs to
  90168. */
  90169. constructor(
  90170. /** The name of the animation group */
  90171. name: string, scene?: Nullable<Scene>);
  90172. /**
  90173. * Add an animation (with its target) in the group
  90174. * @param animation defines the animation we want to add
  90175. * @param target defines the target of the animation
  90176. * @returns the TargetedAnimation object
  90177. */
  90178. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90179. /**
  90180. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90181. * It can add constant keys at begin or end
  90182. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90183. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90184. * @returns the animation group
  90185. */
  90186. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90187. /**
  90188. * Start all animations on given targets
  90189. * @param loop defines if animations must loop
  90190. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90191. * @param from defines the from key (optional)
  90192. * @param to defines the to key (optional)
  90193. * @returns the current animation group
  90194. */
  90195. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90196. /**
  90197. * Pause all animations
  90198. * @returns the animation group
  90199. */
  90200. pause(): AnimationGroup;
  90201. /**
  90202. * Play all animations to initial state
  90203. * This function will start() the animations if they were not started or will restart() them if they were paused
  90204. * @param loop defines if animations must loop
  90205. * @returns the animation group
  90206. */
  90207. play(loop?: boolean): AnimationGroup;
  90208. /**
  90209. * Reset all animations to initial state
  90210. * @returns the animation group
  90211. */
  90212. reset(): AnimationGroup;
  90213. /**
  90214. * Restart animations from key 0
  90215. * @returns the animation group
  90216. */
  90217. restart(): AnimationGroup;
  90218. /**
  90219. * Stop all animations
  90220. * @returns the animation group
  90221. */
  90222. stop(): AnimationGroup;
  90223. /**
  90224. * Set animation weight for all animatables
  90225. * @param weight defines the weight to use
  90226. * @return the animationGroup
  90227. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90228. */
  90229. setWeightForAllAnimatables(weight: number): AnimationGroup;
  90230. /**
  90231. * Synchronize and normalize all animatables with a source animatable
  90232. * @param root defines the root animatable to synchronize with
  90233. * @return the animationGroup
  90234. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90235. */
  90236. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  90237. /**
  90238. * Goes to a specific frame in this animation group
  90239. * @param frame the frame number to go to
  90240. * @return the animationGroup
  90241. */
  90242. goToFrame(frame: number): AnimationGroup;
  90243. /**
  90244. * Dispose all associated resources
  90245. */
  90246. dispose(): void;
  90247. private _checkAnimationGroupEnded;
  90248. /**
  90249. * Clone the current animation group and returns a copy
  90250. * @param newName defines the name of the new group
  90251. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  90252. * @returns the new aniamtion group
  90253. */
  90254. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  90255. /**
  90256. * Returns a new AnimationGroup object parsed from the source provided.
  90257. * @param parsedAnimationGroup defines the source
  90258. * @param scene defines the scene that will receive the animationGroup
  90259. * @returns a new AnimationGroup
  90260. */
  90261. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  90262. /**
  90263. * Returns the string "AnimationGroup"
  90264. * @returns "AnimationGroup"
  90265. */
  90266. getClassName(): string;
  90267. /**
  90268. * Creates a detailled string about the object
  90269. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  90270. * @returns a string representing the object
  90271. */
  90272. toString(fullDetails?: boolean): string;
  90273. }
  90274. }
  90275. declare module BABYLON {
  90276. /**
  90277. * Define an interface for all classes that will hold resources
  90278. */
  90279. export interface IDisposable {
  90280. /**
  90281. * Releases all held resources
  90282. */
  90283. dispose(): void;
  90284. }
  90285. /** Interface defining initialization parameters for Scene class */
  90286. export interface SceneOptions {
  90287. /**
  90288. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  90289. * It will improve performance when the number of geometries becomes important.
  90290. */
  90291. useGeometryUniqueIdsMap?: boolean;
  90292. /**
  90293. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  90294. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90295. */
  90296. useMaterialMeshMap?: boolean;
  90297. /**
  90298. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  90299. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90300. */
  90301. useClonedMeshhMap?: boolean;
  90302. }
  90303. /**
  90304. * Represents a scene to be rendered by the engine.
  90305. * @see http://doc.babylonjs.com/features/scene
  90306. */
  90307. export class Scene extends AbstractScene implements IAnimatable {
  90308. private static _uniqueIdCounter;
  90309. /** The fog is deactivated */
  90310. static readonly FOGMODE_NONE: number;
  90311. /** The fog density is following an exponential function */
  90312. static readonly FOGMODE_EXP: number;
  90313. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  90314. static readonly FOGMODE_EXP2: number;
  90315. /** The fog density is following a linear function. */
  90316. static readonly FOGMODE_LINEAR: number;
  90317. /**
  90318. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  90319. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90320. */
  90321. static MinDeltaTime: number;
  90322. /**
  90323. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  90324. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90325. */
  90326. static MaxDeltaTime: number;
  90327. /**
  90328. * Factory used to create the default material.
  90329. * @param name The name of the material to create
  90330. * @param scene The scene to create the material for
  90331. * @returns The default material
  90332. */
  90333. static DefaultMaterialFactory(scene: Scene): Material;
  90334. /**
  90335. * Factory used to create the a collision coordinator.
  90336. * @returns The collision coordinator
  90337. */
  90338. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  90339. /** @hidden */
  90340. readonly _isScene: boolean;
  90341. /**
  90342. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  90343. */
  90344. autoClear: boolean;
  90345. /**
  90346. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  90347. */
  90348. autoClearDepthAndStencil: boolean;
  90349. /**
  90350. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  90351. */
  90352. clearColor: Color4;
  90353. /**
  90354. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  90355. */
  90356. ambientColor: Color3;
  90357. /**
  90358. * This is use to store the default BRDF lookup for PBR materials in your scene.
  90359. * It should only be one of the following (if not the default embedded one):
  90360. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  90361. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  90362. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  90363. * The material properties need to be setup according to the type of texture in use.
  90364. */
  90365. environmentBRDFTexture: BaseTexture;
  90366. /** @hidden */
  90367. protected _environmentTexture: Nullable<BaseTexture>;
  90368. /**
  90369. * Texture used in all pbr material as the reflection texture.
  90370. * As in the majority of the scene they are the same (exception for multi room and so on),
  90371. * this is easier to reference from here than from all the materials.
  90372. */
  90373. /**
  90374. * Texture used in all pbr material as the reflection texture.
  90375. * As in the majority of the scene they are the same (exception for multi room and so on),
  90376. * this is easier to set here than in all the materials.
  90377. */
  90378. environmentTexture: Nullable<BaseTexture>;
  90379. /** @hidden */
  90380. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90381. /**
  90382. * Default image processing configuration used either in the rendering
  90383. * Forward main pass or through the imageProcessingPostProcess if present.
  90384. * As in the majority of the scene they are the same (exception for multi camera),
  90385. * this is easier to reference from here than from all the materials and post process.
  90386. *
  90387. * No setter as we it is a shared configuration, you can set the values instead.
  90388. */
  90389. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  90390. private _forceWireframe;
  90391. /**
  90392. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  90393. */
  90394. forceWireframe: boolean;
  90395. private _forcePointsCloud;
  90396. /**
  90397. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  90398. */
  90399. forcePointsCloud: boolean;
  90400. /**
  90401. * Gets or sets the active clipplane 1
  90402. */
  90403. clipPlane: Nullable<Plane>;
  90404. /**
  90405. * Gets or sets the active clipplane 2
  90406. */
  90407. clipPlane2: Nullable<Plane>;
  90408. /**
  90409. * Gets or sets the active clipplane 3
  90410. */
  90411. clipPlane3: Nullable<Plane>;
  90412. /**
  90413. * Gets or sets the active clipplane 4
  90414. */
  90415. clipPlane4: Nullable<Plane>;
  90416. /**
  90417. * Gets or sets a boolean indicating if animations are enabled
  90418. */
  90419. animationsEnabled: boolean;
  90420. private _animationPropertiesOverride;
  90421. /**
  90422. * Gets or sets the animation properties override
  90423. */
  90424. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90425. /**
  90426. * Gets or sets a boolean indicating if a constant deltatime has to be used
  90427. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  90428. */
  90429. useConstantAnimationDeltaTime: boolean;
  90430. /**
  90431. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  90432. * Please note that it requires to run a ray cast through the scene on every frame
  90433. */
  90434. constantlyUpdateMeshUnderPointer: boolean;
  90435. /**
  90436. * Defines the HTML cursor to use when hovering over interactive elements
  90437. */
  90438. hoverCursor: string;
  90439. /**
  90440. * Defines the HTML default cursor to use (empty by default)
  90441. */
  90442. defaultCursor: string;
  90443. /**
  90444. * This is used to call preventDefault() on pointer down
  90445. * in order to block unwanted artifacts like system double clicks
  90446. */
  90447. preventDefaultOnPointerDown: boolean;
  90448. /**
  90449. * This is used to call preventDefault() on pointer up
  90450. * in order to block unwanted artifacts like system double clicks
  90451. */
  90452. preventDefaultOnPointerUp: boolean;
  90453. /**
  90454. * Gets or sets user defined metadata
  90455. */
  90456. metadata: any;
  90457. /**
  90458. * For internal use only. Please do not use.
  90459. */
  90460. reservedDataStore: any;
  90461. /**
  90462. * Gets the name of the plugin used to load this scene (null by default)
  90463. */
  90464. loadingPluginName: string;
  90465. /**
  90466. * Use this array to add regular expressions used to disable offline support for specific urls
  90467. */
  90468. disableOfflineSupportExceptionRules: RegExp[];
  90469. /**
  90470. * An event triggered when the scene is disposed.
  90471. */
  90472. onDisposeObservable: Observable<Scene>;
  90473. private _onDisposeObserver;
  90474. /** Sets a function to be executed when this scene is disposed. */
  90475. onDispose: () => void;
  90476. /**
  90477. * An event triggered before rendering the scene (right after animations and physics)
  90478. */
  90479. onBeforeRenderObservable: Observable<Scene>;
  90480. private _onBeforeRenderObserver;
  90481. /** Sets a function to be executed before rendering this scene */
  90482. beforeRender: Nullable<() => void>;
  90483. /**
  90484. * An event triggered after rendering the scene
  90485. */
  90486. onAfterRenderObservable: Observable<Scene>;
  90487. private _onAfterRenderObserver;
  90488. /** Sets a function to be executed after rendering this scene */
  90489. afterRender: Nullable<() => void>;
  90490. /**
  90491. * An event triggered before animating the scene
  90492. */
  90493. onBeforeAnimationsObservable: Observable<Scene>;
  90494. /**
  90495. * An event triggered after animations processing
  90496. */
  90497. onAfterAnimationsObservable: Observable<Scene>;
  90498. /**
  90499. * An event triggered before draw calls are ready to be sent
  90500. */
  90501. onBeforeDrawPhaseObservable: Observable<Scene>;
  90502. /**
  90503. * An event triggered after draw calls have been sent
  90504. */
  90505. onAfterDrawPhaseObservable: Observable<Scene>;
  90506. /**
  90507. * An event triggered when the scene is ready
  90508. */
  90509. onReadyObservable: Observable<Scene>;
  90510. /**
  90511. * An event triggered before rendering a camera
  90512. */
  90513. onBeforeCameraRenderObservable: Observable<Camera>;
  90514. private _onBeforeCameraRenderObserver;
  90515. /** Sets a function to be executed before rendering a camera*/
  90516. beforeCameraRender: () => void;
  90517. /**
  90518. * An event triggered after rendering a camera
  90519. */
  90520. onAfterCameraRenderObservable: Observable<Camera>;
  90521. private _onAfterCameraRenderObserver;
  90522. /** Sets a function to be executed after rendering a camera*/
  90523. afterCameraRender: () => void;
  90524. /**
  90525. * An event triggered when active meshes evaluation is about to start
  90526. */
  90527. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  90528. /**
  90529. * An event triggered when active meshes evaluation is done
  90530. */
  90531. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  90532. /**
  90533. * An event triggered when particles rendering is about to start
  90534. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90535. */
  90536. onBeforeParticlesRenderingObservable: Observable<Scene>;
  90537. /**
  90538. * An event triggered when particles rendering is done
  90539. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90540. */
  90541. onAfterParticlesRenderingObservable: Observable<Scene>;
  90542. /**
  90543. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  90544. */
  90545. onDataLoadedObservable: Observable<Scene>;
  90546. /**
  90547. * An event triggered when a camera is created
  90548. */
  90549. onNewCameraAddedObservable: Observable<Camera>;
  90550. /**
  90551. * An event triggered when a camera is removed
  90552. */
  90553. onCameraRemovedObservable: Observable<Camera>;
  90554. /**
  90555. * An event triggered when a light is created
  90556. */
  90557. onNewLightAddedObservable: Observable<Light>;
  90558. /**
  90559. * An event triggered when a light is removed
  90560. */
  90561. onLightRemovedObservable: Observable<Light>;
  90562. /**
  90563. * An event triggered when a geometry is created
  90564. */
  90565. onNewGeometryAddedObservable: Observable<Geometry>;
  90566. /**
  90567. * An event triggered when a geometry is removed
  90568. */
  90569. onGeometryRemovedObservable: Observable<Geometry>;
  90570. /**
  90571. * An event triggered when a transform node is created
  90572. */
  90573. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  90574. /**
  90575. * An event triggered when a transform node is removed
  90576. */
  90577. onTransformNodeRemovedObservable: Observable<TransformNode>;
  90578. /**
  90579. * An event triggered when a mesh is created
  90580. */
  90581. onNewMeshAddedObservable: Observable<AbstractMesh>;
  90582. /**
  90583. * An event triggered when a mesh is removed
  90584. */
  90585. onMeshRemovedObservable: Observable<AbstractMesh>;
  90586. /**
  90587. * An event triggered when a skeleton is created
  90588. */
  90589. onNewSkeletonAddedObservable: Observable<Skeleton>;
  90590. /**
  90591. * An event triggered when a skeleton is removed
  90592. */
  90593. onSkeletonRemovedObservable: Observable<Skeleton>;
  90594. /**
  90595. * An event triggered when a material is created
  90596. */
  90597. onNewMaterialAddedObservable: Observable<Material>;
  90598. /**
  90599. * An event triggered when a material is removed
  90600. */
  90601. onMaterialRemovedObservable: Observable<Material>;
  90602. /**
  90603. * An event triggered when a texture is created
  90604. */
  90605. onNewTextureAddedObservable: Observable<BaseTexture>;
  90606. /**
  90607. * An event triggered when a texture is removed
  90608. */
  90609. onTextureRemovedObservable: Observable<BaseTexture>;
  90610. /**
  90611. * An event triggered when render targets are about to be rendered
  90612. * Can happen multiple times per frame.
  90613. */
  90614. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  90615. /**
  90616. * An event triggered when render targets were rendered.
  90617. * Can happen multiple times per frame.
  90618. */
  90619. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  90620. /**
  90621. * An event triggered before calculating deterministic simulation step
  90622. */
  90623. onBeforeStepObservable: Observable<Scene>;
  90624. /**
  90625. * An event triggered after calculating deterministic simulation step
  90626. */
  90627. onAfterStepObservable: Observable<Scene>;
  90628. /**
  90629. * An event triggered when the activeCamera property is updated
  90630. */
  90631. onActiveCameraChanged: Observable<Scene>;
  90632. /**
  90633. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  90634. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90635. * 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)
  90636. */
  90637. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90638. /**
  90639. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  90640. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90641. * 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)
  90642. */
  90643. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90644. /**
  90645. * This Observable will when a mesh has been imported into the scene.
  90646. */
  90647. onMeshImportedObservable: Observable<AbstractMesh>;
  90648. /**
  90649. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  90650. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  90651. */
  90652. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  90653. /** @hidden */
  90654. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  90655. /**
  90656. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  90657. */
  90658. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  90659. /**
  90660. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  90661. */
  90662. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  90663. /**
  90664. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  90665. */
  90666. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  90667. private _onPointerMove;
  90668. private _onPointerDown;
  90669. private _onPointerUp;
  90670. /** Callback called when a pointer move is detected */
  90671. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90672. /** Callback called when a pointer down is detected */
  90673. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90674. /** Callback called when a pointer up is detected */
  90675. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  90676. /** Callback called when a pointer pick is detected */
  90677. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  90678. /**
  90679. * 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).
  90680. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  90681. */
  90682. onPrePointerObservable: Observable<PointerInfoPre>;
  90683. /**
  90684. * Observable event triggered each time an input event is received from the rendering canvas
  90685. */
  90686. onPointerObservable: Observable<PointerInfo>;
  90687. /**
  90688. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  90689. */
  90690. readonly unTranslatedPointer: Vector2;
  90691. /** The distance in pixel that you have to move to prevent some events */
  90692. static DragMovementThreshold: number;
  90693. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  90694. static LongPressDelay: number;
  90695. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  90696. static DoubleClickDelay: number;
  90697. /** If you need to check double click without raising a single click at first click, enable this flag */
  90698. static ExclusiveDoubleClickMode: boolean;
  90699. private _initClickEvent;
  90700. private _initActionManager;
  90701. private _delayedSimpleClick;
  90702. private _delayedSimpleClickTimeout;
  90703. private _previousDelayedSimpleClickTimeout;
  90704. private _meshPickProceed;
  90705. private _previousButtonPressed;
  90706. private _currentPickResult;
  90707. private _previousPickResult;
  90708. private _totalPointersPressed;
  90709. private _doubleClickOccured;
  90710. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  90711. cameraToUseForPointers: Nullable<Camera>;
  90712. private _pointerX;
  90713. private _pointerY;
  90714. private _unTranslatedPointerX;
  90715. private _unTranslatedPointerY;
  90716. private _startingPointerPosition;
  90717. private _previousStartingPointerPosition;
  90718. private _startingPointerTime;
  90719. private _previousStartingPointerTime;
  90720. private _pointerCaptures;
  90721. private _timeAccumulator;
  90722. private _currentStepId;
  90723. private _currentInternalStep;
  90724. /** @hidden */
  90725. _mirroredCameraPosition: Nullable<Vector3>;
  90726. /**
  90727. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  90728. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  90729. */
  90730. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  90731. /**
  90732. * Observable event triggered each time an keyboard event is received from the hosting window
  90733. */
  90734. onKeyboardObservable: Observable<KeyboardInfo>;
  90735. private _onKeyDown;
  90736. private _onKeyUp;
  90737. private _onCanvasFocusObserver;
  90738. private _onCanvasBlurObserver;
  90739. private _useRightHandedSystem;
  90740. /**
  90741. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  90742. */
  90743. useRightHandedSystem: boolean;
  90744. /**
  90745. * Sets the step Id used by deterministic lock step
  90746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90747. * @param newStepId defines the step Id
  90748. */
  90749. setStepId(newStepId: number): void;
  90750. /**
  90751. * Gets the step Id used by deterministic lock step
  90752. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90753. * @returns the step Id
  90754. */
  90755. getStepId(): number;
  90756. /**
  90757. * Gets the internal step used by deterministic lock step
  90758. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90759. * @returns the internal step
  90760. */
  90761. getInternalStep(): number;
  90762. private _fogEnabled;
  90763. /**
  90764. * Gets or sets a boolean indicating if fog is enabled on this scene
  90765. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90766. * (Default is true)
  90767. */
  90768. fogEnabled: boolean;
  90769. private _fogMode;
  90770. /**
  90771. * Gets or sets the fog mode to use
  90772. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90773. * | mode | value |
  90774. * | --- | --- |
  90775. * | FOGMODE_NONE | 0 |
  90776. * | FOGMODE_EXP | 1 |
  90777. * | FOGMODE_EXP2 | 2 |
  90778. * | FOGMODE_LINEAR | 3 |
  90779. */
  90780. fogMode: number;
  90781. /**
  90782. * Gets or sets the fog color to use
  90783. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90784. * (Default is Color3(0.2, 0.2, 0.3))
  90785. */
  90786. fogColor: Color3;
  90787. /**
  90788. * Gets or sets the fog density to use
  90789. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90790. * (Default is 0.1)
  90791. */
  90792. fogDensity: number;
  90793. /**
  90794. * Gets or sets the fog start distance to use
  90795. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90796. * (Default is 0)
  90797. */
  90798. fogStart: number;
  90799. /**
  90800. * Gets or sets the fog end distance to use
  90801. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90802. * (Default is 1000)
  90803. */
  90804. fogEnd: number;
  90805. private _shadowsEnabled;
  90806. /**
  90807. * Gets or sets a boolean indicating if shadows are enabled on this scene
  90808. */
  90809. shadowsEnabled: boolean;
  90810. private _lightsEnabled;
  90811. /**
  90812. * Gets or sets a boolean indicating if lights are enabled on this scene
  90813. */
  90814. lightsEnabled: boolean;
  90815. /** All of the active cameras added to this scene. */
  90816. activeCameras: Camera[];
  90817. private _activeCamera;
  90818. /** Gets or sets the current active camera */
  90819. activeCamera: Nullable<Camera>;
  90820. private _defaultMaterial;
  90821. /** The default material used on meshes when no material is affected */
  90822. /** The default material used on meshes when no material is affected */
  90823. defaultMaterial: Material;
  90824. private _texturesEnabled;
  90825. /**
  90826. * Gets or sets a boolean indicating if textures are enabled on this scene
  90827. */
  90828. texturesEnabled: boolean;
  90829. /**
  90830. * Gets or sets a boolean indicating if particles are enabled on this scene
  90831. */
  90832. particlesEnabled: boolean;
  90833. /**
  90834. * Gets or sets a boolean indicating if sprites are enabled on this scene
  90835. */
  90836. spritesEnabled: boolean;
  90837. private _skeletonsEnabled;
  90838. /**
  90839. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  90840. */
  90841. skeletonsEnabled: boolean;
  90842. /**
  90843. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  90844. */
  90845. lensFlaresEnabled: boolean;
  90846. /**
  90847. * Gets or sets a boolean indicating if collisions are enabled on this scene
  90848. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90849. */
  90850. collisionsEnabled: boolean;
  90851. private _collisionCoordinator;
  90852. /** @hidden */
  90853. readonly collisionCoordinator: ICollisionCoordinator;
  90854. /**
  90855. * Defines the gravity applied to this scene (used only for collisions)
  90856. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90857. */
  90858. gravity: Vector3;
  90859. /**
  90860. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  90861. */
  90862. postProcessesEnabled: boolean;
  90863. /**
  90864. * The list of postprocesses added to the scene
  90865. */
  90866. postProcesses: PostProcess[];
  90867. /**
  90868. * Gets the current postprocess manager
  90869. */
  90870. postProcessManager: PostProcessManager;
  90871. /**
  90872. * Gets or sets a boolean indicating if render targets are enabled on this scene
  90873. */
  90874. renderTargetsEnabled: boolean;
  90875. /**
  90876. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  90877. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  90878. */
  90879. dumpNextRenderTargets: boolean;
  90880. /**
  90881. * The list of user defined render targets added to the scene
  90882. */
  90883. customRenderTargets: RenderTargetTexture[];
  90884. /**
  90885. * Defines if texture loading must be delayed
  90886. * If true, textures will only be loaded when they need to be rendered
  90887. */
  90888. useDelayedTextureLoading: boolean;
  90889. /**
  90890. * Gets the list of meshes imported to the scene through SceneLoader
  90891. */
  90892. importedMeshesFiles: String[];
  90893. /**
  90894. * Gets or sets a boolean indicating if probes are enabled on this scene
  90895. */
  90896. probesEnabled: boolean;
  90897. /**
  90898. * Gets or sets the current offline provider to use to store scene data
  90899. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  90900. */
  90901. offlineProvider: IOfflineProvider;
  90902. /**
  90903. * Gets or sets the action manager associated with the scene
  90904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90905. */
  90906. actionManager: AbstractActionManager;
  90907. private _meshesForIntersections;
  90908. /**
  90909. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  90910. */
  90911. proceduralTexturesEnabled: boolean;
  90912. private _engine;
  90913. private _totalVertices;
  90914. /** @hidden */
  90915. _activeIndices: PerfCounter;
  90916. /** @hidden */
  90917. _activeParticles: PerfCounter;
  90918. /** @hidden */
  90919. _activeBones: PerfCounter;
  90920. private _animationRatio;
  90921. /** @hidden */
  90922. _animationTimeLast: number;
  90923. /** @hidden */
  90924. _animationTime: number;
  90925. /**
  90926. * Gets or sets a general scale for animation speed
  90927. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  90928. */
  90929. animationTimeScale: number;
  90930. /** @hidden */
  90931. _cachedMaterial: Nullable<Material>;
  90932. /** @hidden */
  90933. _cachedEffect: Nullable<Effect>;
  90934. /** @hidden */
  90935. _cachedVisibility: Nullable<number>;
  90936. private _renderId;
  90937. private _frameId;
  90938. private _executeWhenReadyTimeoutId;
  90939. private _intermediateRendering;
  90940. private _viewUpdateFlag;
  90941. private _projectionUpdateFlag;
  90942. /** @hidden */
  90943. _toBeDisposed: Nullable<IDisposable>[];
  90944. private _activeRequests;
  90945. /** @hidden */
  90946. _pendingData: any[];
  90947. private _isDisposed;
  90948. /**
  90949. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  90950. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  90951. */
  90952. dispatchAllSubMeshesOfActiveMeshes: boolean;
  90953. private _activeMeshes;
  90954. private _processedMaterials;
  90955. private _renderTargets;
  90956. /** @hidden */
  90957. _activeParticleSystems: SmartArray<IParticleSystem>;
  90958. private _activeSkeletons;
  90959. private _softwareSkinnedMeshes;
  90960. private _renderingManager;
  90961. /** @hidden */
  90962. _activeAnimatables: Animatable[];
  90963. private _transformMatrix;
  90964. private _transformMatrixR;
  90965. private _sceneUbo;
  90966. private _multiviewSceneUbo;
  90967. private _viewMatrix;
  90968. private _projectionMatrix;
  90969. private _wheelEventName;
  90970. /** @hidden */
  90971. _forcedViewPosition: Nullable<Vector3>;
  90972. private _frustumPlanes;
  90973. /**
  90974. * Gets the list of frustum planes (built from the active camera)
  90975. */
  90976. readonly frustumPlanes: Plane[];
  90977. /**
  90978. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  90979. * This is useful if there are more lights that the maximum simulteanous authorized
  90980. */
  90981. requireLightSorting: boolean;
  90982. /** @hidden */
  90983. readonly useMaterialMeshMap: boolean;
  90984. /** @hidden */
  90985. readonly useClonedMeshhMap: boolean;
  90986. private _pointerOverMesh;
  90987. private _pickedDownMesh;
  90988. private _pickedUpMesh;
  90989. private _externalData;
  90990. private _uid;
  90991. /**
  90992. * @hidden
  90993. * Backing store of defined scene components.
  90994. */
  90995. _components: ISceneComponent[];
  90996. /**
  90997. * @hidden
  90998. * Backing store of defined scene components.
  90999. */
  91000. _serializableComponents: ISceneSerializableComponent[];
  91001. /**
  91002. * List of components to register on the next registration step.
  91003. */
  91004. private _transientComponents;
  91005. /**
  91006. * Registers the transient components if needed.
  91007. */
  91008. private _registerTransientComponents;
  91009. /**
  91010. * @hidden
  91011. * Add a component to the scene.
  91012. * Note that the ccomponent could be registered on th next frame if this is called after
  91013. * the register component stage.
  91014. * @param component Defines the component to add to the scene
  91015. */
  91016. _addComponent(component: ISceneComponent): void;
  91017. /**
  91018. * @hidden
  91019. * Gets a component from the scene.
  91020. * @param name defines the name of the component to retrieve
  91021. * @returns the component or null if not present
  91022. */
  91023. _getComponent(name: string): Nullable<ISceneComponent>;
  91024. /**
  91025. * @hidden
  91026. * Defines the actions happening before camera updates.
  91027. */
  91028. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91029. /**
  91030. * @hidden
  91031. * Defines the actions happening before clear the canvas.
  91032. */
  91033. _beforeClearStage: Stage<SimpleStageAction>;
  91034. /**
  91035. * @hidden
  91036. * Defines the actions when collecting render targets for the frame.
  91037. */
  91038. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91039. /**
  91040. * @hidden
  91041. * Defines the actions happening for one camera in the frame.
  91042. */
  91043. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91044. /**
  91045. * @hidden
  91046. * Defines the actions happening during the per mesh ready checks.
  91047. */
  91048. _isReadyForMeshStage: Stage<MeshStageAction>;
  91049. /**
  91050. * @hidden
  91051. * Defines the actions happening before evaluate active mesh checks.
  91052. */
  91053. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91054. /**
  91055. * @hidden
  91056. * Defines the actions happening during the evaluate sub mesh checks.
  91057. */
  91058. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91059. /**
  91060. * @hidden
  91061. * Defines the actions happening during the active mesh stage.
  91062. */
  91063. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91064. /**
  91065. * @hidden
  91066. * Defines the actions happening during the per camera render target step.
  91067. */
  91068. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  91069. /**
  91070. * @hidden
  91071. * Defines the actions happening just before the active camera is drawing.
  91072. */
  91073. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91074. /**
  91075. * @hidden
  91076. * Defines the actions happening just before a render target is drawing.
  91077. */
  91078. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91079. /**
  91080. * @hidden
  91081. * Defines the actions happening just before a rendering group is drawing.
  91082. */
  91083. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91084. /**
  91085. * @hidden
  91086. * Defines the actions happening just before a mesh is drawing.
  91087. */
  91088. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91089. /**
  91090. * @hidden
  91091. * Defines the actions happening just after a mesh has been drawn.
  91092. */
  91093. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91094. /**
  91095. * @hidden
  91096. * Defines the actions happening just after a rendering group has been drawn.
  91097. */
  91098. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91099. /**
  91100. * @hidden
  91101. * Defines the actions happening just after the active camera has been drawn.
  91102. */
  91103. _afterCameraDrawStage: Stage<CameraStageAction>;
  91104. /**
  91105. * @hidden
  91106. * Defines the actions happening just after a render target has been drawn.
  91107. */
  91108. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91109. /**
  91110. * @hidden
  91111. * Defines the actions happening just after rendering all cameras and computing intersections.
  91112. */
  91113. _afterRenderStage: Stage<SimpleStageAction>;
  91114. /**
  91115. * @hidden
  91116. * Defines the actions happening when a pointer move event happens.
  91117. */
  91118. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91119. /**
  91120. * @hidden
  91121. * Defines the actions happening when a pointer down event happens.
  91122. */
  91123. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91124. /**
  91125. * @hidden
  91126. * Defines the actions happening when a pointer up event happens.
  91127. */
  91128. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91129. /**
  91130. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91131. */
  91132. private geometriesByUniqueId;
  91133. /**
  91134. * Creates a new Scene
  91135. * @param engine defines the engine to use to render this scene
  91136. * @param options defines the scene options
  91137. */
  91138. constructor(engine: Engine, options?: SceneOptions);
  91139. private _defaultMeshCandidates;
  91140. /**
  91141. * @hidden
  91142. */
  91143. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91144. private _defaultSubMeshCandidates;
  91145. /**
  91146. * @hidden
  91147. */
  91148. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91149. /**
  91150. * Sets the default candidate providers for the scene.
  91151. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91152. * and getCollidingSubMeshCandidates to their default function
  91153. */
  91154. setDefaultCandidateProviders(): void;
  91155. /**
  91156. * Gets the mesh that is currently under the pointer
  91157. */
  91158. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91159. /**
  91160. * Gets or sets the current on-screen X position of the pointer
  91161. */
  91162. pointerX: number;
  91163. /**
  91164. * Gets or sets the current on-screen Y position of the pointer
  91165. */
  91166. pointerY: number;
  91167. /**
  91168. * Gets the cached material (ie. the latest rendered one)
  91169. * @returns the cached material
  91170. */
  91171. getCachedMaterial(): Nullable<Material>;
  91172. /**
  91173. * Gets the cached effect (ie. the latest rendered one)
  91174. * @returns the cached effect
  91175. */
  91176. getCachedEffect(): Nullable<Effect>;
  91177. /**
  91178. * Gets the cached visibility state (ie. the latest rendered one)
  91179. * @returns the cached visibility state
  91180. */
  91181. getCachedVisibility(): Nullable<number>;
  91182. /**
  91183. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91184. * @param material defines the current material
  91185. * @param effect defines the current effect
  91186. * @param visibility defines the current visibility state
  91187. * @returns true if one parameter is not cached
  91188. */
  91189. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91190. /**
  91191. * Gets the engine associated with the scene
  91192. * @returns an Engine
  91193. */
  91194. getEngine(): Engine;
  91195. /**
  91196. * Gets the total number of vertices rendered per frame
  91197. * @returns the total number of vertices rendered per frame
  91198. */
  91199. getTotalVertices(): number;
  91200. /**
  91201. * Gets the performance counter for total vertices
  91202. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91203. */
  91204. readonly totalVerticesPerfCounter: PerfCounter;
  91205. /**
  91206. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91207. * @returns the total number of active indices rendered per frame
  91208. */
  91209. getActiveIndices(): number;
  91210. /**
  91211. * Gets the performance counter for active indices
  91212. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91213. */
  91214. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91215. /**
  91216. * Gets the total number of active particles rendered per frame
  91217. * @returns the total number of active particles rendered per frame
  91218. */
  91219. getActiveParticles(): number;
  91220. /**
  91221. * Gets the performance counter for active particles
  91222. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91223. */
  91224. readonly activeParticlesPerfCounter: PerfCounter;
  91225. /**
  91226. * Gets the total number of active bones rendered per frame
  91227. * @returns the total number of active bones rendered per frame
  91228. */
  91229. getActiveBones(): number;
  91230. /**
  91231. * Gets the performance counter for active bones
  91232. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91233. */
  91234. readonly activeBonesPerfCounter: PerfCounter;
  91235. /**
  91236. * Gets the array of active meshes
  91237. * @returns an array of AbstractMesh
  91238. */
  91239. getActiveMeshes(): SmartArray<AbstractMesh>;
  91240. /**
  91241. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  91242. * @returns a number
  91243. */
  91244. getAnimationRatio(): number;
  91245. /**
  91246. * Gets an unique Id for the current render phase
  91247. * @returns a number
  91248. */
  91249. getRenderId(): number;
  91250. /**
  91251. * Gets an unique Id for the current frame
  91252. * @returns a number
  91253. */
  91254. getFrameId(): number;
  91255. /** Call this function if you want to manually increment the render Id*/
  91256. incrementRenderId(): void;
  91257. private _updatePointerPosition;
  91258. private _createUbo;
  91259. private _createMultiviewUbo;
  91260. private _setRayOnPointerInfo;
  91261. /**
  91262. * Use this method to simulate a pointer move on a mesh
  91263. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91264. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91265. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91266. * @returns the current scene
  91267. */
  91268. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91269. private _processPointerMove;
  91270. private _checkPrePointerObservable;
  91271. /**
  91272. * Use this method to simulate a pointer down on a mesh
  91273. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91274. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91275. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91276. * @returns the current scene
  91277. */
  91278. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91279. private _processPointerDown;
  91280. /**
  91281. * Use this method to simulate a pointer up on a mesh
  91282. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91283. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91284. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91285. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91286. * @returns the current scene
  91287. */
  91288. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  91289. private _processPointerUp;
  91290. /**
  91291. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91292. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91293. * @returns true if the pointer was captured
  91294. */
  91295. isPointerCaptured(pointerId?: number): boolean;
  91296. /** @hidden */
  91297. _isPointerSwiping(): boolean;
  91298. /**
  91299. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91300. * @param attachUp defines if you want to attach events to pointerup
  91301. * @param attachDown defines if you want to attach events to pointerdown
  91302. * @param attachMove defines if you want to attach events to pointermove
  91303. */
  91304. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91305. /** Detaches all event handlers*/
  91306. detachControl(): void;
  91307. /**
  91308. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  91309. * Delay loaded resources are not taking in account
  91310. * @return true if all required resources are ready
  91311. */
  91312. isReady(): boolean;
  91313. /** Resets all cached information relative to material (including effect and visibility) */
  91314. resetCachedMaterial(): void;
  91315. /**
  91316. * Registers a function to be called before every frame render
  91317. * @param func defines the function to register
  91318. */
  91319. registerBeforeRender(func: () => void): void;
  91320. /**
  91321. * Unregisters a function called before every frame render
  91322. * @param func defines the function to unregister
  91323. */
  91324. unregisterBeforeRender(func: () => void): void;
  91325. /**
  91326. * Registers a function to be called after every frame render
  91327. * @param func defines the function to register
  91328. */
  91329. registerAfterRender(func: () => void): void;
  91330. /**
  91331. * Unregisters a function called after every frame render
  91332. * @param func defines the function to unregister
  91333. */
  91334. unregisterAfterRender(func: () => void): void;
  91335. private _executeOnceBeforeRender;
  91336. /**
  91337. * The provided function will run before render once and will be disposed afterwards.
  91338. * A timeout delay can be provided so that the function will be executed in N ms.
  91339. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  91340. * @param func The function to be executed.
  91341. * @param timeout optional delay in ms
  91342. */
  91343. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  91344. /** @hidden */
  91345. _addPendingData(data: any): void;
  91346. /** @hidden */
  91347. _removePendingData(data: any): void;
  91348. /**
  91349. * Returns the number of items waiting to be loaded
  91350. * @returns the number of items waiting to be loaded
  91351. */
  91352. getWaitingItemsCount(): number;
  91353. /**
  91354. * Returns a boolean indicating if the scene is still loading data
  91355. */
  91356. readonly isLoading: boolean;
  91357. /**
  91358. * Registers a function to be executed when the scene is ready
  91359. * @param {Function} func - the function to be executed
  91360. */
  91361. executeWhenReady(func: () => void): void;
  91362. /**
  91363. * Returns a promise that resolves when the scene is ready
  91364. * @returns A promise that resolves when the scene is ready
  91365. */
  91366. whenReadyAsync(): Promise<void>;
  91367. /** @hidden */
  91368. _checkIsReady(): void;
  91369. /**
  91370. * Gets all animatable attached to the scene
  91371. */
  91372. readonly animatables: Animatable[];
  91373. /**
  91374. * Resets the last animation time frame.
  91375. * Useful to override when animations start running when loading a scene for the first time.
  91376. */
  91377. resetLastAnimationTimeFrame(): void;
  91378. /**
  91379. * Gets the current view matrix
  91380. * @returns a Matrix
  91381. */
  91382. getViewMatrix(): Matrix;
  91383. /**
  91384. * Gets the current projection matrix
  91385. * @returns a Matrix
  91386. */
  91387. getProjectionMatrix(): Matrix;
  91388. /**
  91389. * Gets the current transform matrix
  91390. * @returns a Matrix made of View * Projection
  91391. */
  91392. getTransformMatrix(): Matrix;
  91393. /**
  91394. * Sets the current transform matrix
  91395. * @param viewL defines the View matrix to use
  91396. * @param projectionL defines the Projection matrix to use
  91397. * @param viewR defines the right View matrix to use (if provided)
  91398. * @param projectionR defines the right Projection matrix to use (if provided)
  91399. */
  91400. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  91401. /**
  91402. * Gets the uniform buffer used to store scene data
  91403. * @returns a UniformBuffer
  91404. */
  91405. getSceneUniformBuffer(): UniformBuffer;
  91406. /**
  91407. * Gets an unique (relatively to the current scene) Id
  91408. * @returns an unique number for the scene
  91409. */
  91410. getUniqueId(): number;
  91411. /**
  91412. * Add a mesh to the list of scene's meshes
  91413. * @param newMesh defines the mesh to add
  91414. * @param recursive if all child meshes should also be added to the scene
  91415. */
  91416. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  91417. /**
  91418. * Remove a mesh for the list of scene's meshes
  91419. * @param toRemove defines the mesh to remove
  91420. * @param recursive if all child meshes should also be removed from the scene
  91421. * @returns the index where the mesh was in the mesh list
  91422. */
  91423. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  91424. /**
  91425. * Add a transform node to the list of scene's transform nodes
  91426. * @param newTransformNode defines the transform node to add
  91427. */
  91428. addTransformNode(newTransformNode: TransformNode): void;
  91429. /**
  91430. * Remove a transform node for the list of scene's transform nodes
  91431. * @param toRemove defines the transform node to remove
  91432. * @returns the index where the transform node was in the transform node list
  91433. */
  91434. removeTransformNode(toRemove: TransformNode): number;
  91435. /**
  91436. * Remove a skeleton for the list of scene's skeletons
  91437. * @param toRemove defines the skeleton to remove
  91438. * @returns the index where the skeleton was in the skeleton list
  91439. */
  91440. removeSkeleton(toRemove: Skeleton): number;
  91441. /**
  91442. * Remove a morph target for the list of scene's morph targets
  91443. * @param toRemove defines the morph target to remove
  91444. * @returns the index where the morph target was in the morph target list
  91445. */
  91446. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  91447. /**
  91448. * Remove a light for the list of scene's lights
  91449. * @param toRemove defines the light to remove
  91450. * @returns the index where the light was in the light list
  91451. */
  91452. removeLight(toRemove: Light): number;
  91453. /**
  91454. * Remove a camera for the list of scene's cameras
  91455. * @param toRemove defines the camera to remove
  91456. * @returns the index where the camera was in the camera list
  91457. */
  91458. removeCamera(toRemove: Camera): number;
  91459. /**
  91460. * Remove a particle system for the list of scene's particle systems
  91461. * @param toRemove defines the particle system to remove
  91462. * @returns the index where the particle system was in the particle system list
  91463. */
  91464. removeParticleSystem(toRemove: IParticleSystem): number;
  91465. /**
  91466. * Remove a animation for the list of scene's animations
  91467. * @param toRemove defines the animation to remove
  91468. * @returns the index where the animation was in the animation list
  91469. */
  91470. removeAnimation(toRemove: Animation): number;
  91471. /**
  91472. * Removes the given animation group from this scene.
  91473. * @param toRemove The animation group to remove
  91474. * @returns The index of the removed animation group
  91475. */
  91476. removeAnimationGroup(toRemove: AnimationGroup): number;
  91477. /**
  91478. * Removes the given multi-material from this scene.
  91479. * @param toRemove The multi-material to remove
  91480. * @returns The index of the removed multi-material
  91481. */
  91482. removeMultiMaterial(toRemove: MultiMaterial): number;
  91483. /**
  91484. * Removes the given material from this scene.
  91485. * @param toRemove The material to remove
  91486. * @returns The index of the removed material
  91487. */
  91488. removeMaterial(toRemove: Material): number;
  91489. /**
  91490. * Removes the given action manager from this scene.
  91491. * @param toRemove The action manager to remove
  91492. * @returns The index of the removed action manager
  91493. */
  91494. removeActionManager(toRemove: AbstractActionManager): number;
  91495. /**
  91496. * Removes the given texture from this scene.
  91497. * @param toRemove The texture to remove
  91498. * @returns The index of the removed texture
  91499. */
  91500. removeTexture(toRemove: BaseTexture): number;
  91501. /**
  91502. * Adds the given light to this scene
  91503. * @param newLight The light to add
  91504. */
  91505. addLight(newLight: Light): void;
  91506. /**
  91507. * Sorts the list list based on light priorities
  91508. */
  91509. sortLightsByPriority(): void;
  91510. /**
  91511. * Adds the given camera to this scene
  91512. * @param newCamera The camera to add
  91513. */
  91514. addCamera(newCamera: Camera): void;
  91515. /**
  91516. * Adds the given skeleton to this scene
  91517. * @param newSkeleton The skeleton to add
  91518. */
  91519. addSkeleton(newSkeleton: Skeleton): void;
  91520. /**
  91521. * Adds the given particle system to this scene
  91522. * @param newParticleSystem The particle system to add
  91523. */
  91524. addParticleSystem(newParticleSystem: IParticleSystem): void;
  91525. /**
  91526. * Adds the given animation to this scene
  91527. * @param newAnimation The animation to add
  91528. */
  91529. addAnimation(newAnimation: Animation): void;
  91530. /**
  91531. * Adds the given animation group to this scene.
  91532. * @param newAnimationGroup The animation group to add
  91533. */
  91534. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  91535. /**
  91536. * Adds the given multi-material to this scene
  91537. * @param newMultiMaterial The multi-material to add
  91538. */
  91539. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  91540. /**
  91541. * Adds the given material to this scene
  91542. * @param newMaterial The material to add
  91543. */
  91544. addMaterial(newMaterial: Material): void;
  91545. /**
  91546. * Adds the given morph target to this scene
  91547. * @param newMorphTargetManager The morph target to add
  91548. */
  91549. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  91550. /**
  91551. * Adds the given geometry to this scene
  91552. * @param newGeometry The geometry to add
  91553. */
  91554. addGeometry(newGeometry: Geometry): void;
  91555. /**
  91556. * Adds the given action manager to this scene
  91557. * @param newActionManager The action manager to add
  91558. */
  91559. addActionManager(newActionManager: AbstractActionManager): void;
  91560. /**
  91561. * Adds the given texture to this scene.
  91562. * @param newTexture The texture to add
  91563. */
  91564. addTexture(newTexture: BaseTexture): void;
  91565. /**
  91566. * Switch active camera
  91567. * @param newCamera defines the new active camera
  91568. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  91569. */
  91570. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  91571. /**
  91572. * sets the active camera of the scene using its ID
  91573. * @param id defines the camera's ID
  91574. * @return the new active camera or null if none found.
  91575. */
  91576. setActiveCameraByID(id: string): Nullable<Camera>;
  91577. /**
  91578. * sets the active camera of the scene using its name
  91579. * @param name defines the camera's name
  91580. * @returns the new active camera or null if none found.
  91581. */
  91582. setActiveCameraByName(name: string): Nullable<Camera>;
  91583. /**
  91584. * get an animation group using its name
  91585. * @param name defines the material's name
  91586. * @return the animation group or null if none found.
  91587. */
  91588. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  91589. /**
  91590. * Get a material using its unique id
  91591. * @param uniqueId defines the material's unique id
  91592. * @return the material or null if none found.
  91593. */
  91594. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  91595. /**
  91596. * get a material using its id
  91597. * @param id defines the material's ID
  91598. * @return the material or null if none found.
  91599. */
  91600. getMaterialByID(id: string): Nullable<Material>;
  91601. /**
  91602. * Gets a material using its name
  91603. * @param name defines the material's name
  91604. * @return the material or null if none found.
  91605. */
  91606. getMaterialByName(name: string): Nullable<Material>;
  91607. /**
  91608. * Gets a camera using its id
  91609. * @param id defines the id to look for
  91610. * @returns the camera or null if not found
  91611. */
  91612. getCameraByID(id: string): Nullable<Camera>;
  91613. /**
  91614. * Gets a camera using its unique id
  91615. * @param uniqueId defines the unique id to look for
  91616. * @returns the camera or null if not found
  91617. */
  91618. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  91619. /**
  91620. * Gets a camera using its name
  91621. * @param name defines the camera's name
  91622. * @return the camera or null if none found.
  91623. */
  91624. getCameraByName(name: string): Nullable<Camera>;
  91625. /**
  91626. * Gets a bone using its id
  91627. * @param id defines the bone's id
  91628. * @return the bone or null if not found
  91629. */
  91630. getBoneByID(id: string): Nullable<Bone>;
  91631. /**
  91632. * Gets a bone using its id
  91633. * @param name defines the bone's name
  91634. * @return the bone or null if not found
  91635. */
  91636. getBoneByName(name: string): Nullable<Bone>;
  91637. /**
  91638. * Gets a light node using its name
  91639. * @param name defines the the light's name
  91640. * @return the light or null if none found.
  91641. */
  91642. getLightByName(name: string): Nullable<Light>;
  91643. /**
  91644. * Gets a light node using its id
  91645. * @param id defines the light's id
  91646. * @return the light or null if none found.
  91647. */
  91648. getLightByID(id: string): Nullable<Light>;
  91649. /**
  91650. * Gets a light node using its scene-generated unique ID
  91651. * @param uniqueId defines the light's unique id
  91652. * @return the light or null if none found.
  91653. */
  91654. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  91655. /**
  91656. * Gets a particle system by id
  91657. * @param id defines the particle system id
  91658. * @return the corresponding system or null if none found
  91659. */
  91660. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  91661. /**
  91662. * Gets a geometry using its ID
  91663. * @param id defines the geometry's id
  91664. * @return the geometry or null if none found.
  91665. */
  91666. getGeometryByID(id: string): Nullable<Geometry>;
  91667. private _getGeometryByUniqueID;
  91668. /**
  91669. * Add a new geometry to this scene
  91670. * @param geometry defines the geometry to be added to the scene.
  91671. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  91672. * @return a boolean defining if the geometry was added or not
  91673. */
  91674. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  91675. /**
  91676. * Removes an existing geometry
  91677. * @param geometry defines the geometry to be removed from the scene
  91678. * @return a boolean defining if the geometry was removed or not
  91679. */
  91680. removeGeometry(geometry: Geometry): boolean;
  91681. /**
  91682. * Gets the list of geometries attached to the scene
  91683. * @returns an array of Geometry
  91684. */
  91685. getGeometries(): Geometry[];
  91686. /**
  91687. * Gets the first added mesh found of a given ID
  91688. * @param id defines the id to search for
  91689. * @return the mesh found or null if not found at all
  91690. */
  91691. getMeshByID(id: string): Nullable<AbstractMesh>;
  91692. /**
  91693. * Gets a list of meshes using their id
  91694. * @param id defines the id to search for
  91695. * @returns a list of meshes
  91696. */
  91697. getMeshesByID(id: string): Array<AbstractMesh>;
  91698. /**
  91699. * Gets the first added transform node found of a given ID
  91700. * @param id defines the id to search for
  91701. * @return the found transform node or null if not found at all.
  91702. */
  91703. getTransformNodeByID(id: string): Nullable<TransformNode>;
  91704. /**
  91705. * Gets a transform node with its auto-generated unique id
  91706. * @param uniqueId efines the unique id to search for
  91707. * @return the found transform node or null if not found at all.
  91708. */
  91709. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  91710. /**
  91711. * Gets a list of transform nodes using their id
  91712. * @param id defines the id to search for
  91713. * @returns a list of transform nodes
  91714. */
  91715. getTransformNodesByID(id: string): Array<TransformNode>;
  91716. /**
  91717. * Gets a mesh with its auto-generated unique id
  91718. * @param uniqueId defines the unique id to search for
  91719. * @return the found mesh or null if not found at all.
  91720. */
  91721. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  91722. /**
  91723. * Gets a the last added mesh using a given id
  91724. * @param id defines the id to search for
  91725. * @return the found mesh or null if not found at all.
  91726. */
  91727. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  91728. /**
  91729. * Gets a the last added node (Mesh, Camera, Light) using a given id
  91730. * @param id defines the id to search for
  91731. * @return the found node or null if not found at all
  91732. */
  91733. getLastEntryByID(id: string): Nullable<Node>;
  91734. /**
  91735. * Gets a node (Mesh, Camera, Light) using a given id
  91736. * @param id defines the id to search for
  91737. * @return the found node or null if not found at all
  91738. */
  91739. getNodeByID(id: string): Nullable<Node>;
  91740. /**
  91741. * Gets a node (Mesh, Camera, Light) using a given name
  91742. * @param name defines the name to search for
  91743. * @return the found node or null if not found at all.
  91744. */
  91745. getNodeByName(name: string): Nullable<Node>;
  91746. /**
  91747. * Gets a mesh using a given name
  91748. * @param name defines the name to search for
  91749. * @return the found mesh or null if not found at all.
  91750. */
  91751. getMeshByName(name: string): Nullable<AbstractMesh>;
  91752. /**
  91753. * Gets a transform node using a given name
  91754. * @param name defines the name to search for
  91755. * @return the found transform node or null if not found at all.
  91756. */
  91757. getTransformNodeByName(name: string): Nullable<TransformNode>;
  91758. /**
  91759. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  91760. * @param id defines the id to search for
  91761. * @return the found skeleton or null if not found at all.
  91762. */
  91763. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  91764. /**
  91765. * Gets a skeleton using a given auto generated unique id
  91766. * @param uniqueId defines the unique id to search for
  91767. * @return the found skeleton or null if not found at all.
  91768. */
  91769. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  91770. /**
  91771. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  91772. * @param id defines the id to search for
  91773. * @return the found skeleton or null if not found at all.
  91774. */
  91775. getSkeletonById(id: string): Nullable<Skeleton>;
  91776. /**
  91777. * Gets a skeleton using a given name
  91778. * @param name defines the name to search for
  91779. * @return the found skeleton or null if not found at all.
  91780. */
  91781. getSkeletonByName(name: string): Nullable<Skeleton>;
  91782. /**
  91783. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  91784. * @param id defines the id to search for
  91785. * @return the found morph target manager or null if not found at all.
  91786. */
  91787. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  91788. /**
  91789. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  91790. * @param id defines the id to search for
  91791. * @return the found morph target or null if not found at all.
  91792. */
  91793. getMorphTargetById(id: string): Nullable<MorphTarget>;
  91794. /**
  91795. * Gets a boolean indicating if the given mesh is active
  91796. * @param mesh defines the mesh to look for
  91797. * @returns true if the mesh is in the active list
  91798. */
  91799. isActiveMesh(mesh: AbstractMesh): boolean;
  91800. /**
  91801. * Return a unique id as a string which can serve as an identifier for the scene
  91802. */
  91803. readonly uid: string;
  91804. /**
  91805. * Add an externaly attached data from its key.
  91806. * This method call will fail and return false, if such key already exists.
  91807. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91808. * @param key the unique key that identifies the data
  91809. * @param data the data object to associate to the key for this Engine instance
  91810. * @return true if no such key were already present and the data was added successfully, false otherwise
  91811. */
  91812. addExternalData<T>(key: string, data: T): boolean;
  91813. /**
  91814. * Get an externaly attached data from its key
  91815. * @param key the unique key that identifies the data
  91816. * @return the associated data, if present (can be null), or undefined if not present
  91817. */
  91818. getExternalData<T>(key: string): Nullable<T>;
  91819. /**
  91820. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91821. * @param key the unique key that identifies the data
  91822. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91823. * @return the associated data, can be null if the factory returned null.
  91824. */
  91825. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91826. /**
  91827. * Remove an externaly attached data from the Engine instance
  91828. * @param key the unique key that identifies the data
  91829. * @return true if the data was successfully removed, false if it doesn't exist
  91830. */
  91831. removeExternalData(key: string): boolean;
  91832. private _evaluateSubMesh;
  91833. /**
  91834. * Clear the processed materials smart array preventing retention point in material dispose.
  91835. */
  91836. freeProcessedMaterials(): void;
  91837. private _preventFreeActiveMeshesAndRenderingGroups;
  91838. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  91839. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  91840. * when disposing several meshes in a row or a hierarchy of meshes.
  91841. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  91842. */
  91843. blockfreeActiveMeshesAndRenderingGroups: boolean;
  91844. /**
  91845. * Clear the active meshes smart array preventing retention point in mesh dispose.
  91846. */
  91847. freeActiveMeshes(): void;
  91848. /**
  91849. * Clear the info related to rendering groups preventing retention points during dispose.
  91850. */
  91851. freeRenderingGroups(): void;
  91852. /** @hidden */
  91853. _isInIntermediateRendering(): boolean;
  91854. /**
  91855. * Lambda returning the list of potentially active meshes.
  91856. */
  91857. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  91858. /**
  91859. * Lambda returning the list of potentially active sub meshes.
  91860. */
  91861. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  91862. /**
  91863. * Lambda returning the list of potentially intersecting sub meshes.
  91864. */
  91865. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  91866. /**
  91867. * Lambda returning the list of potentially colliding sub meshes.
  91868. */
  91869. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  91870. private _activeMeshesFrozen;
  91871. /**
  91872. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  91873. * @returns the current scene
  91874. */
  91875. freezeActiveMeshes(): Scene;
  91876. /**
  91877. * Use this function to restart evaluating active meshes on every frame
  91878. * @returns the current scene
  91879. */
  91880. unfreezeActiveMeshes(): Scene;
  91881. private _evaluateActiveMeshes;
  91882. private _activeMesh;
  91883. /**
  91884. * Update the transform matrix to update from the current active camera
  91885. * @param force defines a boolean used to force the update even if cache is up to date
  91886. */
  91887. updateTransformMatrix(force?: boolean): void;
  91888. private _bindFrameBuffer;
  91889. /** @hidden */
  91890. _allowPostProcessClearColor: boolean;
  91891. private _renderForCamera;
  91892. private _processSubCameras;
  91893. private _checkIntersections;
  91894. /** @hidden */
  91895. _advancePhysicsEngineStep(step: number): void;
  91896. /**
  91897. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  91898. */
  91899. getDeterministicFrameTime: () => number;
  91900. /** @hidden */
  91901. _animate(): void;
  91902. /**
  91903. * Render the scene
  91904. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  91905. */
  91906. render(updateCameras?: boolean): void;
  91907. /**
  91908. * Freeze all materials
  91909. * A frozen material will not be updatable but should be faster to render
  91910. */
  91911. freezeMaterials(): void;
  91912. /**
  91913. * Unfreeze all materials
  91914. * A frozen material will not be updatable but should be faster to render
  91915. */
  91916. unfreezeMaterials(): void;
  91917. /**
  91918. * Releases all held ressources
  91919. */
  91920. dispose(): void;
  91921. /**
  91922. * Gets if the scene is already disposed
  91923. */
  91924. readonly isDisposed: boolean;
  91925. /**
  91926. * Call this function to reduce memory footprint of the scene.
  91927. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  91928. */
  91929. clearCachedVertexData(): void;
  91930. /**
  91931. * This function will remove the local cached buffer data from texture.
  91932. * It will save memory but will prevent the texture from being rebuilt
  91933. */
  91934. cleanCachedTextureBuffer(): void;
  91935. /**
  91936. * Get the world extend vectors with an optional filter
  91937. *
  91938. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  91939. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  91940. */
  91941. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  91942. min: Vector3;
  91943. max: Vector3;
  91944. };
  91945. /**
  91946. * Creates a ray that can be used to pick in the scene
  91947. * @param x defines the x coordinate of the origin (on-screen)
  91948. * @param y defines the y coordinate of the origin (on-screen)
  91949. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91950. * @param camera defines the camera to use for the picking
  91951. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91952. * @returns a Ray
  91953. */
  91954. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  91955. /**
  91956. * Creates a ray that can be used to pick in the scene
  91957. * @param x defines the x coordinate of the origin (on-screen)
  91958. * @param y defines the y coordinate of the origin (on-screen)
  91959. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91960. * @param result defines the ray where to store the picking ray
  91961. * @param camera defines the camera to use for the picking
  91962. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91963. * @returns the current scene
  91964. */
  91965. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  91966. /**
  91967. * Creates a ray that can be used to pick in the scene
  91968. * @param x defines the x coordinate of the origin (on-screen)
  91969. * @param y defines the y coordinate of the origin (on-screen)
  91970. * @param camera defines the camera to use for the picking
  91971. * @returns a Ray
  91972. */
  91973. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  91974. /**
  91975. * Creates a ray that can be used to pick in the scene
  91976. * @param x defines the x coordinate of the origin (on-screen)
  91977. * @param y defines the y coordinate of the origin (on-screen)
  91978. * @param result defines the ray where to store the picking ray
  91979. * @param camera defines the camera to use for the picking
  91980. * @returns the current scene
  91981. */
  91982. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  91983. /** Launch a ray to try to pick a mesh in the scene
  91984. * @param x position on screen
  91985. * @param y position on screen
  91986. * @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
  91987. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  91988. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91989. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91990. * @returns a PickingInfo
  91991. */
  91992. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  91993. /** Use the given ray to pick a mesh in the scene
  91994. * @param ray The ray to use to pick meshes
  91995. * @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
  91996. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  91997. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91998. * @returns a PickingInfo
  91999. */
  92000. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92001. /**
  92002. * Launch a ray to try to pick a mesh in the scene
  92003. * @param x X position on screen
  92004. * @param y Y position on screen
  92005. * @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
  92006. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92007. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92008. * @returns an array of PickingInfo
  92009. */
  92010. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92011. /**
  92012. * Launch a ray to try to pick a mesh in the scene
  92013. * @param ray Ray to use
  92014. * @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
  92015. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92016. * @returns an array of PickingInfo
  92017. */
  92018. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92019. /**
  92020. * Force the value of meshUnderPointer
  92021. * @param mesh defines the mesh to use
  92022. */
  92023. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92024. /**
  92025. * Gets the mesh under the pointer
  92026. * @returns a Mesh or null if no mesh is under the pointer
  92027. */
  92028. getPointerOverMesh(): Nullable<AbstractMesh>;
  92029. /** @hidden */
  92030. _rebuildGeometries(): void;
  92031. /** @hidden */
  92032. _rebuildTextures(): void;
  92033. private _getByTags;
  92034. /**
  92035. * Get a list of meshes by tags
  92036. * @param tagsQuery defines the tags query to use
  92037. * @param forEach defines a predicate used to filter results
  92038. * @returns an array of Mesh
  92039. */
  92040. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92041. /**
  92042. * Get a list of cameras by tags
  92043. * @param tagsQuery defines the tags query to use
  92044. * @param forEach defines a predicate used to filter results
  92045. * @returns an array of Camera
  92046. */
  92047. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92048. /**
  92049. * Get a list of lights by tags
  92050. * @param tagsQuery defines the tags query to use
  92051. * @param forEach defines a predicate used to filter results
  92052. * @returns an array of Light
  92053. */
  92054. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92055. /**
  92056. * Get a list of materials by tags
  92057. * @param tagsQuery defines the tags query to use
  92058. * @param forEach defines a predicate used to filter results
  92059. * @returns an array of Material
  92060. */
  92061. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92062. /**
  92063. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92064. * This allowed control for front to back rendering or reversly depending of the special needs.
  92065. *
  92066. * @param renderingGroupId The rendering group id corresponding to its index
  92067. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92068. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92069. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92070. */
  92071. 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;
  92072. /**
  92073. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92074. *
  92075. * @param renderingGroupId The rendering group id corresponding to its index
  92076. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92077. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92078. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92079. */
  92080. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92081. /**
  92082. * Gets the current auto clear configuration for one rendering group of the rendering
  92083. * manager.
  92084. * @param index the rendering group index to get the information for
  92085. * @returns The auto clear setup for the requested rendering group
  92086. */
  92087. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92088. private _blockMaterialDirtyMechanism;
  92089. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92090. blockMaterialDirtyMechanism: boolean;
  92091. /**
  92092. * Will flag all materials as dirty to trigger new shader compilation
  92093. * @param flag defines the flag used to specify which material part must be marked as dirty
  92094. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92095. */
  92096. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92097. /** @hidden */
  92098. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  92099. /** @hidden */
  92100. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92101. }
  92102. }
  92103. declare module BABYLON {
  92104. /**
  92105. * Set of assets to keep when moving a scene into an asset container.
  92106. */
  92107. export class KeepAssets extends AbstractScene {
  92108. }
  92109. /**
  92110. * Container with a set of assets that can be added or removed from a scene.
  92111. */
  92112. export class AssetContainer extends AbstractScene {
  92113. /**
  92114. * The scene the AssetContainer belongs to.
  92115. */
  92116. scene: Scene;
  92117. /**
  92118. * Instantiates an AssetContainer.
  92119. * @param scene The scene the AssetContainer belongs to.
  92120. */
  92121. constructor(scene: Scene);
  92122. /**
  92123. * Adds all the assets from the container to the scene.
  92124. */
  92125. addAllToScene(): void;
  92126. /**
  92127. * Removes all the assets in the container from the scene
  92128. */
  92129. removeAllFromScene(): void;
  92130. /**
  92131. * Disposes all the assets in the container
  92132. */
  92133. dispose(): void;
  92134. private _moveAssets;
  92135. /**
  92136. * Removes all the assets contained in the scene and adds them to the container.
  92137. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92138. */
  92139. moveAllFromScene(keepAssets?: KeepAssets): void;
  92140. /**
  92141. * 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.
  92142. * @returns the root mesh
  92143. */
  92144. createRootMesh(): Mesh;
  92145. }
  92146. }
  92147. declare module BABYLON {
  92148. /**
  92149. * Defines how the parser contract is defined.
  92150. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92151. */
  92152. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92153. /**
  92154. * Defines how the individual parser contract is defined.
  92155. * These parser can parse an individual asset
  92156. */
  92157. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92158. /**
  92159. * Base class of the scene acting as a container for the different elements composing a scene.
  92160. * This class is dynamically extended by the different components of the scene increasing
  92161. * flexibility and reducing coupling
  92162. */
  92163. export abstract class AbstractScene {
  92164. /**
  92165. * Stores the list of available parsers in the application.
  92166. */
  92167. private static _BabylonFileParsers;
  92168. /**
  92169. * Stores the list of available individual parsers in the application.
  92170. */
  92171. private static _IndividualBabylonFileParsers;
  92172. /**
  92173. * Adds a parser in the list of available ones
  92174. * @param name Defines the name of the parser
  92175. * @param parser Defines the parser to add
  92176. */
  92177. static AddParser(name: string, parser: BabylonFileParser): void;
  92178. /**
  92179. * Gets a general parser from the list of avaialble ones
  92180. * @param name Defines the name of the parser
  92181. * @returns the requested parser or null
  92182. */
  92183. static GetParser(name: string): Nullable<BabylonFileParser>;
  92184. /**
  92185. * Adds n individual parser in the list of available ones
  92186. * @param name Defines the name of the parser
  92187. * @param parser Defines the parser to add
  92188. */
  92189. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92190. /**
  92191. * Gets an individual parser from the list of avaialble ones
  92192. * @param name Defines the name of the parser
  92193. * @returns the requested parser or null
  92194. */
  92195. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92196. /**
  92197. * Parser json data and populate both a scene and its associated container object
  92198. * @param jsonData Defines the data to parse
  92199. * @param scene Defines the scene to parse the data for
  92200. * @param container Defines the container attached to the parsing sequence
  92201. * @param rootUrl Defines the root url of the data
  92202. */
  92203. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92204. /**
  92205. * Gets the list of root nodes (ie. nodes with no parent)
  92206. */
  92207. rootNodes: Node[];
  92208. /** All of the cameras added to this scene
  92209. * @see http://doc.babylonjs.com/babylon101/cameras
  92210. */
  92211. cameras: Camera[];
  92212. /**
  92213. * All of the lights added to this scene
  92214. * @see http://doc.babylonjs.com/babylon101/lights
  92215. */
  92216. lights: Light[];
  92217. /**
  92218. * All of the (abstract) meshes added to this scene
  92219. */
  92220. meshes: AbstractMesh[];
  92221. /**
  92222. * The list of skeletons added to the scene
  92223. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92224. */
  92225. skeletons: Skeleton[];
  92226. /**
  92227. * All of the particle systems added to this scene
  92228. * @see http://doc.babylonjs.com/babylon101/particles
  92229. */
  92230. particleSystems: IParticleSystem[];
  92231. /**
  92232. * Gets a list of Animations associated with the scene
  92233. */
  92234. animations: Animation[];
  92235. /**
  92236. * All of the animation groups added to this scene
  92237. * @see http://doc.babylonjs.com/how_to/group
  92238. */
  92239. animationGroups: AnimationGroup[];
  92240. /**
  92241. * All of the multi-materials added to this scene
  92242. * @see http://doc.babylonjs.com/how_to/multi_materials
  92243. */
  92244. multiMaterials: MultiMaterial[];
  92245. /**
  92246. * All of the materials added to this scene
  92247. * In the context of a Scene, it is not supposed to be modified manually.
  92248. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  92249. * Note also that the order of the Material wihin the array is not significant and might change.
  92250. * @see http://doc.babylonjs.com/babylon101/materials
  92251. */
  92252. materials: Material[];
  92253. /**
  92254. * The list of morph target managers added to the scene
  92255. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  92256. */
  92257. morphTargetManagers: MorphTargetManager[];
  92258. /**
  92259. * The list of geometries used in the scene.
  92260. */
  92261. geometries: Geometry[];
  92262. /**
  92263. * All of the tranform nodes added to this scene
  92264. * In the context of a Scene, it is not supposed to be modified manually.
  92265. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  92266. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  92267. * @see http://doc.babylonjs.com/how_to/transformnode
  92268. */
  92269. transformNodes: TransformNode[];
  92270. /**
  92271. * ActionManagers available on the scene.
  92272. */
  92273. actionManagers: AbstractActionManager[];
  92274. /**
  92275. * Textures to keep.
  92276. */
  92277. textures: BaseTexture[];
  92278. /**
  92279. * Environment texture for the scene
  92280. */
  92281. environmentTexture: Nullable<BaseTexture>;
  92282. }
  92283. }
  92284. declare module BABYLON {
  92285. /**
  92286. * Defines a sound that can be played in the application.
  92287. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  92288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92289. */
  92290. export class Sound {
  92291. /**
  92292. * The name of the sound in the scene.
  92293. */
  92294. name: string;
  92295. /**
  92296. * Does the sound autoplay once loaded.
  92297. */
  92298. autoplay: boolean;
  92299. /**
  92300. * Does the sound loop after it finishes playing once.
  92301. */
  92302. loop: boolean;
  92303. /**
  92304. * Does the sound use a custom attenuation curve to simulate the falloff
  92305. * happening when the source gets further away from the camera.
  92306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92307. */
  92308. useCustomAttenuation: boolean;
  92309. /**
  92310. * The sound track id this sound belongs to.
  92311. */
  92312. soundTrackId: number;
  92313. /**
  92314. * Is this sound currently played.
  92315. */
  92316. isPlaying: boolean;
  92317. /**
  92318. * Is this sound currently paused.
  92319. */
  92320. isPaused: boolean;
  92321. /**
  92322. * Does this sound enables spatial sound.
  92323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92324. */
  92325. spatialSound: boolean;
  92326. /**
  92327. * Define the reference distance the sound should be heard perfectly.
  92328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92329. */
  92330. refDistance: number;
  92331. /**
  92332. * Define the roll off factor of spatial sounds.
  92333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92334. */
  92335. rolloffFactor: number;
  92336. /**
  92337. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  92338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92339. */
  92340. maxDistance: number;
  92341. /**
  92342. * Define the distance attenuation model the sound will follow.
  92343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92344. */
  92345. distanceModel: string;
  92346. /**
  92347. * @hidden
  92348. * Back Compat
  92349. **/
  92350. onended: () => any;
  92351. /**
  92352. * Observable event when the current playing sound finishes.
  92353. */
  92354. onEndedObservable: Observable<Sound>;
  92355. private _panningModel;
  92356. private _playbackRate;
  92357. private _streaming;
  92358. private _startTime;
  92359. private _startOffset;
  92360. private _position;
  92361. /** @hidden */
  92362. _positionInEmitterSpace: boolean;
  92363. private _localDirection;
  92364. private _volume;
  92365. private _isReadyToPlay;
  92366. private _isDirectional;
  92367. private _readyToPlayCallback;
  92368. private _audioBuffer;
  92369. private _soundSource;
  92370. private _streamingSource;
  92371. private _soundPanner;
  92372. private _soundGain;
  92373. private _inputAudioNode;
  92374. private _outputAudioNode;
  92375. private _coneInnerAngle;
  92376. private _coneOuterAngle;
  92377. private _coneOuterGain;
  92378. private _scene;
  92379. private _connectedTransformNode;
  92380. private _customAttenuationFunction;
  92381. private _registerFunc;
  92382. private _isOutputConnected;
  92383. private _htmlAudioElement;
  92384. private _urlType;
  92385. /** @hidden */
  92386. static _SceneComponentInitialization: (scene: Scene) => void;
  92387. /**
  92388. * Create a sound and attach it to a scene
  92389. * @param name Name of your sound
  92390. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  92391. * @param scene defines the scene the sound belongs to
  92392. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  92393. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  92394. */
  92395. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  92396. /**
  92397. * Release the sound and its associated resources
  92398. */
  92399. dispose(): void;
  92400. /**
  92401. * Gets if the sounds is ready to be played or not.
  92402. * @returns true if ready, otherwise false
  92403. */
  92404. isReady(): boolean;
  92405. private _soundLoaded;
  92406. /**
  92407. * Sets the data of the sound from an audiobuffer
  92408. * @param audioBuffer The audioBuffer containing the data
  92409. */
  92410. setAudioBuffer(audioBuffer: AudioBuffer): void;
  92411. /**
  92412. * Updates the current sounds options such as maxdistance, loop...
  92413. * @param options A JSON object containing values named as the object properties
  92414. */
  92415. updateOptions(options: any): void;
  92416. private _createSpatialParameters;
  92417. private _updateSpatialParameters;
  92418. /**
  92419. * Switch the panning model to HRTF:
  92420. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92422. */
  92423. switchPanningModelToHRTF(): void;
  92424. /**
  92425. * Switch the panning model to Equal Power:
  92426. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92428. */
  92429. switchPanningModelToEqualPower(): void;
  92430. private _switchPanningModel;
  92431. /**
  92432. * Connect this sound to a sound track audio node like gain...
  92433. * @param soundTrackAudioNode the sound track audio node to connect to
  92434. */
  92435. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  92436. /**
  92437. * Transform this sound into a directional source
  92438. * @param coneInnerAngle Size of the inner cone in degree
  92439. * @param coneOuterAngle Size of the outer cone in degree
  92440. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  92441. */
  92442. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  92443. /**
  92444. * Gets or sets the inner angle for the directional cone.
  92445. */
  92446. /**
  92447. * Gets or sets the inner angle for the directional cone.
  92448. */
  92449. directionalConeInnerAngle: number;
  92450. /**
  92451. * Gets or sets the outer angle for the directional cone.
  92452. */
  92453. /**
  92454. * Gets or sets the outer angle for the directional cone.
  92455. */
  92456. directionalConeOuterAngle: number;
  92457. /**
  92458. * Sets the position of the emitter if spatial sound is enabled
  92459. * @param newPosition Defines the new posisiton
  92460. */
  92461. setPosition(newPosition: Vector3): void;
  92462. /**
  92463. * Sets the local direction of the emitter if spatial sound is enabled
  92464. * @param newLocalDirection Defines the new local direction
  92465. */
  92466. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  92467. private _updateDirection;
  92468. /** @hidden */
  92469. updateDistanceFromListener(): void;
  92470. /**
  92471. * Sets a new custom attenuation function for the sound.
  92472. * @param callback Defines the function used for the attenuation
  92473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92474. */
  92475. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  92476. /**
  92477. * Play the sound
  92478. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  92479. * @param offset (optional) Start the sound setting it at a specific time
  92480. */
  92481. play(time?: number, offset?: number): void;
  92482. private _onended;
  92483. /**
  92484. * Stop the sound
  92485. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  92486. */
  92487. stop(time?: number): void;
  92488. /**
  92489. * Put the sound in pause
  92490. */
  92491. pause(): void;
  92492. /**
  92493. * Sets a dedicated volume for this sounds
  92494. * @param newVolume Define the new volume of the sound
  92495. * @param time Define in how long the sound should be at this value
  92496. */
  92497. setVolume(newVolume: number, time?: number): void;
  92498. /**
  92499. * Set the sound play back rate
  92500. * @param newPlaybackRate Define the playback rate the sound should be played at
  92501. */
  92502. setPlaybackRate(newPlaybackRate: number): void;
  92503. /**
  92504. * Gets the volume of the sound.
  92505. * @returns the volume of the sound
  92506. */
  92507. getVolume(): number;
  92508. /**
  92509. * Attach the sound to a dedicated mesh
  92510. * @param transformNode The transform node to connect the sound with
  92511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92512. */
  92513. attachToMesh(transformNode: TransformNode): void;
  92514. /**
  92515. * Detach the sound from the previously attached mesh
  92516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92517. */
  92518. detachFromMesh(): void;
  92519. private _onRegisterAfterWorldMatrixUpdate;
  92520. /**
  92521. * Clone the current sound in the scene.
  92522. * @returns the new sound clone
  92523. */
  92524. clone(): Nullable<Sound>;
  92525. /**
  92526. * Gets the current underlying audio buffer containing the data
  92527. * @returns the audio buffer
  92528. */
  92529. getAudioBuffer(): Nullable<AudioBuffer>;
  92530. /**
  92531. * Serializes the Sound in a JSON representation
  92532. * @returns the JSON representation of the sound
  92533. */
  92534. serialize(): any;
  92535. /**
  92536. * Parse a JSON representation of a sound to innstantiate in a given scene
  92537. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  92538. * @param scene Define the scene the new parsed sound should be created in
  92539. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  92540. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  92541. * @returns the newly parsed sound
  92542. */
  92543. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  92544. }
  92545. }
  92546. declare module BABYLON {
  92547. /**
  92548. * This defines an action helpful to play a defined sound on a triggered action.
  92549. */
  92550. export class PlaySoundAction extends Action {
  92551. private _sound;
  92552. /**
  92553. * Instantiate the action
  92554. * @param triggerOptions defines the trigger options
  92555. * @param sound defines the sound to play
  92556. * @param condition defines the trigger related conditions
  92557. */
  92558. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92559. /** @hidden */
  92560. _prepare(): void;
  92561. /**
  92562. * Execute the action and play the sound.
  92563. */
  92564. execute(): void;
  92565. /**
  92566. * Serializes the actions and its related information.
  92567. * @param parent defines the object to serialize in
  92568. * @returns the serialized object
  92569. */
  92570. serialize(parent: any): any;
  92571. }
  92572. /**
  92573. * This defines an action helpful to stop a defined sound on a triggered action.
  92574. */
  92575. export class StopSoundAction extends Action {
  92576. private _sound;
  92577. /**
  92578. * Instantiate the action
  92579. * @param triggerOptions defines the trigger options
  92580. * @param sound defines the sound to stop
  92581. * @param condition defines the trigger related conditions
  92582. */
  92583. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92584. /** @hidden */
  92585. _prepare(): void;
  92586. /**
  92587. * Execute the action and stop the sound.
  92588. */
  92589. execute(): void;
  92590. /**
  92591. * Serializes the actions and its related information.
  92592. * @param parent defines the object to serialize in
  92593. * @returns the serialized object
  92594. */
  92595. serialize(parent: any): any;
  92596. }
  92597. }
  92598. declare module BABYLON {
  92599. /**
  92600. * This defines an action responsible to change the value of a property
  92601. * by interpolating between its current value and the newly set one once triggered.
  92602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92603. */
  92604. export class InterpolateValueAction extends Action {
  92605. /**
  92606. * Defines the path of the property where the value should be interpolated
  92607. */
  92608. propertyPath: string;
  92609. /**
  92610. * Defines the target value at the end of the interpolation.
  92611. */
  92612. value: any;
  92613. /**
  92614. * Defines the time it will take for the property to interpolate to the value.
  92615. */
  92616. duration: number;
  92617. /**
  92618. * Defines if the other scene animations should be stopped when the action has been triggered
  92619. */
  92620. stopOtherAnimations?: boolean;
  92621. /**
  92622. * Defines a callback raised once the interpolation animation has been done.
  92623. */
  92624. onInterpolationDone?: () => void;
  92625. /**
  92626. * Observable triggered once the interpolation animation has been done.
  92627. */
  92628. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  92629. private _target;
  92630. private _effectiveTarget;
  92631. private _property;
  92632. /**
  92633. * Instantiate the action
  92634. * @param triggerOptions defines the trigger options
  92635. * @param target defines the object containing the value to interpolate
  92636. * @param propertyPath defines the path to the property in the target object
  92637. * @param value defines the target value at the end of the interpolation
  92638. * @param duration deines the time it will take for the property to interpolate to the value.
  92639. * @param condition defines the trigger related conditions
  92640. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  92641. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  92642. */
  92643. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  92644. /** @hidden */
  92645. _prepare(): void;
  92646. /**
  92647. * Execute the action starts the value interpolation.
  92648. */
  92649. execute(): void;
  92650. /**
  92651. * Serializes the actions and its related information.
  92652. * @param parent defines the object to serialize in
  92653. * @returns the serialized object
  92654. */
  92655. serialize(parent: any): any;
  92656. }
  92657. }
  92658. declare module BABYLON {
  92659. /**
  92660. * Options allowed during the creation of a sound track.
  92661. */
  92662. export interface ISoundTrackOptions {
  92663. /**
  92664. * The volume the sound track should take during creation
  92665. */
  92666. volume?: number;
  92667. /**
  92668. * Define if the sound track is the main sound track of the scene
  92669. */
  92670. mainTrack?: boolean;
  92671. }
  92672. /**
  92673. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  92674. * It will be also used in a future release to apply effects on a specific track.
  92675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92676. */
  92677. export class SoundTrack {
  92678. /**
  92679. * The unique identifier of the sound track in the scene.
  92680. */
  92681. id: number;
  92682. /**
  92683. * The list of sounds included in the sound track.
  92684. */
  92685. soundCollection: Array<Sound>;
  92686. private _outputAudioNode;
  92687. private _scene;
  92688. private _isMainTrack;
  92689. private _connectedAnalyser;
  92690. private _options;
  92691. private _isInitialized;
  92692. /**
  92693. * Creates a new sound track.
  92694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92695. * @param scene Define the scene the sound track belongs to
  92696. * @param options
  92697. */
  92698. constructor(scene: Scene, options?: ISoundTrackOptions);
  92699. private _initializeSoundTrackAudioGraph;
  92700. /**
  92701. * Release the sound track and its associated resources
  92702. */
  92703. dispose(): void;
  92704. /**
  92705. * Adds a sound to this sound track
  92706. * @param sound define the cound to add
  92707. * @ignoreNaming
  92708. */
  92709. AddSound(sound: Sound): void;
  92710. /**
  92711. * Removes a sound to this sound track
  92712. * @param sound define the cound to remove
  92713. * @ignoreNaming
  92714. */
  92715. RemoveSound(sound: Sound): void;
  92716. /**
  92717. * Set a global volume for the full sound track.
  92718. * @param newVolume Define the new volume of the sound track
  92719. */
  92720. setVolume(newVolume: number): void;
  92721. /**
  92722. * Switch the panning model to HRTF:
  92723. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92725. */
  92726. switchPanningModelToHRTF(): void;
  92727. /**
  92728. * Switch the panning model to Equal Power:
  92729. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92731. */
  92732. switchPanningModelToEqualPower(): void;
  92733. /**
  92734. * Connect the sound track to an audio analyser allowing some amazing
  92735. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92737. * @param analyser The analyser to connect to the engine
  92738. */
  92739. connectToAnalyser(analyser: Analyser): void;
  92740. }
  92741. }
  92742. declare module BABYLON {
  92743. interface AbstractScene {
  92744. /**
  92745. * The list of sounds used in the scene.
  92746. */
  92747. sounds: Nullable<Array<Sound>>;
  92748. }
  92749. interface Scene {
  92750. /**
  92751. * @hidden
  92752. * Backing field
  92753. */
  92754. _mainSoundTrack: SoundTrack;
  92755. /**
  92756. * The main sound track played by the scene.
  92757. * It cotains your primary collection of sounds.
  92758. */
  92759. mainSoundTrack: SoundTrack;
  92760. /**
  92761. * The list of sound tracks added to the scene
  92762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92763. */
  92764. soundTracks: Nullable<Array<SoundTrack>>;
  92765. /**
  92766. * Gets a sound using a given name
  92767. * @param name defines the name to search for
  92768. * @return the found sound or null if not found at all.
  92769. */
  92770. getSoundByName(name: string): Nullable<Sound>;
  92771. /**
  92772. * Gets or sets if audio support is enabled
  92773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92774. */
  92775. audioEnabled: boolean;
  92776. /**
  92777. * Gets or sets if audio will be output to headphones
  92778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92779. */
  92780. headphone: boolean;
  92781. }
  92782. /**
  92783. * Defines the sound scene component responsible to manage any sounds
  92784. * in a given scene.
  92785. */
  92786. export class AudioSceneComponent implements ISceneSerializableComponent {
  92787. /**
  92788. * The component name helpfull to identify the component in the list of scene components.
  92789. */
  92790. readonly name: string;
  92791. /**
  92792. * The scene the component belongs to.
  92793. */
  92794. scene: Scene;
  92795. private _audioEnabled;
  92796. /**
  92797. * Gets whether audio is enabled or not.
  92798. * Please use related enable/disable method to switch state.
  92799. */
  92800. readonly audioEnabled: boolean;
  92801. private _headphone;
  92802. /**
  92803. * Gets whether audio is outputing to headphone or not.
  92804. * Please use the according Switch methods to change output.
  92805. */
  92806. readonly headphone: boolean;
  92807. /**
  92808. * Creates a new instance of the component for the given scene
  92809. * @param scene Defines the scene to register the component in
  92810. */
  92811. constructor(scene: Scene);
  92812. /**
  92813. * Registers the component in a given scene
  92814. */
  92815. register(): void;
  92816. /**
  92817. * Rebuilds the elements related to this component in case of
  92818. * context lost for instance.
  92819. */
  92820. rebuild(): void;
  92821. /**
  92822. * Serializes the component data to the specified json object
  92823. * @param serializationObject The object to serialize to
  92824. */
  92825. serialize(serializationObject: any): void;
  92826. /**
  92827. * Adds all the element from the container to the scene
  92828. * @param container the container holding the elements
  92829. */
  92830. addFromContainer(container: AbstractScene): void;
  92831. /**
  92832. * Removes all the elements in the container from the scene
  92833. * @param container contains the elements to remove
  92834. * @param dispose if the removed element should be disposed (default: false)
  92835. */
  92836. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  92837. /**
  92838. * Disposes the component and the associated ressources.
  92839. */
  92840. dispose(): void;
  92841. /**
  92842. * Disables audio in the associated scene.
  92843. */
  92844. disableAudio(): void;
  92845. /**
  92846. * Enables audio in the associated scene.
  92847. */
  92848. enableAudio(): void;
  92849. /**
  92850. * Switch audio to headphone output.
  92851. */
  92852. switchAudioModeForHeadphones(): void;
  92853. /**
  92854. * Switch audio to normal speakers.
  92855. */
  92856. switchAudioModeForNormalSpeakers(): void;
  92857. private _afterRender;
  92858. }
  92859. }
  92860. declare module BABYLON {
  92861. /**
  92862. * Wraps one or more Sound objects and selects one with random weight for playback.
  92863. */
  92864. export class WeightedSound {
  92865. /** When true a Sound will be selected and played when the current playing Sound completes. */
  92866. loop: boolean;
  92867. private _coneInnerAngle;
  92868. private _coneOuterAngle;
  92869. private _volume;
  92870. /** A Sound is currently playing. */
  92871. isPlaying: boolean;
  92872. /** A Sound is currently paused. */
  92873. isPaused: boolean;
  92874. private _sounds;
  92875. private _weights;
  92876. private _currentIndex?;
  92877. /**
  92878. * Creates a new WeightedSound from the list of sounds given.
  92879. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  92880. * @param sounds Array of Sounds that will be selected from.
  92881. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  92882. */
  92883. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  92884. /**
  92885. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  92886. */
  92887. /**
  92888. * The size of cone in degress for a directional sound in which there will be no attenuation.
  92889. */
  92890. directionalConeInnerAngle: number;
  92891. /**
  92892. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92893. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92894. */
  92895. /**
  92896. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92897. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92898. */
  92899. directionalConeOuterAngle: number;
  92900. /**
  92901. * Playback volume.
  92902. */
  92903. /**
  92904. * Playback volume.
  92905. */
  92906. volume: number;
  92907. private _onended;
  92908. /**
  92909. * Suspend playback
  92910. */
  92911. pause(): void;
  92912. /**
  92913. * Stop playback
  92914. */
  92915. stop(): void;
  92916. /**
  92917. * Start playback.
  92918. * @param startOffset Position the clip head at a specific time in seconds.
  92919. */
  92920. play(startOffset?: number): void;
  92921. }
  92922. }
  92923. declare module BABYLON {
  92924. /**
  92925. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  92926. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92927. */
  92928. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  92929. /**
  92930. * Gets the name of the behavior.
  92931. */
  92932. readonly name: string;
  92933. /**
  92934. * The easing function used by animations
  92935. */
  92936. static EasingFunction: BackEase;
  92937. /**
  92938. * The easing mode used by animations
  92939. */
  92940. static EasingMode: number;
  92941. /**
  92942. * The duration of the animation, in milliseconds
  92943. */
  92944. transitionDuration: number;
  92945. /**
  92946. * Length of the distance animated by the transition when lower radius is reached
  92947. */
  92948. lowerRadiusTransitionRange: number;
  92949. /**
  92950. * Length of the distance animated by the transition when upper radius is reached
  92951. */
  92952. upperRadiusTransitionRange: number;
  92953. private _autoTransitionRange;
  92954. /**
  92955. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92956. */
  92957. /**
  92958. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92959. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  92960. */
  92961. autoTransitionRange: boolean;
  92962. private _attachedCamera;
  92963. private _onAfterCheckInputsObserver;
  92964. private _onMeshTargetChangedObserver;
  92965. /**
  92966. * Initializes the behavior.
  92967. */
  92968. init(): void;
  92969. /**
  92970. * Attaches the behavior to its arc rotate camera.
  92971. * @param camera Defines the camera to attach the behavior to
  92972. */
  92973. attach(camera: ArcRotateCamera): void;
  92974. /**
  92975. * Detaches the behavior from its current arc rotate camera.
  92976. */
  92977. detach(): void;
  92978. private _radiusIsAnimating;
  92979. private _radiusBounceTransition;
  92980. private _animatables;
  92981. private _cachedWheelPrecision;
  92982. /**
  92983. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  92984. * @param radiusLimit The limit to check against.
  92985. * @return Bool to indicate if at limit.
  92986. */
  92987. private _isRadiusAtLimit;
  92988. /**
  92989. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  92990. * @param radiusDelta The delta by which to animate to. Can be negative.
  92991. */
  92992. private _applyBoundRadiusAnimation;
  92993. /**
  92994. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  92995. */
  92996. protected _clearAnimationLocks(): void;
  92997. /**
  92998. * Stops and removes all animations that have been applied to the camera
  92999. */
  93000. stopAllAnimations(): void;
  93001. }
  93002. }
  93003. declare module BABYLON {
  93004. /**
  93005. * 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.
  93006. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93007. */
  93008. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93009. /**
  93010. * Gets the name of the behavior.
  93011. */
  93012. readonly name: string;
  93013. private _mode;
  93014. private _radiusScale;
  93015. private _positionScale;
  93016. private _defaultElevation;
  93017. private _elevationReturnTime;
  93018. private _elevationReturnWaitTime;
  93019. private _zoomStopsAnimation;
  93020. private _framingTime;
  93021. /**
  93022. * The easing function used by animations
  93023. */
  93024. static EasingFunction: ExponentialEase;
  93025. /**
  93026. * The easing mode used by animations
  93027. */
  93028. static EasingMode: number;
  93029. /**
  93030. * Sets the current mode used by the behavior
  93031. */
  93032. /**
  93033. * Gets current mode used by the behavior.
  93034. */
  93035. mode: number;
  93036. /**
  93037. * Sets the scale applied to the radius (1 by default)
  93038. */
  93039. /**
  93040. * Gets the scale applied to the radius
  93041. */
  93042. radiusScale: number;
  93043. /**
  93044. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93045. */
  93046. /**
  93047. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93048. */
  93049. positionScale: number;
  93050. /**
  93051. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93052. * behaviour is triggered, in radians.
  93053. */
  93054. /**
  93055. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93056. * behaviour is triggered, in radians.
  93057. */
  93058. defaultElevation: number;
  93059. /**
  93060. * Sets the time (in milliseconds) taken to return to the default beta position.
  93061. * Negative value indicates camera should not return to default.
  93062. */
  93063. /**
  93064. * Gets the time (in milliseconds) taken to return to the default beta position.
  93065. * Negative value indicates camera should not return to default.
  93066. */
  93067. elevationReturnTime: number;
  93068. /**
  93069. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93070. */
  93071. /**
  93072. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93073. */
  93074. elevationReturnWaitTime: number;
  93075. /**
  93076. * Sets the flag that indicates if user zooming should stop animation.
  93077. */
  93078. /**
  93079. * Gets the flag that indicates if user zooming should stop animation.
  93080. */
  93081. zoomStopsAnimation: boolean;
  93082. /**
  93083. * Sets the transition time when framing the mesh, in milliseconds
  93084. */
  93085. /**
  93086. * Gets the transition time when framing the mesh, in milliseconds
  93087. */
  93088. framingTime: number;
  93089. /**
  93090. * Define if the behavior should automatically change the configured
  93091. * camera limits and sensibilities.
  93092. */
  93093. autoCorrectCameraLimitsAndSensibility: boolean;
  93094. private _onPrePointerObservableObserver;
  93095. private _onAfterCheckInputsObserver;
  93096. private _onMeshTargetChangedObserver;
  93097. private _attachedCamera;
  93098. private _isPointerDown;
  93099. private _lastInteractionTime;
  93100. /**
  93101. * Initializes the behavior.
  93102. */
  93103. init(): void;
  93104. /**
  93105. * Attaches the behavior to its arc rotate camera.
  93106. * @param camera Defines the camera to attach the behavior to
  93107. */
  93108. attach(camera: ArcRotateCamera): void;
  93109. /**
  93110. * Detaches the behavior from its current arc rotate camera.
  93111. */
  93112. detach(): void;
  93113. private _animatables;
  93114. private _betaIsAnimating;
  93115. private _betaTransition;
  93116. private _radiusTransition;
  93117. private _vectorTransition;
  93118. /**
  93119. * Targets the given mesh and updates zoom level accordingly.
  93120. * @param mesh The mesh to target.
  93121. * @param radius Optional. If a cached radius position already exists, overrides default.
  93122. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93123. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93124. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93125. */
  93126. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93127. /**
  93128. * Targets the given mesh with its children and updates zoom level accordingly.
  93129. * @param mesh The mesh to target.
  93130. * @param radius Optional. If a cached radius position already exists, overrides default.
  93131. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93132. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93133. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93134. */
  93135. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93136. /**
  93137. * Targets the given meshes with their children and updates zoom level accordingly.
  93138. * @param meshes The mesh to target.
  93139. * @param radius Optional. If a cached radius position already exists, overrides default.
  93140. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93141. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93142. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93143. */
  93144. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93145. /**
  93146. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93147. * @param minimumWorld Determines the smaller position of the bounding box extend
  93148. * @param maximumWorld Determines the bigger position of the bounding box extend
  93149. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93150. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93151. */
  93152. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93153. /**
  93154. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93155. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93156. * frustum width.
  93157. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93158. * to fully enclose the mesh in the viewing frustum.
  93159. */
  93160. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93161. /**
  93162. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93163. * is automatically returned to its default position (expected to be above ground plane).
  93164. */
  93165. private _maintainCameraAboveGround;
  93166. /**
  93167. * Returns the frustum slope based on the canvas ratio and camera FOV
  93168. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93169. */
  93170. private _getFrustumSlope;
  93171. /**
  93172. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93173. */
  93174. private _clearAnimationLocks;
  93175. /**
  93176. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93177. */
  93178. private _applyUserInteraction;
  93179. /**
  93180. * Stops and removes all animations that have been applied to the camera
  93181. */
  93182. stopAllAnimations(): void;
  93183. /**
  93184. * Gets a value indicating if the user is moving the camera
  93185. */
  93186. readonly isUserIsMoving: boolean;
  93187. /**
  93188. * The camera can move all the way towards the mesh.
  93189. */
  93190. static IgnoreBoundsSizeMode: number;
  93191. /**
  93192. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93193. */
  93194. static FitFrustumSidesMode: number;
  93195. }
  93196. }
  93197. declare module BABYLON {
  93198. /**
  93199. * Base class for Camera Pointer Inputs.
  93200. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93201. * for example usage.
  93202. */
  93203. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93204. /**
  93205. * Defines the camera the input is attached to.
  93206. */
  93207. abstract camera: Camera;
  93208. /**
  93209. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93210. */
  93211. protected _altKey: boolean;
  93212. protected _ctrlKey: boolean;
  93213. protected _metaKey: boolean;
  93214. protected _shiftKey: boolean;
  93215. /**
  93216. * Which mouse buttons were pressed at time of last mouse event.
  93217. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  93218. */
  93219. protected _buttonsPressed: number;
  93220. /**
  93221. * Defines the buttons associated with the input to handle camera move.
  93222. */
  93223. buttons: number[];
  93224. /**
  93225. * Attach the input controls to a specific dom element to get the input from.
  93226. * @param element Defines the element the controls should be listened from
  93227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93228. */
  93229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93230. /**
  93231. * Detach the current controls from the specified dom element.
  93232. * @param element Defines the element to stop listening the inputs from
  93233. */
  93234. detachControl(element: Nullable<HTMLElement>): void;
  93235. /**
  93236. * Gets the class name of the current input.
  93237. * @returns the class name
  93238. */
  93239. getClassName(): string;
  93240. /**
  93241. * Get the friendly name associated with the input class.
  93242. * @returns the input friendly name
  93243. */
  93244. getSimpleName(): string;
  93245. /**
  93246. * Called on pointer POINTERDOUBLETAP event.
  93247. * Override this method to provide functionality on POINTERDOUBLETAP event.
  93248. */
  93249. protected onDoubleTap(type: string): void;
  93250. /**
  93251. * Called on pointer POINTERMOVE event if only a single touch is active.
  93252. * Override this method to provide functionality.
  93253. */
  93254. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93255. /**
  93256. * Called on pointer POINTERMOVE event if multiple touches are active.
  93257. * Override this method to provide functionality.
  93258. */
  93259. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93260. /**
  93261. * Called on JS contextmenu event.
  93262. * Override this method to provide functionality.
  93263. */
  93264. protected onContextMenu(evt: PointerEvent): void;
  93265. /**
  93266. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93267. * press.
  93268. * Override this method to provide functionality.
  93269. */
  93270. protected onButtonDown(evt: PointerEvent): void;
  93271. /**
  93272. * Called each time a new POINTERUP event occurs. Ie, for each button
  93273. * release.
  93274. * Override this method to provide functionality.
  93275. */
  93276. protected onButtonUp(evt: PointerEvent): void;
  93277. /**
  93278. * Called when window becomes inactive.
  93279. * Override this method to provide functionality.
  93280. */
  93281. protected onLostFocus(): void;
  93282. private _pointerInput;
  93283. private _observer;
  93284. private _onLostFocus;
  93285. private pointA;
  93286. private pointB;
  93287. }
  93288. }
  93289. declare module BABYLON {
  93290. /**
  93291. * Manage the pointers inputs to control an arc rotate camera.
  93292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93293. */
  93294. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  93295. /**
  93296. * Defines the camera the input is attached to.
  93297. */
  93298. camera: ArcRotateCamera;
  93299. /**
  93300. * Gets the class name of the current input.
  93301. * @returns the class name
  93302. */
  93303. getClassName(): string;
  93304. /**
  93305. * Defines the buttons associated with the input to handle camera move.
  93306. */
  93307. buttons: number[];
  93308. /**
  93309. * Defines the pointer angular sensibility along the X axis or how fast is
  93310. * the camera rotating.
  93311. */
  93312. angularSensibilityX: number;
  93313. /**
  93314. * Defines the pointer angular sensibility along the Y axis or how fast is
  93315. * the camera rotating.
  93316. */
  93317. angularSensibilityY: number;
  93318. /**
  93319. * Defines the pointer pinch precision or how fast is the camera zooming.
  93320. */
  93321. pinchPrecision: number;
  93322. /**
  93323. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93324. * from 0.
  93325. * It defines the percentage of current camera.radius to use as delta when
  93326. * pinch zoom is used.
  93327. */
  93328. pinchDeltaPercentage: number;
  93329. /**
  93330. * Defines the pointer panning sensibility or how fast is the camera moving.
  93331. */
  93332. panningSensibility: number;
  93333. /**
  93334. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  93335. */
  93336. multiTouchPanning: boolean;
  93337. /**
  93338. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  93339. * zoom (pinch) through multitouch.
  93340. */
  93341. multiTouchPanAndZoom: boolean;
  93342. /**
  93343. * Revers pinch action direction.
  93344. */
  93345. pinchInwards: boolean;
  93346. private _isPanClick;
  93347. private _twoFingerActivityCount;
  93348. private _isPinching;
  93349. /**
  93350. * Called on pointer POINTERMOVE event if only a single touch is active.
  93351. */
  93352. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93353. /**
  93354. * Called on pointer POINTERDOUBLETAP event.
  93355. */
  93356. protected onDoubleTap(type: string): void;
  93357. /**
  93358. * Called on pointer POINTERMOVE event if multiple touches are active.
  93359. */
  93360. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93361. /**
  93362. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93363. * press.
  93364. */
  93365. protected onButtonDown(evt: PointerEvent): void;
  93366. /**
  93367. * Called each time a new POINTERUP event occurs. Ie, for each button
  93368. * release.
  93369. */
  93370. protected onButtonUp(evt: PointerEvent): void;
  93371. /**
  93372. * Called when window becomes inactive.
  93373. */
  93374. protected onLostFocus(): void;
  93375. }
  93376. }
  93377. declare module BABYLON {
  93378. /**
  93379. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  93380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93381. */
  93382. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  93383. /**
  93384. * Defines the camera the input is attached to.
  93385. */
  93386. camera: ArcRotateCamera;
  93387. /**
  93388. * Defines the list of key codes associated with the up action (increase alpha)
  93389. */
  93390. keysUp: number[];
  93391. /**
  93392. * Defines the list of key codes associated with the down action (decrease alpha)
  93393. */
  93394. keysDown: number[];
  93395. /**
  93396. * Defines the list of key codes associated with the left action (increase beta)
  93397. */
  93398. keysLeft: number[];
  93399. /**
  93400. * Defines the list of key codes associated with the right action (decrease beta)
  93401. */
  93402. keysRight: number[];
  93403. /**
  93404. * Defines the list of key codes associated with the reset action.
  93405. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  93406. */
  93407. keysReset: number[];
  93408. /**
  93409. * Defines the panning sensibility of the inputs.
  93410. * (How fast is the camera paning)
  93411. */
  93412. panningSensibility: number;
  93413. /**
  93414. * Defines the zooming sensibility of the inputs.
  93415. * (How fast is the camera zooming)
  93416. */
  93417. zoomingSensibility: number;
  93418. /**
  93419. * Defines wether maintaining the alt key down switch the movement mode from
  93420. * orientation to zoom.
  93421. */
  93422. useAltToZoom: boolean;
  93423. /**
  93424. * Rotation speed of the camera
  93425. */
  93426. angularSpeed: number;
  93427. private _keys;
  93428. private _ctrlPressed;
  93429. private _altPressed;
  93430. private _onCanvasBlurObserver;
  93431. private _onKeyboardObserver;
  93432. private _engine;
  93433. private _scene;
  93434. /**
  93435. * Attach the input controls to a specific dom element to get the input from.
  93436. * @param element Defines the element the controls should be listened from
  93437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93438. */
  93439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93440. /**
  93441. * Detach the current controls from the specified dom element.
  93442. * @param element Defines the element to stop listening the inputs from
  93443. */
  93444. detachControl(element: Nullable<HTMLElement>): void;
  93445. /**
  93446. * Update the current camera state depending on the inputs that have been used this frame.
  93447. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93448. */
  93449. checkInputs(): void;
  93450. /**
  93451. * Gets the class name of the current intput.
  93452. * @returns the class name
  93453. */
  93454. getClassName(): string;
  93455. /**
  93456. * Get the friendly name associated with the input class.
  93457. * @returns the input friendly name
  93458. */
  93459. getSimpleName(): string;
  93460. }
  93461. }
  93462. declare module BABYLON {
  93463. /**
  93464. * Manage the mouse wheel inputs to control an arc rotate camera.
  93465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93466. */
  93467. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  93468. /**
  93469. * Defines the camera the input is attached to.
  93470. */
  93471. camera: ArcRotateCamera;
  93472. /**
  93473. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93474. */
  93475. wheelPrecision: number;
  93476. /**
  93477. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93478. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93479. */
  93480. wheelDeltaPercentage: number;
  93481. private _wheel;
  93482. private _observer;
  93483. /**
  93484. * Attach the input controls to a specific dom element to get the input from.
  93485. * @param element Defines the element the controls should be listened from
  93486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93487. */
  93488. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93489. /**
  93490. * Detach the current controls from the specified dom element.
  93491. * @param element Defines the element to stop listening the inputs from
  93492. */
  93493. detachControl(element: Nullable<HTMLElement>): void;
  93494. /**
  93495. * Gets the class name of the current intput.
  93496. * @returns the class name
  93497. */
  93498. getClassName(): string;
  93499. /**
  93500. * Get the friendly name associated with the input class.
  93501. * @returns the input friendly name
  93502. */
  93503. getSimpleName(): string;
  93504. }
  93505. }
  93506. declare module BABYLON {
  93507. /**
  93508. * Default Inputs manager for the ArcRotateCamera.
  93509. * It groups all the default supported inputs for ease of use.
  93510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93511. */
  93512. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  93513. /**
  93514. * Instantiates a new ArcRotateCameraInputsManager.
  93515. * @param camera Defines the camera the inputs belong to
  93516. */
  93517. constructor(camera: ArcRotateCamera);
  93518. /**
  93519. * Add mouse wheel input support to the input manager.
  93520. * @returns the current input manager
  93521. */
  93522. addMouseWheel(): ArcRotateCameraInputsManager;
  93523. /**
  93524. * Add pointers input support to the input manager.
  93525. * @returns the current input manager
  93526. */
  93527. addPointers(): ArcRotateCameraInputsManager;
  93528. /**
  93529. * Add keyboard input support to the input manager.
  93530. * @returns the current input manager
  93531. */
  93532. addKeyboard(): ArcRotateCameraInputsManager;
  93533. }
  93534. }
  93535. declare module BABYLON {
  93536. /**
  93537. * This represents an orbital type of camera.
  93538. *
  93539. * 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.
  93540. * 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.
  93541. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  93542. */
  93543. export class ArcRotateCamera extends TargetCamera {
  93544. /**
  93545. * Defines the rotation angle of the camera along the longitudinal axis.
  93546. */
  93547. alpha: number;
  93548. /**
  93549. * Defines the rotation angle of the camera along the latitudinal axis.
  93550. */
  93551. beta: number;
  93552. /**
  93553. * Defines the radius of the camera from it s target point.
  93554. */
  93555. radius: number;
  93556. protected _target: Vector3;
  93557. protected _targetHost: Nullable<AbstractMesh>;
  93558. /**
  93559. * Defines the target point of the camera.
  93560. * The camera looks towards it form the radius distance.
  93561. */
  93562. target: Vector3;
  93563. /**
  93564. * Define the current local position of the camera in the scene
  93565. */
  93566. position: Vector3;
  93567. /**
  93568. * Current inertia value on the longitudinal axis.
  93569. * The bigger this number the longer it will take for the camera to stop.
  93570. */
  93571. inertialAlphaOffset: number;
  93572. /**
  93573. * Current inertia value on the latitudinal axis.
  93574. * The bigger this number the longer it will take for the camera to stop.
  93575. */
  93576. inertialBetaOffset: number;
  93577. /**
  93578. * Current inertia value on the radius axis.
  93579. * The bigger this number the longer it will take for the camera to stop.
  93580. */
  93581. inertialRadiusOffset: number;
  93582. /**
  93583. * Minimum allowed angle on the longitudinal axis.
  93584. * This can help limiting how the Camera is able to move in the scene.
  93585. */
  93586. lowerAlphaLimit: Nullable<number>;
  93587. /**
  93588. * Maximum allowed angle on the longitudinal axis.
  93589. * This can help limiting how the Camera is able to move in the scene.
  93590. */
  93591. upperAlphaLimit: Nullable<number>;
  93592. /**
  93593. * Minimum allowed angle on the latitudinal axis.
  93594. * This can help limiting how the Camera is able to move in the scene.
  93595. */
  93596. lowerBetaLimit: number;
  93597. /**
  93598. * Maximum allowed angle on the latitudinal axis.
  93599. * This can help limiting how the Camera is able to move in the scene.
  93600. */
  93601. upperBetaLimit: number;
  93602. /**
  93603. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  93604. * This can help limiting how the Camera is able to move in the scene.
  93605. */
  93606. lowerRadiusLimit: Nullable<number>;
  93607. /**
  93608. * Maximum allowed distance of the camera to the target (The camera can not get further).
  93609. * This can help limiting how the Camera is able to move in the scene.
  93610. */
  93611. upperRadiusLimit: Nullable<number>;
  93612. /**
  93613. * Defines the current inertia value used during panning of the camera along the X axis.
  93614. */
  93615. inertialPanningX: number;
  93616. /**
  93617. * Defines the current inertia value used during panning of the camera along the Y axis.
  93618. */
  93619. inertialPanningY: number;
  93620. /**
  93621. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  93622. * Basically if your fingers moves away from more than this distance you will be considered
  93623. * in pinch mode.
  93624. */
  93625. pinchToPanMaxDistance: number;
  93626. /**
  93627. * Defines the maximum distance the camera can pan.
  93628. * This could help keeping the cammera always in your scene.
  93629. */
  93630. panningDistanceLimit: Nullable<number>;
  93631. /**
  93632. * Defines the target of the camera before paning.
  93633. */
  93634. panningOriginTarget: Vector3;
  93635. /**
  93636. * Defines the value of the inertia used during panning.
  93637. * 0 would mean stop inertia and one would mean no decelleration at all.
  93638. */
  93639. panningInertia: number;
  93640. /**
  93641. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  93642. */
  93643. angularSensibilityX: number;
  93644. /**
  93645. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  93646. */
  93647. angularSensibilityY: number;
  93648. /**
  93649. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  93650. */
  93651. pinchPrecision: number;
  93652. /**
  93653. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  93654. * It will be used instead of pinchDeltaPrecision if different from 0.
  93655. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93656. */
  93657. pinchDeltaPercentage: number;
  93658. /**
  93659. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  93660. */
  93661. panningSensibility: number;
  93662. /**
  93663. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  93664. */
  93665. keysUp: number[];
  93666. /**
  93667. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  93668. */
  93669. keysDown: number[];
  93670. /**
  93671. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  93672. */
  93673. keysLeft: number[];
  93674. /**
  93675. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  93676. */
  93677. keysRight: number[];
  93678. /**
  93679. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93680. */
  93681. wheelPrecision: number;
  93682. /**
  93683. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  93684. * It will be used instead of pinchDeltaPrecision if different from 0.
  93685. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93686. */
  93687. wheelDeltaPercentage: number;
  93688. /**
  93689. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  93690. */
  93691. zoomOnFactor: number;
  93692. /**
  93693. * Defines a screen offset for the camera position.
  93694. */
  93695. targetScreenOffset: Vector2;
  93696. /**
  93697. * Allows the camera to be completely reversed.
  93698. * If false the camera can not arrive upside down.
  93699. */
  93700. allowUpsideDown: boolean;
  93701. /**
  93702. * Define if double tap/click is used to restore the previously saved state of the camera.
  93703. */
  93704. useInputToRestoreState: boolean;
  93705. /** @hidden */
  93706. _viewMatrix: Matrix;
  93707. /** @hidden */
  93708. _useCtrlForPanning: boolean;
  93709. /** @hidden */
  93710. _panningMouseButton: number;
  93711. /**
  93712. * Defines the input associated to the camera.
  93713. */
  93714. inputs: ArcRotateCameraInputsManager;
  93715. /** @hidden */
  93716. _reset: () => void;
  93717. /**
  93718. * Defines the allowed panning axis.
  93719. */
  93720. panningAxis: Vector3;
  93721. protected _localDirection: Vector3;
  93722. protected _transformedDirection: Vector3;
  93723. private _bouncingBehavior;
  93724. /**
  93725. * Gets the bouncing behavior of the camera if it has been enabled.
  93726. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93727. */
  93728. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  93729. /**
  93730. * Defines if the bouncing behavior of the camera is enabled on the camera.
  93731. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93732. */
  93733. useBouncingBehavior: boolean;
  93734. private _framingBehavior;
  93735. /**
  93736. * Gets the framing behavior of the camera if it has been enabled.
  93737. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93738. */
  93739. readonly framingBehavior: Nullable<FramingBehavior>;
  93740. /**
  93741. * Defines if the framing behavior of the camera is enabled on the camera.
  93742. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93743. */
  93744. useFramingBehavior: boolean;
  93745. private _autoRotationBehavior;
  93746. /**
  93747. * Gets the auto rotation behavior of the camera if it has been enabled.
  93748. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93749. */
  93750. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  93751. /**
  93752. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  93753. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93754. */
  93755. useAutoRotationBehavior: boolean;
  93756. /**
  93757. * Observable triggered when the mesh target has been changed on the camera.
  93758. */
  93759. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  93760. /**
  93761. * Event raised when the camera is colliding with a mesh.
  93762. */
  93763. onCollide: (collidedMesh: AbstractMesh) => void;
  93764. /**
  93765. * Defines whether the camera should check collision with the objects oh the scene.
  93766. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  93767. */
  93768. checkCollisions: boolean;
  93769. /**
  93770. * Defines the collision radius of the camera.
  93771. * This simulates a sphere around the camera.
  93772. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93773. */
  93774. collisionRadius: Vector3;
  93775. protected _collider: Collider;
  93776. protected _previousPosition: Vector3;
  93777. protected _collisionVelocity: Vector3;
  93778. protected _newPosition: Vector3;
  93779. protected _previousAlpha: number;
  93780. protected _previousBeta: number;
  93781. protected _previousRadius: number;
  93782. protected _collisionTriggered: boolean;
  93783. protected _targetBoundingCenter: Nullable<Vector3>;
  93784. private _computationVector;
  93785. private _tempAxisVector;
  93786. private _tempAxisRotationMatrix;
  93787. /**
  93788. * Instantiates a new ArcRotateCamera in a given scene
  93789. * @param name Defines the name of the camera
  93790. * @param alpha Defines the camera rotation along the logitudinal axis
  93791. * @param beta Defines the camera rotation along the latitudinal axis
  93792. * @param radius Defines the camera distance from its target
  93793. * @param target Defines the camera target
  93794. * @param scene Defines the scene the camera belongs to
  93795. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  93796. */
  93797. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93798. /** @hidden */
  93799. _initCache(): void;
  93800. /** @hidden */
  93801. _updateCache(ignoreParentClass?: boolean): void;
  93802. protected _getTargetPosition(): Vector3;
  93803. private _storedAlpha;
  93804. private _storedBeta;
  93805. private _storedRadius;
  93806. private _storedTarget;
  93807. /**
  93808. * Stores the current state of the camera (alpha, beta, radius and target)
  93809. * @returns the camera itself
  93810. */
  93811. storeState(): Camera;
  93812. /**
  93813. * @hidden
  93814. * Restored camera state. You must call storeState() first
  93815. */
  93816. _restoreStateValues(): boolean;
  93817. /** @hidden */
  93818. _isSynchronizedViewMatrix(): boolean;
  93819. /**
  93820. * Attached controls to the current camera.
  93821. * @param element Defines the element the controls should be listened from
  93822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93823. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  93824. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  93825. */
  93826. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  93827. /**
  93828. * Detach the current controls from the camera.
  93829. * The camera will stop reacting to inputs.
  93830. * @param element Defines the element to stop listening the inputs from
  93831. */
  93832. detachControl(element: HTMLElement): void;
  93833. /** @hidden */
  93834. _checkInputs(): void;
  93835. protected _checkLimits(): void;
  93836. /**
  93837. * Rebuilds angles (alpha, beta) and radius from the give position and target
  93838. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  93839. */
  93840. rebuildAnglesAndRadius(updateView?: boolean): void;
  93841. /**
  93842. * Use a position to define the current camera related information like aplha, beta and radius
  93843. * @param position Defines the position to set the camera at
  93844. */
  93845. setPosition(position: Vector3): void;
  93846. /**
  93847. * Defines the target the camera should look at.
  93848. * This will automatically adapt alpha beta and radius to fit within the new target.
  93849. * @param target Defines the new target as a Vector or a mesh
  93850. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  93851. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  93852. */
  93853. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  93854. /** @hidden */
  93855. _getViewMatrix(): Matrix;
  93856. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  93857. /**
  93858. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  93859. * @param meshes Defines the mesh to zoom on
  93860. * @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)
  93861. */
  93862. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  93863. /**
  93864. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  93865. * The target will be changed but the radius
  93866. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  93867. * @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)
  93868. */
  93869. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  93870. min: Vector3;
  93871. max: Vector3;
  93872. distance: number;
  93873. }, doNotUpdateMaxZ?: boolean): void;
  93874. /**
  93875. * @override
  93876. * Override Camera.createRigCamera
  93877. */
  93878. createRigCamera(name: string, cameraIndex: number): Camera;
  93879. /**
  93880. * @hidden
  93881. * @override
  93882. * Override Camera._updateRigCameras
  93883. */
  93884. _updateRigCameras(): void;
  93885. /**
  93886. * Destroy the camera and release the current resources hold by it.
  93887. */
  93888. dispose(): void;
  93889. /**
  93890. * Gets the current object class name.
  93891. * @return the class name
  93892. */
  93893. getClassName(): string;
  93894. }
  93895. }
  93896. declare module BABYLON {
  93897. /**
  93898. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  93899. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93900. */
  93901. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  93902. /**
  93903. * Gets the name of the behavior.
  93904. */
  93905. readonly name: string;
  93906. private _zoomStopsAnimation;
  93907. private _idleRotationSpeed;
  93908. private _idleRotationWaitTime;
  93909. private _idleRotationSpinupTime;
  93910. /**
  93911. * Sets the flag that indicates if user zooming should stop animation.
  93912. */
  93913. /**
  93914. * Gets the flag that indicates if user zooming should stop animation.
  93915. */
  93916. zoomStopsAnimation: boolean;
  93917. /**
  93918. * Sets the default speed at which the camera rotates around the model.
  93919. */
  93920. /**
  93921. * Gets the default speed at which the camera rotates around the model.
  93922. */
  93923. idleRotationSpeed: number;
  93924. /**
  93925. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  93926. */
  93927. /**
  93928. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  93929. */
  93930. idleRotationWaitTime: number;
  93931. /**
  93932. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93933. */
  93934. /**
  93935. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93936. */
  93937. idleRotationSpinupTime: number;
  93938. /**
  93939. * Gets a value indicating if the camera is currently rotating because of this behavior
  93940. */
  93941. readonly rotationInProgress: boolean;
  93942. private _onPrePointerObservableObserver;
  93943. private _onAfterCheckInputsObserver;
  93944. private _attachedCamera;
  93945. private _isPointerDown;
  93946. private _lastFrameTime;
  93947. private _lastInteractionTime;
  93948. private _cameraRotationSpeed;
  93949. /**
  93950. * Initializes the behavior.
  93951. */
  93952. init(): void;
  93953. /**
  93954. * Attaches the behavior to its arc rotate camera.
  93955. * @param camera Defines the camera to attach the behavior to
  93956. */
  93957. attach(camera: ArcRotateCamera): void;
  93958. /**
  93959. * Detaches the behavior from its current arc rotate camera.
  93960. */
  93961. detach(): void;
  93962. /**
  93963. * Returns true if user is scrolling.
  93964. * @return true if user is scrolling.
  93965. */
  93966. private _userIsZooming;
  93967. private _lastFrameRadius;
  93968. private _shouldAnimationStopForInteraction;
  93969. /**
  93970. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93971. */
  93972. private _applyUserInteraction;
  93973. private _userIsMoving;
  93974. }
  93975. }
  93976. declare module BABYLON {
  93977. /**
  93978. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  93979. */
  93980. export class AttachToBoxBehavior implements Behavior<Mesh> {
  93981. private ui;
  93982. /**
  93983. * The name of the behavior
  93984. */
  93985. name: string;
  93986. /**
  93987. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  93988. */
  93989. distanceAwayFromFace: number;
  93990. /**
  93991. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  93992. */
  93993. distanceAwayFromBottomOfFace: number;
  93994. private _faceVectors;
  93995. private _target;
  93996. private _scene;
  93997. private _onRenderObserver;
  93998. private _tmpMatrix;
  93999. private _tmpVector;
  94000. /**
  94001. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94002. * @param ui The transform node that should be attched to the mesh
  94003. */
  94004. constructor(ui: TransformNode);
  94005. /**
  94006. * Initializes the behavior
  94007. */
  94008. init(): void;
  94009. private _closestFace;
  94010. private _zeroVector;
  94011. private _lookAtTmpMatrix;
  94012. private _lookAtToRef;
  94013. /**
  94014. * Attaches the AttachToBoxBehavior to the passed in mesh
  94015. * @param target The mesh that the specified node will be attached to
  94016. */
  94017. attach(target: Mesh): void;
  94018. /**
  94019. * Detaches the behavior from the mesh
  94020. */
  94021. detach(): void;
  94022. }
  94023. }
  94024. declare module BABYLON {
  94025. /**
  94026. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94027. */
  94028. export class FadeInOutBehavior implements Behavior<Mesh> {
  94029. /**
  94030. * Time in milliseconds to delay before fading in (Default: 0)
  94031. */
  94032. delay: number;
  94033. /**
  94034. * Time in milliseconds for the mesh to fade in (Default: 300)
  94035. */
  94036. fadeInTime: number;
  94037. private _millisecondsPerFrame;
  94038. private _hovered;
  94039. private _hoverValue;
  94040. private _ownerNode;
  94041. /**
  94042. * Instatiates the FadeInOutBehavior
  94043. */
  94044. constructor();
  94045. /**
  94046. * The name of the behavior
  94047. */
  94048. readonly name: string;
  94049. /**
  94050. * Initializes the behavior
  94051. */
  94052. init(): void;
  94053. /**
  94054. * Attaches the fade behavior on the passed in mesh
  94055. * @param ownerNode The mesh that will be faded in/out once attached
  94056. */
  94057. attach(ownerNode: Mesh): void;
  94058. /**
  94059. * Detaches the behavior from the mesh
  94060. */
  94061. detach(): void;
  94062. /**
  94063. * Triggers the mesh to begin fading in or out
  94064. * @param value if the object should fade in or out (true to fade in)
  94065. */
  94066. fadeIn(value: boolean): void;
  94067. private _update;
  94068. private _setAllVisibility;
  94069. }
  94070. }
  94071. declare module BABYLON {
  94072. /**
  94073. * Class containing a set of static utilities functions for managing Pivots
  94074. * @hidden
  94075. */
  94076. export class PivotTools {
  94077. private static _PivotCached;
  94078. private static _OldPivotPoint;
  94079. private static _PivotTranslation;
  94080. private static _PivotTmpVector;
  94081. /** @hidden */
  94082. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94083. /** @hidden */
  94084. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94085. }
  94086. }
  94087. declare module BABYLON {
  94088. /**
  94089. * Class containing static functions to help procedurally build meshes
  94090. */
  94091. export class PlaneBuilder {
  94092. /**
  94093. * Creates a plane mesh
  94094. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94095. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94096. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94100. * @param name defines the name of the mesh
  94101. * @param options defines the options used to create the mesh
  94102. * @param scene defines the hosting scene
  94103. * @returns the plane mesh
  94104. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94105. */
  94106. static CreatePlane(name: string, options: {
  94107. size?: number;
  94108. width?: number;
  94109. height?: number;
  94110. sideOrientation?: number;
  94111. frontUVs?: Vector4;
  94112. backUVs?: Vector4;
  94113. updatable?: boolean;
  94114. sourcePlane?: Plane;
  94115. }, scene: Scene): Mesh;
  94116. }
  94117. }
  94118. declare module BABYLON {
  94119. /**
  94120. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94121. */
  94122. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94123. private static _AnyMouseID;
  94124. private _attachedNode;
  94125. private _dragPlane;
  94126. private _scene;
  94127. private _pointerObserver;
  94128. private _beforeRenderObserver;
  94129. private static _planeScene;
  94130. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94131. /**
  94132. * 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)
  94133. */
  94134. maxDragAngle: number;
  94135. /**
  94136. * @hidden
  94137. */
  94138. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94139. /**
  94140. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94141. */
  94142. currentDraggingPointerID: number;
  94143. /**
  94144. * The last position where the pointer hit the drag plane in world space
  94145. */
  94146. lastDragPosition: Vector3;
  94147. /**
  94148. * If the behavior is currently in a dragging state
  94149. */
  94150. dragging: boolean;
  94151. /**
  94152. * 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)
  94153. */
  94154. dragDeltaRatio: number;
  94155. /**
  94156. * If the drag plane orientation should be updated during the dragging (Default: true)
  94157. */
  94158. updateDragPlane: boolean;
  94159. private _debugMode;
  94160. private _moving;
  94161. /**
  94162. * Fires each time the attached mesh is dragged with the pointer
  94163. * * delta between last drag position and current drag position in world space
  94164. * * dragDistance along the drag axis
  94165. * * dragPlaneNormal normal of the current drag plane used during the drag
  94166. * * dragPlanePoint in world space where the drag intersects the drag plane
  94167. */
  94168. onDragObservable: Observable<{
  94169. delta: Vector3;
  94170. dragPlanePoint: Vector3;
  94171. dragPlaneNormal: Vector3;
  94172. dragDistance: number;
  94173. pointerId: number;
  94174. }>;
  94175. /**
  94176. * Fires each time a drag begins (eg. mouse down on mesh)
  94177. */
  94178. onDragStartObservable: Observable<{
  94179. dragPlanePoint: Vector3;
  94180. pointerId: number;
  94181. }>;
  94182. /**
  94183. * Fires each time a drag ends (eg. mouse release after drag)
  94184. */
  94185. onDragEndObservable: Observable<{
  94186. dragPlanePoint: Vector3;
  94187. pointerId: number;
  94188. }>;
  94189. /**
  94190. * If the attached mesh should be moved when dragged
  94191. */
  94192. moveAttached: boolean;
  94193. /**
  94194. * If the drag behavior will react to drag events (Default: true)
  94195. */
  94196. enabled: boolean;
  94197. /**
  94198. * If camera controls should be detached during the drag
  94199. */
  94200. detachCameraControls: boolean;
  94201. /**
  94202. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94203. */
  94204. useObjectOrienationForDragging: boolean;
  94205. private _options;
  94206. /**
  94207. * Creates a pointer drag behavior that can be attached to a mesh
  94208. * @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)
  94209. */
  94210. constructor(options?: {
  94211. dragAxis?: Vector3;
  94212. dragPlaneNormal?: Vector3;
  94213. });
  94214. /**
  94215. * Predicate to determine if it is valid to move the object to a new position when it is moved
  94216. */
  94217. validateDrag: (targetPosition: Vector3) => boolean;
  94218. /**
  94219. * The name of the behavior
  94220. */
  94221. readonly name: string;
  94222. /**
  94223. * Initializes the behavior
  94224. */
  94225. init(): void;
  94226. private _tmpVector;
  94227. private _alternatePickedPoint;
  94228. private _worldDragAxis;
  94229. private _targetPosition;
  94230. private _attachedElement;
  94231. /**
  94232. * Attaches the drag behavior the passed in mesh
  94233. * @param ownerNode The mesh that will be dragged around once attached
  94234. */
  94235. attach(ownerNode: AbstractMesh): void;
  94236. /**
  94237. * Force relase the drag action by code.
  94238. */
  94239. releaseDrag(): void;
  94240. private _startDragRay;
  94241. private _lastPointerRay;
  94242. /**
  94243. * Simulates the start of a pointer drag event on the behavior
  94244. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  94245. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  94246. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  94247. */
  94248. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  94249. private _startDrag;
  94250. private _dragDelta;
  94251. private _moveDrag;
  94252. private _pickWithRayOnDragPlane;
  94253. private _pointA;
  94254. private _pointB;
  94255. private _pointC;
  94256. private _lineA;
  94257. private _lineB;
  94258. private _localAxis;
  94259. private _lookAt;
  94260. private _updateDragPlanePosition;
  94261. /**
  94262. * Detaches the behavior from the mesh
  94263. */
  94264. detach(): void;
  94265. }
  94266. }
  94267. declare module BABYLON {
  94268. /**
  94269. * A behavior that when attached to a mesh will allow the mesh to be scaled
  94270. */
  94271. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  94272. private _dragBehaviorA;
  94273. private _dragBehaviorB;
  94274. private _startDistance;
  94275. private _initialScale;
  94276. private _targetScale;
  94277. private _ownerNode;
  94278. private _sceneRenderObserver;
  94279. /**
  94280. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  94281. */
  94282. constructor();
  94283. /**
  94284. * The name of the behavior
  94285. */
  94286. readonly name: string;
  94287. /**
  94288. * Initializes the behavior
  94289. */
  94290. init(): void;
  94291. private _getCurrentDistance;
  94292. /**
  94293. * Attaches the scale behavior the passed in mesh
  94294. * @param ownerNode The mesh that will be scaled around once attached
  94295. */
  94296. attach(ownerNode: Mesh): void;
  94297. /**
  94298. * Detaches the behavior from the mesh
  94299. */
  94300. detach(): void;
  94301. }
  94302. }
  94303. declare module BABYLON {
  94304. /**
  94305. * 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
  94306. */
  94307. export class SixDofDragBehavior implements Behavior<Mesh> {
  94308. private static _virtualScene;
  94309. private _ownerNode;
  94310. private _sceneRenderObserver;
  94311. private _scene;
  94312. private _targetPosition;
  94313. private _virtualOriginMesh;
  94314. private _virtualDragMesh;
  94315. private _pointerObserver;
  94316. private _moving;
  94317. private _startingOrientation;
  94318. /**
  94319. * 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)
  94320. */
  94321. private zDragFactor;
  94322. /**
  94323. * If the object should rotate to face the drag origin
  94324. */
  94325. rotateDraggedObject: boolean;
  94326. /**
  94327. * If the behavior is currently in a dragging state
  94328. */
  94329. dragging: boolean;
  94330. /**
  94331. * 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)
  94332. */
  94333. dragDeltaRatio: number;
  94334. /**
  94335. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94336. */
  94337. currentDraggingPointerID: number;
  94338. /**
  94339. * If camera controls should be detached during the drag
  94340. */
  94341. detachCameraControls: boolean;
  94342. /**
  94343. * Fires each time a drag starts
  94344. */
  94345. onDragStartObservable: Observable<{}>;
  94346. /**
  94347. * Fires each time a drag ends (eg. mouse release after drag)
  94348. */
  94349. onDragEndObservable: Observable<{}>;
  94350. /**
  94351. * 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
  94352. */
  94353. constructor();
  94354. /**
  94355. * The name of the behavior
  94356. */
  94357. readonly name: string;
  94358. /**
  94359. * Initializes the behavior
  94360. */
  94361. init(): void;
  94362. /**
  94363. * Attaches the scale behavior the passed in mesh
  94364. * @param ownerNode The mesh that will be scaled around once attached
  94365. */
  94366. attach(ownerNode: Mesh): void;
  94367. /**
  94368. * Detaches the behavior from the mesh
  94369. */
  94370. detach(): void;
  94371. }
  94372. }
  94373. declare module BABYLON {
  94374. /**
  94375. * Class used to apply inverse kinematics to bones
  94376. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  94377. */
  94378. export class BoneIKController {
  94379. private static _tmpVecs;
  94380. private static _tmpQuat;
  94381. private static _tmpMats;
  94382. /**
  94383. * Gets or sets the target mesh
  94384. */
  94385. targetMesh: AbstractMesh;
  94386. /** Gets or sets the mesh used as pole */
  94387. poleTargetMesh: AbstractMesh;
  94388. /**
  94389. * Gets or sets the bone used as pole
  94390. */
  94391. poleTargetBone: Nullable<Bone>;
  94392. /**
  94393. * Gets or sets the target position
  94394. */
  94395. targetPosition: Vector3;
  94396. /**
  94397. * Gets or sets the pole target position
  94398. */
  94399. poleTargetPosition: Vector3;
  94400. /**
  94401. * Gets or sets the pole target local offset
  94402. */
  94403. poleTargetLocalOffset: Vector3;
  94404. /**
  94405. * Gets or sets the pole angle
  94406. */
  94407. poleAngle: number;
  94408. /**
  94409. * Gets or sets the mesh associated with the controller
  94410. */
  94411. mesh: AbstractMesh;
  94412. /**
  94413. * 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)
  94414. */
  94415. slerpAmount: number;
  94416. private _bone1Quat;
  94417. private _bone1Mat;
  94418. private _bone2Ang;
  94419. private _bone1;
  94420. private _bone2;
  94421. private _bone1Length;
  94422. private _bone2Length;
  94423. private _maxAngle;
  94424. private _maxReach;
  94425. private _rightHandedSystem;
  94426. private _bendAxis;
  94427. private _slerping;
  94428. private _adjustRoll;
  94429. /**
  94430. * Gets or sets maximum allowed angle
  94431. */
  94432. maxAngle: number;
  94433. /**
  94434. * Creates a new BoneIKController
  94435. * @param mesh defines the mesh to control
  94436. * @param bone defines the bone to control
  94437. * @param options defines options to set up the controller
  94438. */
  94439. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  94440. targetMesh?: AbstractMesh;
  94441. poleTargetMesh?: AbstractMesh;
  94442. poleTargetBone?: Bone;
  94443. poleTargetLocalOffset?: Vector3;
  94444. poleAngle?: number;
  94445. bendAxis?: Vector3;
  94446. maxAngle?: number;
  94447. slerpAmount?: number;
  94448. });
  94449. private _setMaxAngle;
  94450. /**
  94451. * Force the controller to update the bones
  94452. */
  94453. update(): void;
  94454. }
  94455. }
  94456. declare module BABYLON {
  94457. /**
  94458. * Class used to make a bone look toward a point in space
  94459. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  94460. */
  94461. export class BoneLookController {
  94462. private static _tmpVecs;
  94463. private static _tmpQuat;
  94464. private static _tmpMats;
  94465. /**
  94466. * The target Vector3 that the bone will look at
  94467. */
  94468. target: Vector3;
  94469. /**
  94470. * The mesh that the bone is attached to
  94471. */
  94472. mesh: AbstractMesh;
  94473. /**
  94474. * The bone that will be looking to the target
  94475. */
  94476. bone: Bone;
  94477. /**
  94478. * The up axis of the coordinate system that is used when the bone is rotated
  94479. */
  94480. upAxis: Vector3;
  94481. /**
  94482. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  94483. */
  94484. upAxisSpace: Space;
  94485. /**
  94486. * Used to make an adjustment to the yaw of the bone
  94487. */
  94488. adjustYaw: number;
  94489. /**
  94490. * Used to make an adjustment to the pitch of the bone
  94491. */
  94492. adjustPitch: number;
  94493. /**
  94494. * Used to make an adjustment to the roll of the bone
  94495. */
  94496. adjustRoll: number;
  94497. /**
  94498. * 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)
  94499. */
  94500. slerpAmount: number;
  94501. private _minYaw;
  94502. private _maxYaw;
  94503. private _minPitch;
  94504. private _maxPitch;
  94505. private _minYawSin;
  94506. private _minYawCos;
  94507. private _maxYawSin;
  94508. private _maxYawCos;
  94509. private _midYawConstraint;
  94510. private _minPitchTan;
  94511. private _maxPitchTan;
  94512. private _boneQuat;
  94513. private _slerping;
  94514. private _transformYawPitch;
  94515. private _transformYawPitchInv;
  94516. private _firstFrameSkipped;
  94517. private _yawRange;
  94518. private _fowardAxis;
  94519. /**
  94520. * Gets or sets the minimum yaw angle that the bone can look to
  94521. */
  94522. minYaw: number;
  94523. /**
  94524. * Gets or sets the maximum yaw angle that the bone can look to
  94525. */
  94526. maxYaw: number;
  94527. /**
  94528. * Gets or sets the minimum pitch angle that the bone can look to
  94529. */
  94530. minPitch: number;
  94531. /**
  94532. * Gets or sets the maximum pitch angle that the bone can look to
  94533. */
  94534. maxPitch: number;
  94535. /**
  94536. * Create a BoneLookController
  94537. * @param mesh the mesh that the bone belongs to
  94538. * @param bone the bone that will be looking to the target
  94539. * @param target the target Vector3 to look at
  94540. * @param options optional settings:
  94541. * * maxYaw: the maximum angle the bone will yaw to
  94542. * * minYaw: the minimum angle the bone will yaw to
  94543. * * maxPitch: the maximum angle the bone will pitch to
  94544. * * minPitch: the minimum angle the bone will yaw to
  94545. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  94546. * * upAxis: the up axis of the coordinate system
  94547. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  94548. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  94549. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  94550. * * adjustYaw: used to make an adjustment to the yaw of the bone
  94551. * * adjustPitch: used to make an adjustment to the pitch of the bone
  94552. * * adjustRoll: used to make an adjustment to the roll of the bone
  94553. **/
  94554. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  94555. maxYaw?: number;
  94556. minYaw?: number;
  94557. maxPitch?: number;
  94558. minPitch?: number;
  94559. slerpAmount?: number;
  94560. upAxis?: Vector3;
  94561. upAxisSpace?: Space;
  94562. yawAxis?: Vector3;
  94563. pitchAxis?: Vector3;
  94564. adjustYaw?: number;
  94565. adjustPitch?: number;
  94566. adjustRoll?: number;
  94567. });
  94568. /**
  94569. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  94570. */
  94571. update(): void;
  94572. private _getAngleDiff;
  94573. private _getAngleBetween;
  94574. private _isAngleBetween;
  94575. }
  94576. }
  94577. declare module BABYLON {
  94578. /**
  94579. * Manage the gamepad inputs to control an arc rotate camera.
  94580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94581. */
  94582. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  94583. /**
  94584. * Defines the camera the input is attached to.
  94585. */
  94586. camera: ArcRotateCamera;
  94587. /**
  94588. * Defines the gamepad the input is gathering event from.
  94589. */
  94590. gamepad: Nullable<Gamepad>;
  94591. /**
  94592. * Defines the gamepad rotation sensiblity.
  94593. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94594. */
  94595. gamepadRotationSensibility: number;
  94596. /**
  94597. * Defines the gamepad move sensiblity.
  94598. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94599. */
  94600. gamepadMoveSensibility: number;
  94601. private _onGamepadConnectedObserver;
  94602. private _onGamepadDisconnectedObserver;
  94603. /**
  94604. * Attach the input controls to a specific dom element to get the input from.
  94605. * @param element Defines the element the controls should be listened from
  94606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94607. */
  94608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94609. /**
  94610. * Detach the current controls from the specified dom element.
  94611. * @param element Defines the element to stop listening the inputs from
  94612. */
  94613. detachControl(element: Nullable<HTMLElement>): void;
  94614. /**
  94615. * Update the current camera state depending on the inputs that have been used this frame.
  94616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94617. */
  94618. checkInputs(): void;
  94619. /**
  94620. * Gets the class name of the current intput.
  94621. * @returns the class name
  94622. */
  94623. getClassName(): string;
  94624. /**
  94625. * Get the friendly name associated with the input class.
  94626. * @returns the input friendly name
  94627. */
  94628. getSimpleName(): string;
  94629. }
  94630. }
  94631. declare module BABYLON {
  94632. interface ArcRotateCameraInputsManager {
  94633. /**
  94634. * Add orientation input support to the input manager.
  94635. * @returns the current input manager
  94636. */
  94637. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  94638. }
  94639. /**
  94640. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  94641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94642. */
  94643. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  94644. /**
  94645. * Defines the camera the input is attached to.
  94646. */
  94647. camera: ArcRotateCamera;
  94648. /**
  94649. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  94650. */
  94651. alphaCorrection: number;
  94652. /**
  94653. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  94654. */
  94655. gammaCorrection: number;
  94656. private _alpha;
  94657. private _gamma;
  94658. private _dirty;
  94659. private _deviceOrientationHandler;
  94660. /**
  94661. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  94662. */
  94663. constructor();
  94664. /**
  94665. * Attach the input controls to a specific dom element to get the input from.
  94666. * @param element Defines the element the controls should be listened from
  94667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94668. */
  94669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94670. /** @hidden */
  94671. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  94672. /**
  94673. * Update the current camera state depending on the inputs that have been used this frame.
  94674. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94675. */
  94676. checkInputs(): void;
  94677. /**
  94678. * Detach the current controls from the specified dom element.
  94679. * @param element Defines the element to stop listening the inputs from
  94680. */
  94681. detachControl(element: Nullable<HTMLElement>): void;
  94682. /**
  94683. * Gets the class name of the current intput.
  94684. * @returns the class name
  94685. */
  94686. getClassName(): string;
  94687. /**
  94688. * Get the friendly name associated with the input class.
  94689. * @returns the input friendly name
  94690. */
  94691. getSimpleName(): string;
  94692. }
  94693. }
  94694. declare module BABYLON {
  94695. /**
  94696. * Listen to mouse events to control the camera.
  94697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94698. */
  94699. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  94700. /**
  94701. * Defines the camera the input is attached to.
  94702. */
  94703. camera: FlyCamera;
  94704. /**
  94705. * Defines if touch is enabled. (Default is true.)
  94706. */
  94707. touchEnabled: boolean;
  94708. /**
  94709. * Defines the buttons associated with the input to handle camera rotation.
  94710. */
  94711. buttons: number[];
  94712. /**
  94713. * Assign buttons for Yaw control.
  94714. */
  94715. buttonsYaw: number[];
  94716. /**
  94717. * Assign buttons for Pitch control.
  94718. */
  94719. buttonsPitch: number[];
  94720. /**
  94721. * Assign buttons for Roll control.
  94722. */
  94723. buttonsRoll: number[];
  94724. /**
  94725. * Detect if any button is being pressed while mouse is moved.
  94726. * -1 = Mouse locked.
  94727. * 0 = Left button.
  94728. * 1 = Middle Button.
  94729. * 2 = Right Button.
  94730. */
  94731. activeButton: number;
  94732. /**
  94733. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  94734. * Higher values reduce its sensitivity.
  94735. */
  94736. angularSensibility: number;
  94737. private _mousemoveCallback;
  94738. private _observer;
  94739. private _rollObserver;
  94740. private previousPosition;
  94741. private noPreventDefault;
  94742. private element;
  94743. /**
  94744. * Listen to mouse events to control the camera.
  94745. * @param touchEnabled Define if touch is enabled. (Default is true.)
  94746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94747. */
  94748. constructor(touchEnabled?: boolean);
  94749. /**
  94750. * Attach the mouse control to the HTML DOM element.
  94751. * @param element Defines the element that listens to the input events.
  94752. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  94753. */
  94754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94755. /**
  94756. * Detach the current controls from the specified dom element.
  94757. * @param element Defines the element to stop listening the inputs from
  94758. */
  94759. detachControl(element: Nullable<HTMLElement>): void;
  94760. /**
  94761. * Gets the class name of the current input.
  94762. * @returns the class name.
  94763. */
  94764. getClassName(): string;
  94765. /**
  94766. * Get the friendly name associated with the input class.
  94767. * @returns the input's friendly name.
  94768. */
  94769. getSimpleName(): string;
  94770. private _pointerInput;
  94771. private _onMouseMove;
  94772. /**
  94773. * Rotate camera by mouse offset.
  94774. */
  94775. private rotateCamera;
  94776. }
  94777. }
  94778. declare module BABYLON {
  94779. /**
  94780. * Default Inputs manager for the FlyCamera.
  94781. * It groups all the default supported inputs for ease of use.
  94782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94783. */
  94784. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  94785. /**
  94786. * Instantiates a new FlyCameraInputsManager.
  94787. * @param camera Defines the camera the inputs belong to.
  94788. */
  94789. constructor(camera: FlyCamera);
  94790. /**
  94791. * Add keyboard input support to the input manager.
  94792. * @returns the new FlyCameraKeyboardMoveInput().
  94793. */
  94794. addKeyboard(): FlyCameraInputsManager;
  94795. /**
  94796. * Add mouse input support to the input manager.
  94797. * @param touchEnabled Enable touch screen support.
  94798. * @returns the new FlyCameraMouseInput().
  94799. */
  94800. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  94801. }
  94802. }
  94803. declare module BABYLON {
  94804. /**
  94805. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94806. * such as in a 3D Space Shooter or a Flight Simulator.
  94807. */
  94808. export class FlyCamera extends TargetCamera {
  94809. /**
  94810. * Define the collision ellipsoid of the camera.
  94811. * This is helpful for simulating a camera body, like a player's body.
  94812. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94813. */
  94814. ellipsoid: Vector3;
  94815. /**
  94816. * Define an offset for the position of the ellipsoid around the camera.
  94817. * This can be helpful if the camera is attached away from the player's body center,
  94818. * such as at its head.
  94819. */
  94820. ellipsoidOffset: Vector3;
  94821. /**
  94822. * Enable or disable collisions of the camera with the rest of the scene objects.
  94823. */
  94824. checkCollisions: boolean;
  94825. /**
  94826. * Enable or disable gravity on the camera.
  94827. */
  94828. applyGravity: boolean;
  94829. /**
  94830. * Define the current direction the camera is moving to.
  94831. */
  94832. cameraDirection: Vector3;
  94833. /**
  94834. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  94835. * This overrides and empties cameraRotation.
  94836. */
  94837. rotationQuaternion: Quaternion;
  94838. /**
  94839. * Track Roll to maintain the wanted Rolling when looking around.
  94840. */
  94841. _trackRoll: number;
  94842. /**
  94843. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  94844. */
  94845. rollCorrect: number;
  94846. /**
  94847. * Mimic a banked turn, Rolling the camera when Yawing.
  94848. * It's recommended to use rollCorrect = 10 for faster banking correction.
  94849. */
  94850. bankedTurn: boolean;
  94851. /**
  94852. * Limit in radians for how much Roll banking will add. (Default: 90°)
  94853. */
  94854. bankedTurnLimit: number;
  94855. /**
  94856. * Value of 0 disables the banked Roll.
  94857. * Value of 1 is equal to the Yaw angle in radians.
  94858. */
  94859. bankedTurnMultiplier: number;
  94860. /**
  94861. * The inputs manager loads all the input sources, such as keyboard and mouse.
  94862. */
  94863. inputs: FlyCameraInputsManager;
  94864. /**
  94865. * Gets the input sensibility for mouse input.
  94866. * Higher values reduce sensitivity.
  94867. */
  94868. /**
  94869. * Sets the input sensibility for a mouse input.
  94870. * Higher values reduce sensitivity.
  94871. */
  94872. angularSensibility: number;
  94873. /**
  94874. * Get the keys for camera movement forward.
  94875. */
  94876. /**
  94877. * Set the keys for camera movement forward.
  94878. */
  94879. keysForward: number[];
  94880. /**
  94881. * Get the keys for camera movement backward.
  94882. */
  94883. keysBackward: number[];
  94884. /**
  94885. * Get the keys for camera movement up.
  94886. */
  94887. /**
  94888. * Set the keys for camera movement up.
  94889. */
  94890. keysUp: number[];
  94891. /**
  94892. * Get the keys for camera movement down.
  94893. */
  94894. /**
  94895. * Set the keys for camera movement down.
  94896. */
  94897. keysDown: number[];
  94898. /**
  94899. * Get the keys for camera movement left.
  94900. */
  94901. /**
  94902. * Set the keys for camera movement left.
  94903. */
  94904. keysLeft: number[];
  94905. /**
  94906. * Set the keys for camera movement right.
  94907. */
  94908. /**
  94909. * Set the keys for camera movement right.
  94910. */
  94911. keysRight: number[];
  94912. /**
  94913. * Event raised when the camera collides with a mesh in the scene.
  94914. */
  94915. onCollide: (collidedMesh: AbstractMesh) => void;
  94916. private _collider;
  94917. private _needMoveForGravity;
  94918. private _oldPosition;
  94919. private _diffPosition;
  94920. private _newPosition;
  94921. /** @hidden */
  94922. _localDirection: Vector3;
  94923. /** @hidden */
  94924. _transformedDirection: Vector3;
  94925. /**
  94926. * Instantiates a FlyCamera.
  94927. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94928. * such as in a 3D Space Shooter or a Flight Simulator.
  94929. * @param name Define the name of the camera in the scene.
  94930. * @param position Define the starting position of the camera in the scene.
  94931. * @param scene Define the scene the camera belongs to.
  94932. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  94933. */
  94934. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94935. /**
  94936. * Attach a control to the HTML DOM element.
  94937. * @param element Defines the element that listens to the input events.
  94938. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  94939. */
  94940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94941. /**
  94942. * Detach a control from the HTML DOM element.
  94943. * The camera will stop reacting to that input.
  94944. * @param element Defines the element that listens to the input events.
  94945. */
  94946. detachControl(element: HTMLElement): void;
  94947. private _collisionMask;
  94948. /**
  94949. * Get the mask that the camera ignores in collision events.
  94950. */
  94951. /**
  94952. * Set the mask that the camera ignores in collision events.
  94953. */
  94954. collisionMask: number;
  94955. /** @hidden */
  94956. _collideWithWorld(displacement: Vector3): void;
  94957. /** @hidden */
  94958. private _onCollisionPositionChange;
  94959. /** @hidden */
  94960. _checkInputs(): void;
  94961. /** @hidden */
  94962. _decideIfNeedsToMove(): boolean;
  94963. /** @hidden */
  94964. _updatePosition(): void;
  94965. /**
  94966. * Restore the Roll to its target value at the rate specified.
  94967. * @param rate - Higher means slower restoring.
  94968. * @hidden
  94969. */
  94970. restoreRoll(rate: number): void;
  94971. /**
  94972. * Destroy the camera and release the current resources held by it.
  94973. */
  94974. dispose(): void;
  94975. /**
  94976. * Get the current object class name.
  94977. * @returns the class name.
  94978. */
  94979. getClassName(): string;
  94980. }
  94981. }
  94982. declare module BABYLON {
  94983. /**
  94984. * Listen to keyboard events to control the camera.
  94985. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94986. */
  94987. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  94988. /**
  94989. * Defines the camera the input is attached to.
  94990. */
  94991. camera: FlyCamera;
  94992. /**
  94993. * The list of keyboard keys used to control the forward move of the camera.
  94994. */
  94995. keysForward: number[];
  94996. /**
  94997. * The list of keyboard keys used to control the backward move of the camera.
  94998. */
  94999. keysBackward: number[];
  95000. /**
  95001. * The list of keyboard keys used to control the forward move of the camera.
  95002. */
  95003. keysUp: number[];
  95004. /**
  95005. * The list of keyboard keys used to control the backward move of the camera.
  95006. */
  95007. keysDown: number[];
  95008. /**
  95009. * The list of keyboard keys used to control the right strafe move of the camera.
  95010. */
  95011. keysRight: number[];
  95012. /**
  95013. * The list of keyboard keys used to control the left strafe move of the camera.
  95014. */
  95015. keysLeft: number[];
  95016. private _keys;
  95017. private _onCanvasBlurObserver;
  95018. private _onKeyboardObserver;
  95019. private _engine;
  95020. private _scene;
  95021. /**
  95022. * Attach the input controls to a specific dom element to get the input from.
  95023. * @param element Defines the element the controls should be listened from
  95024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95025. */
  95026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95027. /**
  95028. * Detach the current controls from the specified dom element.
  95029. * @param element Defines the element to stop listening the inputs from
  95030. */
  95031. detachControl(element: Nullable<HTMLElement>): void;
  95032. /**
  95033. * Gets the class name of the current intput.
  95034. * @returns the class name
  95035. */
  95036. getClassName(): string;
  95037. /** @hidden */
  95038. _onLostFocus(e: FocusEvent): void;
  95039. /**
  95040. * Get the friendly name associated with the input class.
  95041. * @returns the input friendly name
  95042. */
  95043. getSimpleName(): string;
  95044. /**
  95045. * Update the current camera state depending on the inputs that have been used this frame.
  95046. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95047. */
  95048. checkInputs(): void;
  95049. }
  95050. }
  95051. declare module BABYLON {
  95052. /**
  95053. * Manage the mouse wheel inputs to control a follow camera.
  95054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95055. */
  95056. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95057. /**
  95058. * Defines the camera the input is attached to.
  95059. */
  95060. camera: FollowCamera;
  95061. /**
  95062. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95063. */
  95064. axisControlRadius: boolean;
  95065. /**
  95066. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95067. */
  95068. axisControlHeight: boolean;
  95069. /**
  95070. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95071. */
  95072. axisControlRotation: boolean;
  95073. /**
  95074. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95075. * relation to mouseWheel events.
  95076. */
  95077. wheelPrecision: number;
  95078. /**
  95079. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95080. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95081. */
  95082. wheelDeltaPercentage: number;
  95083. private _wheel;
  95084. private _observer;
  95085. /**
  95086. * Attach the input controls to a specific dom element to get the input from.
  95087. * @param element Defines the element the controls should be listened from
  95088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95089. */
  95090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95091. /**
  95092. * Detach the current controls from the specified dom element.
  95093. * @param element Defines the element to stop listening the inputs from
  95094. */
  95095. detachControl(element: Nullable<HTMLElement>): void;
  95096. /**
  95097. * Gets the class name of the current intput.
  95098. * @returns the class name
  95099. */
  95100. getClassName(): string;
  95101. /**
  95102. * Get the friendly name associated with the input class.
  95103. * @returns the input friendly name
  95104. */
  95105. getSimpleName(): string;
  95106. }
  95107. }
  95108. declare module BABYLON {
  95109. /**
  95110. * Manage the pointers inputs to control an follow camera.
  95111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95112. */
  95113. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95114. /**
  95115. * Defines the camera the input is attached to.
  95116. */
  95117. camera: FollowCamera;
  95118. /**
  95119. * Gets the class name of the current input.
  95120. * @returns the class name
  95121. */
  95122. getClassName(): string;
  95123. /**
  95124. * Defines the pointer angular sensibility along the X axis or how fast is
  95125. * the camera rotating.
  95126. * A negative number will reverse the axis direction.
  95127. */
  95128. angularSensibilityX: number;
  95129. /**
  95130. * Defines the pointer angular sensibility along the Y axis or how fast is
  95131. * the camera rotating.
  95132. * A negative number will reverse the axis direction.
  95133. */
  95134. angularSensibilityY: number;
  95135. /**
  95136. * Defines the pointer pinch precision or how fast is the camera zooming.
  95137. * A negative number will reverse the axis direction.
  95138. */
  95139. pinchPrecision: number;
  95140. /**
  95141. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95142. * from 0.
  95143. * It defines the percentage of current camera.radius to use as delta when
  95144. * pinch zoom is used.
  95145. */
  95146. pinchDeltaPercentage: number;
  95147. /**
  95148. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95149. */
  95150. axisXControlRadius: boolean;
  95151. /**
  95152. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95153. */
  95154. axisXControlHeight: boolean;
  95155. /**
  95156. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95157. */
  95158. axisXControlRotation: boolean;
  95159. /**
  95160. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95161. */
  95162. axisYControlRadius: boolean;
  95163. /**
  95164. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95165. */
  95166. axisYControlHeight: boolean;
  95167. /**
  95168. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95169. */
  95170. axisYControlRotation: boolean;
  95171. /**
  95172. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95173. */
  95174. axisPinchControlRadius: boolean;
  95175. /**
  95176. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95177. */
  95178. axisPinchControlHeight: boolean;
  95179. /**
  95180. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95181. */
  95182. axisPinchControlRotation: boolean;
  95183. /**
  95184. * Log error messages if basic misconfiguration has occurred.
  95185. */
  95186. warningEnable: boolean;
  95187. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95188. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95189. private _warningCounter;
  95190. private _warning;
  95191. }
  95192. }
  95193. declare module BABYLON {
  95194. /**
  95195. * Default Inputs manager for the FollowCamera.
  95196. * It groups all the default supported inputs for ease of use.
  95197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95198. */
  95199. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95200. /**
  95201. * Instantiates a new FollowCameraInputsManager.
  95202. * @param camera Defines the camera the inputs belong to
  95203. */
  95204. constructor(camera: FollowCamera);
  95205. /**
  95206. * Add keyboard input support to the input manager.
  95207. * @returns the current input manager
  95208. */
  95209. addKeyboard(): FollowCameraInputsManager;
  95210. /**
  95211. * Add mouse wheel input support to the input manager.
  95212. * @returns the current input manager
  95213. */
  95214. addMouseWheel(): FollowCameraInputsManager;
  95215. /**
  95216. * Add pointers input support to the input manager.
  95217. * @returns the current input manager
  95218. */
  95219. addPointers(): FollowCameraInputsManager;
  95220. /**
  95221. * Add orientation input support to the input manager.
  95222. * @returns the current input manager
  95223. */
  95224. addVRDeviceOrientation(): FollowCameraInputsManager;
  95225. }
  95226. }
  95227. declare module BABYLON {
  95228. /**
  95229. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  95230. * an arc rotate version arcFollowCamera are available.
  95231. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95232. */
  95233. export class FollowCamera extends TargetCamera {
  95234. /**
  95235. * Distance the follow camera should follow an object at
  95236. */
  95237. radius: number;
  95238. /**
  95239. * Minimum allowed distance of the camera to the axis of rotation
  95240. * (The camera can not get closer).
  95241. * This can help limiting how the Camera is able to move in the scene.
  95242. */
  95243. lowerRadiusLimit: Nullable<number>;
  95244. /**
  95245. * Maximum allowed distance of the camera to the axis of rotation
  95246. * (The camera can not get further).
  95247. * This can help limiting how the Camera is able to move in the scene.
  95248. */
  95249. upperRadiusLimit: Nullable<number>;
  95250. /**
  95251. * Define a rotation offset between the camera and the object it follows
  95252. */
  95253. rotationOffset: number;
  95254. /**
  95255. * Minimum allowed angle to camera position relative to target object.
  95256. * This can help limiting how the Camera is able to move in the scene.
  95257. */
  95258. lowerRotationOffsetLimit: Nullable<number>;
  95259. /**
  95260. * Maximum allowed angle to camera position relative to target object.
  95261. * This can help limiting how the Camera is able to move in the scene.
  95262. */
  95263. upperRotationOffsetLimit: Nullable<number>;
  95264. /**
  95265. * Define a height offset between the camera and the object it follows.
  95266. * It can help following an object from the top (like a car chaing a plane)
  95267. */
  95268. heightOffset: number;
  95269. /**
  95270. * Minimum allowed height of camera position relative to target object.
  95271. * This can help limiting how the Camera is able to move in the scene.
  95272. */
  95273. lowerHeightOffsetLimit: Nullable<number>;
  95274. /**
  95275. * Maximum allowed height of camera position relative to target object.
  95276. * This can help limiting how the Camera is able to move in the scene.
  95277. */
  95278. upperHeightOffsetLimit: Nullable<number>;
  95279. /**
  95280. * Define how fast the camera can accelerate to follow it s target.
  95281. */
  95282. cameraAcceleration: number;
  95283. /**
  95284. * Define the speed limit of the camera following an object.
  95285. */
  95286. maxCameraSpeed: number;
  95287. /**
  95288. * Define the target of the camera.
  95289. */
  95290. lockedTarget: Nullable<AbstractMesh>;
  95291. /**
  95292. * Defines the input associated with the camera.
  95293. */
  95294. inputs: FollowCameraInputsManager;
  95295. /**
  95296. * Instantiates the follow camera.
  95297. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95298. * @param name Define the name of the camera in the scene
  95299. * @param position Define the position of the camera
  95300. * @param scene Define the scene the camera belong to
  95301. * @param lockedTarget Define the target of the camera
  95302. */
  95303. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  95304. private _follow;
  95305. /**
  95306. * Attached controls to the current camera.
  95307. * @param element Defines the element the controls should be listened from
  95308. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95309. */
  95310. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95311. /**
  95312. * Detach the current controls from the camera.
  95313. * The camera will stop reacting to inputs.
  95314. * @param element Defines the element to stop listening the inputs from
  95315. */
  95316. detachControl(element: HTMLElement): void;
  95317. /** @hidden */
  95318. _checkInputs(): void;
  95319. private _checkLimits;
  95320. /**
  95321. * Gets the camera class name.
  95322. * @returns the class name
  95323. */
  95324. getClassName(): string;
  95325. }
  95326. /**
  95327. * Arc Rotate version of the follow camera.
  95328. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  95329. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95330. */
  95331. export class ArcFollowCamera extends TargetCamera {
  95332. /** The longitudinal angle of the camera */
  95333. alpha: number;
  95334. /** The latitudinal angle of the camera */
  95335. beta: number;
  95336. /** The radius of the camera from its target */
  95337. radius: number;
  95338. /** Define the camera target (the messh it should follow) */
  95339. target: Nullable<AbstractMesh>;
  95340. private _cartesianCoordinates;
  95341. /**
  95342. * Instantiates a new ArcFollowCamera
  95343. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95344. * @param name Define the name of the camera
  95345. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  95346. * @param beta Define the rotation angle of the camera around the elevation axis
  95347. * @param radius Define the radius of the camera from its target point
  95348. * @param target Define the target of the camera
  95349. * @param scene Define the scene the camera belongs to
  95350. */
  95351. constructor(name: string,
  95352. /** The longitudinal angle of the camera */
  95353. alpha: number,
  95354. /** The latitudinal angle of the camera */
  95355. beta: number,
  95356. /** The radius of the camera from its target */
  95357. radius: number,
  95358. /** Define the camera target (the messh it should follow) */
  95359. target: Nullable<AbstractMesh>, scene: Scene);
  95360. private _follow;
  95361. /** @hidden */
  95362. _checkInputs(): void;
  95363. /**
  95364. * Returns the class name of the object.
  95365. * It is mostly used internally for serialization purposes.
  95366. */
  95367. getClassName(): string;
  95368. }
  95369. }
  95370. declare module BABYLON {
  95371. /**
  95372. * Manage the keyboard inputs to control the movement of a follow camera.
  95373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95374. */
  95375. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  95376. /**
  95377. * Defines the camera the input is attached to.
  95378. */
  95379. camera: FollowCamera;
  95380. /**
  95381. * Defines the list of key codes associated with the up action (increase heightOffset)
  95382. */
  95383. keysHeightOffsetIncr: number[];
  95384. /**
  95385. * Defines the list of key codes associated with the down action (decrease heightOffset)
  95386. */
  95387. keysHeightOffsetDecr: number[];
  95388. /**
  95389. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  95390. */
  95391. keysHeightOffsetModifierAlt: boolean;
  95392. /**
  95393. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  95394. */
  95395. keysHeightOffsetModifierCtrl: boolean;
  95396. /**
  95397. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  95398. */
  95399. keysHeightOffsetModifierShift: boolean;
  95400. /**
  95401. * Defines the list of key codes associated with the left action (increase rotationOffset)
  95402. */
  95403. keysRotationOffsetIncr: number[];
  95404. /**
  95405. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  95406. */
  95407. keysRotationOffsetDecr: number[];
  95408. /**
  95409. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  95410. */
  95411. keysRotationOffsetModifierAlt: boolean;
  95412. /**
  95413. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  95414. */
  95415. keysRotationOffsetModifierCtrl: boolean;
  95416. /**
  95417. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  95418. */
  95419. keysRotationOffsetModifierShift: boolean;
  95420. /**
  95421. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  95422. */
  95423. keysRadiusIncr: number[];
  95424. /**
  95425. * Defines the list of key codes associated with the zoom-out action (increase radius)
  95426. */
  95427. keysRadiusDecr: number[];
  95428. /**
  95429. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  95430. */
  95431. keysRadiusModifierAlt: boolean;
  95432. /**
  95433. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  95434. */
  95435. keysRadiusModifierCtrl: boolean;
  95436. /**
  95437. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  95438. */
  95439. keysRadiusModifierShift: boolean;
  95440. /**
  95441. * Defines the rate of change of heightOffset.
  95442. */
  95443. heightSensibility: number;
  95444. /**
  95445. * Defines the rate of change of rotationOffset.
  95446. */
  95447. rotationSensibility: number;
  95448. /**
  95449. * Defines the rate of change of radius.
  95450. */
  95451. radiusSensibility: number;
  95452. private _keys;
  95453. private _ctrlPressed;
  95454. private _altPressed;
  95455. private _shiftPressed;
  95456. private _onCanvasBlurObserver;
  95457. private _onKeyboardObserver;
  95458. private _engine;
  95459. private _scene;
  95460. /**
  95461. * Attach the input controls to a specific dom element to get the input from.
  95462. * @param element Defines the element the controls should be listened from
  95463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95464. */
  95465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95466. /**
  95467. * Detach the current controls from the specified dom element.
  95468. * @param element Defines the element to stop listening the inputs from
  95469. */
  95470. detachControl(element: Nullable<HTMLElement>): void;
  95471. /**
  95472. * Update the current camera state depending on the inputs that have been used this frame.
  95473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95474. */
  95475. checkInputs(): void;
  95476. /**
  95477. * Gets the class name of the current input.
  95478. * @returns the class name
  95479. */
  95480. getClassName(): string;
  95481. /**
  95482. * Get the friendly name associated with the input class.
  95483. * @returns the input friendly name
  95484. */
  95485. getSimpleName(): string;
  95486. /**
  95487. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95488. * allow modification of the heightOffset value.
  95489. */
  95490. private _modifierHeightOffset;
  95491. /**
  95492. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95493. * allow modification of the rotationOffset value.
  95494. */
  95495. private _modifierRotationOffset;
  95496. /**
  95497. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95498. * allow modification of the radius value.
  95499. */
  95500. private _modifierRadius;
  95501. }
  95502. }
  95503. declare module BABYLON {
  95504. interface FreeCameraInputsManager {
  95505. /**
  95506. * Add orientation input support to the input manager.
  95507. * @returns the current input manager
  95508. */
  95509. addDeviceOrientation(): FreeCameraInputsManager;
  95510. }
  95511. /**
  95512. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  95513. * Screen rotation is taken into account.
  95514. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95515. */
  95516. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  95517. private _camera;
  95518. private _screenOrientationAngle;
  95519. private _constantTranform;
  95520. private _screenQuaternion;
  95521. private _alpha;
  95522. private _beta;
  95523. private _gamma;
  95524. /**
  95525. * Instantiates a new input
  95526. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95527. */
  95528. constructor();
  95529. /**
  95530. * Define the camera controlled by the input.
  95531. */
  95532. camera: FreeCamera;
  95533. /**
  95534. * Attach the input controls to a specific dom element to get the input from.
  95535. * @param element Defines the element the controls should be listened from
  95536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95537. */
  95538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95539. private _orientationChanged;
  95540. private _deviceOrientation;
  95541. /**
  95542. * Detach the current controls from the specified dom element.
  95543. * @param element Defines the element to stop listening the inputs from
  95544. */
  95545. detachControl(element: Nullable<HTMLElement>): void;
  95546. /**
  95547. * Update the current camera state depending on the inputs that have been used this frame.
  95548. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95549. */
  95550. checkInputs(): void;
  95551. /**
  95552. * Gets the class name of the current intput.
  95553. * @returns the class name
  95554. */
  95555. getClassName(): string;
  95556. /**
  95557. * Get the friendly name associated with the input class.
  95558. * @returns the input friendly name
  95559. */
  95560. getSimpleName(): string;
  95561. }
  95562. }
  95563. declare module BABYLON {
  95564. /**
  95565. * Manage the gamepad inputs to control a free camera.
  95566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95567. */
  95568. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  95569. /**
  95570. * Define the camera the input is attached to.
  95571. */
  95572. camera: FreeCamera;
  95573. /**
  95574. * Define the Gamepad controlling the input
  95575. */
  95576. gamepad: Nullable<Gamepad>;
  95577. /**
  95578. * Defines the gamepad rotation sensiblity.
  95579. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95580. */
  95581. gamepadAngularSensibility: number;
  95582. /**
  95583. * Defines the gamepad move sensiblity.
  95584. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95585. */
  95586. gamepadMoveSensibility: number;
  95587. private _onGamepadConnectedObserver;
  95588. private _onGamepadDisconnectedObserver;
  95589. private _cameraTransform;
  95590. private _deltaTransform;
  95591. private _vector3;
  95592. private _vector2;
  95593. /**
  95594. * Attach the input controls to a specific dom element to get the input from.
  95595. * @param element Defines the element the controls should be listened from
  95596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95597. */
  95598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95599. /**
  95600. * Detach the current controls from the specified dom element.
  95601. * @param element Defines the element to stop listening the inputs from
  95602. */
  95603. detachControl(element: Nullable<HTMLElement>): void;
  95604. /**
  95605. * Update the current camera state depending on the inputs that have been used this frame.
  95606. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95607. */
  95608. checkInputs(): void;
  95609. /**
  95610. * Gets the class name of the current intput.
  95611. * @returns the class name
  95612. */
  95613. getClassName(): string;
  95614. /**
  95615. * Get the friendly name associated with the input class.
  95616. * @returns the input friendly name
  95617. */
  95618. getSimpleName(): string;
  95619. }
  95620. }
  95621. declare module BABYLON {
  95622. /**
  95623. * Defines the potential axis of a Joystick
  95624. */
  95625. export enum JoystickAxis {
  95626. /** X axis */
  95627. X = 0,
  95628. /** Y axis */
  95629. Y = 1,
  95630. /** Z axis */
  95631. Z = 2
  95632. }
  95633. /**
  95634. * Class used to define virtual joystick (used in touch mode)
  95635. */
  95636. export class VirtualJoystick {
  95637. /**
  95638. * Gets or sets a boolean indicating that left and right values must be inverted
  95639. */
  95640. reverseLeftRight: boolean;
  95641. /**
  95642. * Gets or sets a boolean indicating that up and down values must be inverted
  95643. */
  95644. reverseUpDown: boolean;
  95645. /**
  95646. * Gets the offset value for the position (ie. the change of the position value)
  95647. */
  95648. deltaPosition: Vector3;
  95649. /**
  95650. * Gets a boolean indicating if the virtual joystick was pressed
  95651. */
  95652. pressed: boolean;
  95653. /**
  95654. * Canvas the virtual joystick will render onto, default z-index of this is 5
  95655. */
  95656. static Canvas: Nullable<HTMLCanvasElement>;
  95657. private static _globalJoystickIndex;
  95658. private static vjCanvasContext;
  95659. private static vjCanvasWidth;
  95660. private static vjCanvasHeight;
  95661. private static halfWidth;
  95662. private _action;
  95663. private _axisTargetedByLeftAndRight;
  95664. private _axisTargetedByUpAndDown;
  95665. private _joystickSensibility;
  95666. private _inversedSensibility;
  95667. private _joystickPointerID;
  95668. private _joystickColor;
  95669. private _joystickPointerPos;
  95670. private _joystickPreviousPointerPos;
  95671. private _joystickPointerStartPos;
  95672. private _deltaJoystickVector;
  95673. private _leftJoystick;
  95674. private _touches;
  95675. private _onPointerDownHandlerRef;
  95676. private _onPointerMoveHandlerRef;
  95677. private _onPointerUpHandlerRef;
  95678. private _onResize;
  95679. /**
  95680. * Creates a new virtual joystick
  95681. * @param leftJoystick defines that the joystick is for left hand (false by default)
  95682. */
  95683. constructor(leftJoystick?: boolean);
  95684. /**
  95685. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  95686. * @param newJoystickSensibility defines the new sensibility
  95687. */
  95688. setJoystickSensibility(newJoystickSensibility: number): void;
  95689. private _onPointerDown;
  95690. private _onPointerMove;
  95691. private _onPointerUp;
  95692. /**
  95693. * Change the color of the virtual joystick
  95694. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  95695. */
  95696. setJoystickColor(newColor: string): void;
  95697. /**
  95698. * Defines a callback to call when the joystick is touched
  95699. * @param action defines the callback
  95700. */
  95701. setActionOnTouch(action: () => any): void;
  95702. /**
  95703. * Defines which axis you'd like to control for left & right
  95704. * @param axis defines the axis to use
  95705. */
  95706. setAxisForLeftRight(axis: JoystickAxis): void;
  95707. /**
  95708. * Defines which axis you'd like to control for up & down
  95709. * @param axis defines the axis to use
  95710. */
  95711. setAxisForUpDown(axis: JoystickAxis): void;
  95712. private _drawVirtualJoystick;
  95713. /**
  95714. * Release internal HTML canvas
  95715. */
  95716. releaseCanvas(): void;
  95717. }
  95718. }
  95719. declare module BABYLON {
  95720. interface FreeCameraInputsManager {
  95721. /**
  95722. * Add virtual joystick input support to the input manager.
  95723. * @returns the current input manager
  95724. */
  95725. addVirtualJoystick(): FreeCameraInputsManager;
  95726. }
  95727. /**
  95728. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  95729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95730. */
  95731. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  95732. /**
  95733. * Defines the camera the input is attached to.
  95734. */
  95735. camera: FreeCamera;
  95736. private _leftjoystick;
  95737. private _rightjoystick;
  95738. /**
  95739. * Gets the left stick of the virtual joystick.
  95740. * @returns The virtual Joystick
  95741. */
  95742. getLeftJoystick(): VirtualJoystick;
  95743. /**
  95744. * Gets the right stick of the virtual joystick.
  95745. * @returns The virtual Joystick
  95746. */
  95747. getRightJoystick(): VirtualJoystick;
  95748. /**
  95749. * Update the current camera state depending on the inputs that have been used this frame.
  95750. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95751. */
  95752. checkInputs(): void;
  95753. /**
  95754. * Attach the input controls to a specific dom element to get the input from.
  95755. * @param element Defines the element the controls should be listened from
  95756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95757. */
  95758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95759. /**
  95760. * Detach the current controls from the specified dom element.
  95761. * @param element Defines the element to stop listening the inputs from
  95762. */
  95763. detachControl(element: Nullable<HTMLElement>): void;
  95764. /**
  95765. * Gets the class name of the current intput.
  95766. * @returns the class name
  95767. */
  95768. getClassName(): string;
  95769. /**
  95770. * Get the friendly name associated with the input class.
  95771. * @returns the input friendly name
  95772. */
  95773. getSimpleName(): string;
  95774. }
  95775. }
  95776. declare module BABYLON {
  95777. /**
  95778. * This represents a FPS type of camera controlled by touch.
  95779. * This is like a universal camera minus the Gamepad controls.
  95780. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95781. */
  95782. export class TouchCamera extends FreeCamera {
  95783. /**
  95784. * Defines the touch sensibility for rotation.
  95785. * The higher the faster.
  95786. */
  95787. touchAngularSensibility: number;
  95788. /**
  95789. * Defines the touch sensibility for move.
  95790. * The higher the faster.
  95791. */
  95792. touchMoveSensibility: number;
  95793. /**
  95794. * Instantiates a new touch camera.
  95795. * This represents a FPS type of camera controlled by touch.
  95796. * This is like a universal camera minus the Gamepad controls.
  95797. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95798. * @param name Define the name of the camera in the scene
  95799. * @param position Define the start position of the camera in the scene
  95800. * @param scene Define the scene the camera belongs to
  95801. */
  95802. constructor(name: string, position: Vector3, scene: Scene);
  95803. /**
  95804. * Gets the current object class name.
  95805. * @return the class name
  95806. */
  95807. getClassName(): string;
  95808. /** @hidden */
  95809. _setupInputs(): void;
  95810. }
  95811. }
  95812. declare module BABYLON {
  95813. /**
  95814. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  95815. * being tilted forward or back and left or right.
  95816. */
  95817. export class DeviceOrientationCamera extends FreeCamera {
  95818. private _initialQuaternion;
  95819. private _quaternionCache;
  95820. /**
  95821. * Creates a new device orientation camera
  95822. * @param name The name of the camera
  95823. * @param position The start position camera
  95824. * @param scene The scene the camera belongs to
  95825. */
  95826. constructor(name: string, position: Vector3, scene: Scene);
  95827. /**
  95828. * Gets the current instance class name ("DeviceOrientationCamera").
  95829. * This helps avoiding instanceof at run time.
  95830. * @returns the class name
  95831. */
  95832. getClassName(): string;
  95833. /**
  95834. * @hidden
  95835. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  95836. */
  95837. _checkInputs(): void;
  95838. /**
  95839. * Reset the camera to its default orientation on the specified axis only.
  95840. * @param axis The axis to reset
  95841. */
  95842. resetToCurrentRotation(axis?: Axis): void;
  95843. }
  95844. }
  95845. declare module BABYLON {
  95846. /**
  95847. * 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,
  95848. * which still works and will still be found in many Playgrounds.
  95849. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95850. */
  95851. export class UniversalCamera extends TouchCamera {
  95852. /**
  95853. * Defines the gamepad rotation sensiblity.
  95854. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95855. */
  95856. gamepadAngularSensibility: number;
  95857. /**
  95858. * Defines the gamepad move sensiblity.
  95859. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95860. */
  95861. gamepadMoveSensibility: number;
  95862. /**
  95863. * 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,
  95864. * which still works and will still be found in many Playgrounds.
  95865. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95866. * @param name Define the name of the camera in the scene
  95867. * @param position Define the start position of the camera in the scene
  95868. * @param scene Define the scene the camera belongs to
  95869. */
  95870. constructor(name: string, position: Vector3, scene: Scene);
  95871. /**
  95872. * Gets the current object class name.
  95873. * @return the class name
  95874. */
  95875. getClassName(): string;
  95876. }
  95877. }
  95878. declare module BABYLON {
  95879. /**
  95880. * This represents a FPS type of camera. This is only here for back compat purpose.
  95881. * Please use the UniversalCamera instead as both are identical.
  95882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95883. */
  95884. export class GamepadCamera extends UniversalCamera {
  95885. /**
  95886. * Instantiates a new Gamepad Camera
  95887. * This represents a FPS type of camera. This is only here for back compat purpose.
  95888. * Please use the UniversalCamera instead as both are identical.
  95889. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95890. * @param name Define the name of the camera in the scene
  95891. * @param position Define the start position of the camera in the scene
  95892. * @param scene Define the scene the camera belongs to
  95893. */
  95894. constructor(name: string, position: Vector3, scene: Scene);
  95895. /**
  95896. * Gets the current object class name.
  95897. * @return the class name
  95898. */
  95899. getClassName(): string;
  95900. }
  95901. }
  95902. declare module BABYLON {
  95903. /** @hidden */
  95904. export var passPixelShader: {
  95905. name: string;
  95906. shader: string;
  95907. };
  95908. }
  95909. declare module BABYLON {
  95910. /** @hidden */
  95911. export var passCubePixelShader: {
  95912. name: string;
  95913. shader: string;
  95914. };
  95915. }
  95916. declare module BABYLON {
  95917. /**
  95918. * PassPostProcess which produces an output the same as it's input
  95919. */
  95920. export class PassPostProcess extends PostProcess {
  95921. /**
  95922. * Creates the PassPostProcess
  95923. * @param name The name of the effect.
  95924. * @param options The required width/height ratio to downsize to before computing the render pass.
  95925. * @param camera The camera to apply the render pass to.
  95926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95927. * @param engine The engine which the post process will be applied. (default: current engine)
  95928. * @param reusable If the post process can be reused on the same frame. (default: false)
  95929. * @param textureType The type of texture to be used when performing the post processing.
  95930. * @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)
  95931. */
  95932. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95933. }
  95934. /**
  95935. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  95936. */
  95937. export class PassCubePostProcess extends PostProcess {
  95938. private _face;
  95939. /**
  95940. * Gets or sets the cube face to display.
  95941. * * 0 is +X
  95942. * * 1 is -X
  95943. * * 2 is +Y
  95944. * * 3 is -Y
  95945. * * 4 is +Z
  95946. * * 5 is -Z
  95947. */
  95948. face: number;
  95949. /**
  95950. * Creates the PassCubePostProcess
  95951. * @param name The name of the effect.
  95952. * @param options The required width/height ratio to downsize to before computing the render pass.
  95953. * @param camera The camera to apply the render pass to.
  95954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95955. * @param engine The engine which the post process will be applied. (default: current engine)
  95956. * @param reusable If the post process can be reused on the same frame. (default: false)
  95957. * @param textureType The type of texture to be used when performing the post processing.
  95958. * @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)
  95959. */
  95960. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95961. }
  95962. }
  95963. declare module BABYLON {
  95964. /** @hidden */
  95965. export var anaglyphPixelShader: {
  95966. name: string;
  95967. shader: string;
  95968. };
  95969. }
  95970. declare module BABYLON {
  95971. /**
  95972. * Postprocess used to generate anaglyphic rendering
  95973. */
  95974. export class AnaglyphPostProcess extends PostProcess {
  95975. private _passedProcess;
  95976. /**
  95977. * Creates a new AnaglyphPostProcess
  95978. * @param name defines postprocess name
  95979. * @param options defines creation options or target ratio scale
  95980. * @param rigCameras defines cameras using this postprocess
  95981. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  95982. * @param engine defines hosting engine
  95983. * @param reusable defines if the postprocess will be reused multiple times per frame
  95984. */
  95985. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  95986. }
  95987. }
  95988. declare module BABYLON {
  95989. /**
  95990. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  95991. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95992. */
  95993. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  95994. /**
  95995. * Creates a new AnaglyphArcRotateCamera
  95996. * @param name defines camera name
  95997. * @param alpha defines alpha angle (in radians)
  95998. * @param beta defines beta angle (in radians)
  95999. * @param radius defines radius
  96000. * @param target defines camera target
  96001. * @param interaxialDistance defines distance between each color axis
  96002. * @param scene defines the hosting scene
  96003. */
  96004. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  96005. /**
  96006. * Gets camera class name
  96007. * @returns AnaglyphArcRotateCamera
  96008. */
  96009. getClassName(): string;
  96010. }
  96011. }
  96012. declare module BABYLON {
  96013. /**
  96014. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96015. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96016. */
  96017. export class AnaglyphFreeCamera extends FreeCamera {
  96018. /**
  96019. * Creates a new AnaglyphFreeCamera
  96020. * @param name defines camera name
  96021. * @param position defines initial position
  96022. * @param interaxialDistance defines distance between each color axis
  96023. * @param scene defines the hosting scene
  96024. */
  96025. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96026. /**
  96027. * Gets camera class name
  96028. * @returns AnaglyphFreeCamera
  96029. */
  96030. getClassName(): string;
  96031. }
  96032. }
  96033. declare module BABYLON {
  96034. /**
  96035. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96036. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96037. */
  96038. export class AnaglyphGamepadCamera extends GamepadCamera {
  96039. /**
  96040. * Creates a new AnaglyphGamepadCamera
  96041. * @param name defines camera name
  96042. * @param position defines initial position
  96043. * @param interaxialDistance defines distance between each color axis
  96044. * @param scene defines the hosting scene
  96045. */
  96046. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96047. /**
  96048. * Gets camera class name
  96049. * @returns AnaglyphGamepadCamera
  96050. */
  96051. getClassName(): string;
  96052. }
  96053. }
  96054. declare module BABYLON {
  96055. /**
  96056. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96057. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96058. */
  96059. export class AnaglyphUniversalCamera extends UniversalCamera {
  96060. /**
  96061. * Creates a new AnaglyphUniversalCamera
  96062. * @param name defines camera name
  96063. * @param position defines initial position
  96064. * @param interaxialDistance defines distance between each color axis
  96065. * @param scene defines the hosting scene
  96066. */
  96067. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96068. /**
  96069. * Gets camera class name
  96070. * @returns AnaglyphUniversalCamera
  96071. */
  96072. getClassName(): string;
  96073. }
  96074. }
  96075. declare module BABYLON {
  96076. /** @hidden */
  96077. export var stereoscopicInterlacePixelShader: {
  96078. name: string;
  96079. shader: string;
  96080. };
  96081. }
  96082. declare module BABYLON {
  96083. /**
  96084. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96085. */
  96086. export class StereoscopicInterlacePostProcess extends PostProcess {
  96087. private _stepSize;
  96088. private _passedProcess;
  96089. /**
  96090. * Initializes a StereoscopicInterlacePostProcess
  96091. * @param name The name of the effect.
  96092. * @param rigCameras The rig cameras to be appled to the post process
  96093. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96095. * @param engine The engine which the post process will be applied. (default: current engine)
  96096. * @param reusable If the post process can be reused on the same frame. (default: false)
  96097. */
  96098. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96099. }
  96100. }
  96101. declare module BABYLON {
  96102. /**
  96103. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96104. * @see http://doc.babylonjs.com/features/cameras
  96105. */
  96106. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96107. /**
  96108. * Creates a new StereoscopicArcRotateCamera
  96109. * @param name defines camera name
  96110. * @param alpha defines alpha angle (in radians)
  96111. * @param beta defines beta angle (in radians)
  96112. * @param radius defines radius
  96113. * @param target defines camera target
  96114. * @param interaxialDistance defines distance between each color axis
  96115. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96116. * @param scene defines the hosting scene
  96117. */
  96118. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96119. /**
  96120. * Gets camera class name
  96121. * @returns StereoscopicArcRotateCamera
  96122. */
  96123. getClassName(): string;
  96124. }
  96125. }
  96126. declare module BABYLON {
  96127. /**
  96128. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96129. * @see http://doc.babylonjs.com/features/cameras
  96130. */
  96131. export class StereoscopicFreeCamera extends FreeCamera {
  96132. /**
  96133. * Creates a new StereoscopicFreeCamera
  96134. * @param name defines camera name
  96135. * @param position defines initial position
  96136. * @param interaxialDistance defines distance between each color axis
  96137. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96138. * @param scene defines the hosting scene
  96139. */
  96140. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96141. /**
  96142. * Gets camera class name
  96143. * @returns StereoscopicFreeCamera
  96144. */
  96145. getClassName(): string;
  96146. }
  96147. }
  96148. declare module BABYLON {
  96149. /**
  96150. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96151. * @see http://doc.babylonjs.com/features/cameras
  96152. */
  96153. export class StereoscopicGamepadCamera extends GamepadCamera {
  96154. /**
  96155. * Creates a new StereoscopicGamepadCamera
  96156. * @param name defines camera name
  96157. * @param position defines initial position
  96158. * @param interaxialDistance defines distance between each color axis
  96159. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96160. * @param scene defines the hosting scene
  96161. */
  96162. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96163. /**
  96164. * Gets camera class name
  96165. * @returns StereoscopicGamepadCamera
  96166. */
  96167. getClassName(): string;
  96168. }
  96169. }
  96170. declare module BABYLON {
  96171. /**
  96172. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96173. * @see http://doc.babylonjs.com/features/cameras
  96174. */
  96175. export class StereoscopicUniversalCamera extends UniversalCamera {
  96176. /**
  96177. * Creates a new StereoscopicUniversalCamera
  96178. * @param name defines camera name
  96179. * @param position defines initial position
  96180. * @param interaxialDistance defines distance between each color axis
  96181. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96182. * @param scene defines the hosting scene
  96183. */
  96184. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96185. /**
  96186. * Gets camera class name
  96187. * @returns StereoscopicUniversalCamera
  96188. */
  96189. getClassName(): string;
  96190. }
  96191. }
  96192. declare module BABYLON {
  96193. /**
  96194. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96195. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96196. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96197. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96198. */
  96199. export class VirtualJoysticksCamera extends FreeCamera {
  96200. /**
  96201. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  96202. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96203. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96204. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96205. * @param name Define the name of the camera in the scene
  96206. * @param position Define the start position of the camera in the scene
  96207. * @param scene Define the scene the camera belongs to
  96208. */
  96209. constructor(name: string, position: Vector3, scene: Scene);
  96210. /**
  96211. * Gets the current object class name.
  96212. * @return the class name
  96213. */
  96214. getClassName(): string;
  96215. }
  96216. }
  96217. declare module BABYLON {
  96218. /**
  96219. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  96220. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96221. */
  96222. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  96223. /**
  96224. * Creates a new VRDeviceOrientationArcRotateCamera
  96225. * @param name defines camera name
  96226. * @param alpha defines the camera rotation along the logitudinal axis
  96227. * @param beta defines the camera rotation along the latitudinal axis
  96228. * @param radius defines the camera distance from its target
  96229. * @param target defines the camera target
  96230. * @param scene defines the scene the camera belongs to
  96231. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96232. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96233. */
  96234. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96235. /**
  96236. * Gets camera class name
  96237. * @returns VRDeviceOrientationArcRotateCamera
  96238. */
  96239. getClassName(): string;
  96240. }
  96241. }
  96242. declare module BABYLON {
  96243. /**
  96244. * Camera used to simulate VR rendering (based on FreeCamera)
  96245. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96246. */
  96247. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  96248. /**
  96249. * Creates a new VRDeviceOrientationFreeCamera
  96250. * @param name defines camera name
  96251. * @param position defines the start position of the camera
  96252. * @param scene defines the scene the camera belongs to
  96253. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96254. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96255. */
  96256. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96257. /**
  96258. * Gets camera class name
  96259. * @returns VRDeviceOrientationFreeCamera
  96260. */
  96261. getClassName(): string;
  96262. }
  96263. }
  96264. declare module BABYLON {
  96265. /**
  96266. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  96267. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96268. */
  96269. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  96270. /**
  96271. * Creates a new VRDeviceOrientationGamepadCamera
  96272. * @param name defines camera name
  96273. * @param position defines the start position of the camera
  96274. * @param scene defines the scene the camera belongs to
  96275. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96276. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96277. */
  96278. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96279. /**
  96280. * Gets camera class name
  96281. * @returns VRDeviceOrientationGamepadCamera
  96282. */
  96283. getClassName(): string;
  96284. }
  96285. }
  96286. declare module BABYLON {
  96287. /**
  96288. * Defines supported buttons for XBox360 compatible gamepads
  96289. */
  96290. export enum Xbox360Button {
  96291. /** A */
  96292. A = 0,
  96293. /** B */
  96294. B = 1,
  96295. /** X */
  96296. X = 2,
  96297. /** Y */
  96298. Y = 3,
  96299. /** Start */
  96300. Start = 4,
  96301. /** Back */
  96302. Back = 5,
  96303. /** Left button */
  96304. LB = 6,
  96305. /** Right button */
  96306. RB = 7,
  96307. /** Left stick */
  96308. LeftStick = 8,
  96309. /** Right stick */
  96310. RightStick = 9
  96311. }
  96312. /** Defines values for XBox360 DPad */
  96313. export enum Xbox360Dpad {
  96314. /** Up */
  96315. Up = 0,
  96316. /** Down */
  96317. Down = 1,
  96318. /** Left */
  96319. Left = 2,
  96320. /** Right */
  96321. Right = 3
  96322. }
  96323. /**
  96324. * Defines a XBox360 gamepad
  96325. */
  96326. export class Xbox360Pad extends Gamepad {
  96327. private _leftTrigger;
  96328. private _rightTrigger;
  96329. private _onlefttriggerchanged;
  96330. private _onrighttriggerchanged;
  96331. private _onbuttondown;
  96332. private _onbuttonup;
  96333. private _ondpaddown;
  96334. private _ondpadup;
  96335. /** Observable raised when a button is pressed */
  96336. onButtonDownObservable: Observable<Xbox360Button>;
  96337. /** Observable raised when a button is released */
  96338. onButtonUpObservable: Observable<Xbox360Button>;
  96339. /** Observable raised when a pad is pressed */
  96340. onPadDownObservable: Observable<Xbox360Dpad>;
  96341. /** Observable raised when a pad is released */
  96342. onPadUpObservable: Observable<Xbox360Dpad>;
  96343. private _buttonA;
  96344. private _buttonB;
  96345. private _buttonX;
  96346. private _buttonY;
  96347. private _buttonBack;
  96348. private _buttonStart;
  96349. private _buttonLB;
  96350. private _buttonRB;
  96351. private _buttonLeftStick;
  96352. private _buttonRightStick;
  96353. private _dPadUp;
  96354. private _dPadDown;
  96355. private _dPadLeft;
  96356. private _dPadRight;
  96357. private _isXboxOnePad;
  96358. /**
  96359. * Creates a new XBox360 gamepad object
  96360. * @param id defines the id of this gamepad
  96361. * @param index defines its index
  96362. * @param gamepad defines the internal HTML gamepad object
  96363. * @param xboxOne defines if it is a XBox One gamepad
  96364. */
  96365. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  96366. /**
  96367. * Defines the callback to call when left trigger is pressed
  96368. * @param callback defines the callback to use
  96369. */
  96370. onlefttriggerchanged(callback: (value: number) => void): void;
  96371. /**
  96372. * Defines the callback to call when right trigger is pressed
  96373. * @param callback defines the callback to use
  96374. */
  96375. onrighttriggerchanged(callback: (value: number) => void): void;
  96376. /**
  96377. * Gets the left trigger value
  96378. */
  96379. /**
  96380. * Sets the left trigger value
  96381. */
  96382. leftTrigger: number;
  96383. /**
  96384. * Gets the right trigger value
  96385. */
  96386. /**
  96387. * Sets the right trigger value
  96388. */
  96389. rightTrigger: number;
  96390. /**
  96391. * Defines the callback to call when a button is pressed
  96392. * @param callback defines the callback to use
  96393. */
  96394. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  96395. /**
  96396. * Defines the callback to call when a button is released
  96397. * @param callback defines the callback to use
  96398. */
  96399. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  96400. /**
  96401. * Defines the callback to call when a pad is pressed
  96402. * @param callback defines the callback to use
  96403. */
  96404. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  96405. /**
  96406. * Defines the callback to call when a pad is released
  96407. * @param callback defines the callback to use
  96408. */
  96409. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  96410. private _setButtonValue;
  96411. private _setDPadValue;
  96412. /**
  96413. * Gets the value of the `A` button
  96414. */
  96415. /**
  96416. * Sets the value of the `A` button
  96417. */
  96418. buttonA: number;
  96419. /**
  96420. * Gets the value of the `B` button
  96421. */
  96422. /**
  96423. * Sets the value of the `B` button
  96424. */
  96425. buttonB: number;
  96426. /**
  96427. * Gets the value of the `X` button
  96428. */
  96429. /**
  96430. * Sets the value of the `X` button
  96431. */
  96432. buttonX: number;
  96433. /**
  96434. * Gets the value of the `Y` button
  96435. */
  96436. /**
  96437. * Sets the value of the `Y` button
  96438. */
  96439. buttonY: number;
  96440. /**
  96441. * Gets the value of the `Start` button
  96442. */
  96443. /**
  96444. * Sets the value of the `Start` button
  96445. */
  96446. buttonStart: number;
  96447. /**
  96448. * Gets the value of the `Back` button
  96449. */
  96450. /**
  96451. * Sets the value of the `Back` button
  96452. */
  96453. buttonBack: number;
  96454. /**
  96455. * Gets the value of the `Left` button
  96456. */
  96457. /**
  96458. * Sets the value of the `Left` button
  96459. */
  96460. buttonLB: number;
  96461. /**
  96462. * Gets the value of the `Right` button
  96463. */
  96464. /**
  96465. * Sets the value of the `Right` button
  96466. */
  96467. buttonRB: number;
  96468. /**
  96469. * Gets the value of the Left joystick
  96470. */
  96471. /**
  96472. * Sets the value of the Left joystick
  96473. */
  96474. buttonLeftStick: number;
  96475. /**
  96476. * Gets the value of the Right joystick
  96477. */
  96478. /**
  96479. * Sets the value of the Right joystick
  96480. */
  96481. buttonRightStick: number;
  96482. /**
  96483. * Gets the value of D-pad up
  96484. */
  96485. /**
  96486. * Sets the value of D-pad up
  96487. */
  96488. dPadUp: number;
  96489. /**
  96490. * Gets the value of D-pad down
  96491. */
  96492. /**
  96493. * Sets the value of D-pad down
  96494. */
  96495. dPadDown: number;
  96496. /**
  96497. * Gets the value of D-pad left
  96498. */
  96499. /**
  96500. * Sets the value of D-pad left
  96501. */
  96502. dPadLeft: number;
  96503. /**
  96504. * Gets the value of D-pad right
  96505. */
  96506. /**
  96507. * Sets the value of D-pad right
  96508. */
  96509. dPadRight: number;
  96510. /**
  96511. * Force the gamepad to synchronize with device values
  96512. */
  96513. update(): void;
  96514. /**
  96515. * Disposes the gamepad
  96516. */
  96517. dispose(): void;
  96518. }
  96519. }
  96520. declare module BABYLON {
  96521. /**
  96522. * Base class of materials working in push mode in babylon JS
  96523. * @hidden
  96524. */
  96525. export class PushMaterial extends Material {
  96526. protected _activeEffect: Effect;
  96527. protected _normalMatrix: Matrix;
  96528. /**
  96529. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96530. * This means that the material can keep using a previous shader while a new one is being compiled.
  96531. * This is mostly used when shader parallel compilation is supported (true by default)
  96532. */
  96533. allowShaderHotSwapping: boolean;
  96534. constructor(name: string, scene: Scene);
  96535. getEffect(): Effect;
  96536. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96537. /**
  96538. * Binds the given world matrix to the active effect
  96539. *
  96540. * @param world the matrix to bind
  96541. */
  96542. bindOnlyWorldMatrix(world: Matrix): void;
  96543. /**
  96544. * Binds the given normal matrix to the active effect
  96545. *
  96546. * @param normalMatrix the matrix to bind
  96547. */
  96548. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96549. bind(world: Matrix, mesh?: Mesh): void;
  96550. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96551. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96552. }
  96553. }
  96554. declare module BABYLON {
  96555. /**
  96556. * This groups all the flags used to control the materials channel.
  96557. */
  96558. export class MaterialFlags {
  96559. private static _DiffuseTextureEnabled;
  96560. /**
  96561. * Are diffuse textures enabled in the application.
  96562. */
  96563. static DiffuseTextureEnabled: boolean;
  96564. private static _AmbientTextureEnabled;
  96565. /**
  96566. * Are ambient textures enabled in the application.
  96567. */
  96568. static AmbientTextureEnabled: boolean;
  96569. private static _OpacityTextureEnabled;
  96570. /**
  96571. * Are opacity textures enabled in the application.
  96572. */
  96573. static OpacityTextureEnabled: boolean;
  96574. private static _ReflectionTextureEnabled;
  96575. /**
  96576. * Are reflection textures enabled in the application.
  96577. */
  96578. static ReflectionTextureEnabled: boolean;
  96579. private static _EmissiveTextureEnabled;
  96580. /**
  96581. * Are emissive textures enabled in the application.
  96582. */
  96583. static EmissiveTextureEnabled: boolean;
  96584. private static _SpecularTextureEnabled;
  96585. /**
  96586. * Are specular textures enabled in the application.
  96587. */
  96588. static SpecularTextureEnabled: boolean;
  96589. private static _BumpTextureEnabled;
  96590. /**
  96591. * Are bump textures enabled in the application.
  96592. */
  96593. static BumpTextureEnabled: boolean;
  96594. private static _LightmapTextureEnabled;
  96595. /**
  96596. * Are lightmap textures enabled in the application.
  96597. */
  96598. static LightmapTextureEnabled: boolean;
  96599. private static _RefractionTextureEnabled;
  96600. /**
  96601. * Are refraction textures enabled in the application.
  96602. */
  96603. static RefractionTextureEnabled: boolean;
  96604. private static _ColorGradingTextureEnabled;
  96605. /**
  96606. * Are color grading textures enabled in the application.
  96607. */
  96608. static ColorGradingTextureEnabled: boolean;
  96609. private static _FresnelEnabled;
  96610. /**
  96611. * Are fresnels enabled in the application.
  96612. */
  96613. static FresnelEnabled: boolean;
  96614. private static _ClearCoatTextureEnabled;
  96615. /**
  96616. * Are clear coat textures enabled in the application.
  96617. */
  96618. static ClearCoatTextureEnabled: boolean;
  96619. private static _ClearCoatBumpTextureEnabled;
  96620. /**
  96621. * Are clear coat bump textures enabled in the application.
  96622. */
  96623. static ClearCoatBumpTextureEnabled: boolean;
  96624. private static _ClearCoatTintTextureEnabled;
  96625. /**
  96626. * Are clear coat tint textures enabled in the application.
  96627. */
  96628. static ClearCoatTintTextureEnabled: boolean;
  96629. private static _SheenTextureEnabled;
  96630. /**
  96631. * Are sheen textures enabled in the application.
  96632. */
  96633. static SheenTextureEnabled: boolean;
  96634. private static _AnisotropicTextureEnabled;
  96635. /**
  96636. * Are anisotropic textures enabled in the application.
  96637. */
  96638. static AnisotropicTextureEnabled: boolean;
  96639. }
  96640. }
  96641. declare module BABYLON {
  96642. /** @hidden */
  96643. export var defaultFragmentDeclaration: {
  96644. name: string;
  96645. shader: string;
  96646. };
  96647. }
  96648. declare module BABYLON {
  96649. /** @hidden */
  96650. export var defaultUboDeclaration: {
  96651. name: string;
  96652. shader: string;
  96653. };
  96654. }
  96655. declare module BABYLON {
  96656. /** @hidden */
  96657. export var lightFragmentDeclaration: {
  96658. name: string;
  96659. shader: string;
  96660. };
  96661. }
  96662. declare module BABYLON {
  96663. /** @hidden */
  96664. export var lightUboDeclaration: {
  96665. name: string;
  96666. shader: string;
  96667. };
  96668. }
  96669. declare module BABYLON {
  96670. /** @hidden */
  96671. export var lightsFragmentFunctions: {
  96672. name: string;
  96673. shader: string;
  96674. };
  96675. }
  96676. declare module BABYLON {
  96677. /** @hidden */
  96678. export var shadowsFragmentFunctions: {
  96679. name: string;
  96680. shader: string;
  96681. };
  96682. }
  96683. declare module BABYLON {
  96684. /** @hidden */
  96685. export var fresnelFunction: {
  96686. name: string;
  96687. shader: string;
  96688. };
  96689. }
  96690. declare module BABYLON {
  96691. /** @hidden */
  96692. export var reflectionFunction: {
  96693. name: string;
  96694. shader: string;
  96695. };
  96696. }
  96697. declare module BABYLON {
  96698. /** @hidden */
  96699. export var bumpFragmentFunctions: {
  96700. name: string;
  96701. shader: string;
  96702. };
  96703. }
  96704. declare module BABYLON {
  96705. /** @hidden */
  96706. export var logDepthDeclaration: {
  96707. name: string;
  96708. shader: string;
  96709. };
  96710. }
  96711. declare module BABYLON {
  96712. /** @hidden */
  96713. export var bumpFragment: {
  96714. name: string;
  96715. shader: string;
  96716. };
  96717. }
  96718. declare module BABYLON {
  96719. /** @hidden */
  96720. export var depthPrePass: {
  96721. name: string;
  96722. shader: string;
  96723. };
  96724. }
  96725. declare module BABYLON {
  96726. /** @hidden */
  96727. export var lightFragment: {
  96728. name: string;
  96729. shader: string;
  96730. };
  96731. }
  96732. declare module BABYLON {
  96733. /** @hidden */
  96734. export var logDepthFragment: {
  96735. name: string;
  96736. shader: string;
  96737. };
  96738. }
  96739. declare module BABYLON {
  96740. /** @hidden */
  96741. export var defaultPixelShader: {
  96742. name: string;
  96743. shader: string;
  96744. };
  96745. }
  96746. declare module BABYLON {
  96747. /** @hidden */
  96748. export var defaultVertexDeclaration: {
  96749. name: string;
  96750. shader: string;
  96751. };
  96752. }
  96753. declare module BABYLON {
  96754. /** @hidden */
  96755. export var bumpVertexDeclaration: {
  96756. name: string;
  96757. shader: string;
  96758. };
  96759. }
  96760. declare module BABYLON {
  96761. /** @hidden */
  96762. export var bumpVertex: {
  96763. name: string;
  96764. shader: string;
  96765. };
  96766. }
  96767. declare module BABYLON {
  96768. /** @hidden */
  96769. export var fogVertex: {
  96770. name: string;
  96771. shader: string;
  96772. };
  96773. }
  96774. declare module BABYLON {
  96775. /** @hidden */
  96776. export var shadowsVertex: {
  96777. name: string;
  96778. shader: string;
  96779. };
  96780. }
  96781. declare module BABYLON {
  96782. /** @hidden */
  96783. export var pointCloudVertex: {
  96784. name: string;
  96785. shader: string;
  96786. };
  96787. }
  96788. declare module BABYLON {
  96789. /** @hidden */
  96790. export var logDepthVertex: {
  96791. name: string;
  96792. shader: string;
  96793. };
  96794. }
  96795. declare module BABYLON {
  96796. /** @hidden */
  96797. export var defaultVertexShader: {
  96798. name: string;
  96799. shader: string;
  96800. };
  96801. }
  96802. declare module BABYLON {
  96803. /** @hidden */
  96804. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96805. MAINUV1: boolean;
  96806. MAINUV2: boolean;
  96807. DIFFUSE: boolean;
  96808. DIFFUSEDIRECTUV: number;
  96809. AMBIENT: boolean;
  96810. AMBIENTDIRECTUV: number;
  96811. OPACITY: boolean;
  96812. OPACITYDIRECTUV: number;
  96813. OPACITYRGB: boolean;
  96814. REFLECTION: boolean;
  96815. EMISSIVE: boolean;
  96816. EMISSIVEDIRECTUV: number;
  96817. SPECULAR: boolean;
  96818. SPECULARDIRECTUV: number;
  96819. BUMP: boolean;
  96820. BUMPDIRECTUV: number;
  96821. PARALLAX: boolean;
  96822. PARALLAXOCCLUSION: boolean;
  96823. SPECULAROVERALPHA: boolean;
  96824. CLIPPLANE: boolean;
  96825. CLIPPLANE2: boolean;
  96826. CLIPPLANE3: boolean;
  96827. CLIPPLANE4: boolean;
  96828. ALPHATEST: boolean;
  96829. DEPTHPREPASS: boolean;
  96830. ALPHAFROMDIFFUSE: boolean;
  96831. POINTSIZE: boolean;
  96832. FOG: boolean;
  96833. SPECULARTERM: boolean;
  96834. DIFFUSEFRESNEL: boolean;
  96835. OPACITYFRESNEL: boolean;
  96836. REFLECTIONFRESNEL: boolean;
  96837. REFRACTIONFRESNEL: boolean;
  96838. EMISSIVEFRESNEL: boolean;
  96839. FRESNEL: boolean;
  96840. NORMAL: boolean;
  96841. UV1: boolean;
  96842. UV2: boolean;
  96843. VERTEXCOLOR: boolean;
  96844. VERTEXALPHA: boolean;
  96845. NUM_BONE_INFLUENCERS: number;
  96846. BonesPerMesh: number;
  96847. BONETEXTURE: boolean;
  96848. INSTANCES: boolean;
  96849. GLOSSINESS: boolean;
  96850. ROUGHNESS: boolean;
  96851. EMISSIVEASILLUMINATION: boolean;
  96852. LINKEMISSIVEWITHDIFFUSE: boolean;
  96853. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96854. LIGHTMAP: boolean;
  96855. LIGHTMAPDIRECTUV: number;
  96856. OBJECTSPACE_NORMALMAP: boolean;
  96857. USELIGHTMAPASSHADOWMAP: boolean;
  96858. REFLECTIONMAP_3D: boolean;
  96859. REFLECTIONMAP_SPHERICAL: boolean;
  96860. REFLECTIONMAP_PLANAR: boolean;
  96861. REFLECTIONMAP_CUBIC: boolean;
  96862. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96863. REFLECTIONMAP_PROJECTION: boolean;
  96864. REFLECTIONMAP_SKYBOX: boolean;
  96865. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96866. REFLECTIONMAP_EXPLICIT: boolean;
  96867. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96868. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96869. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96870. INVERTCUBICMAP: boolean;
  96871. LOGARITHMICDEPTH: boolean;
  96872. REFRACTION: boolean;
  96873. REFRACTIONMAP_3D: boolean;
  96874. REFLECTIONOVERALPHA: boolean;
  96875. TWOSIDEDLIGHTING: boolean;
  96876. SHADOWFLOAT: boolean;
  96877. MORPHTARGETS: boolean;
  96878. MORPHTARGETS_NORMAL: boolean;
  96879. MORPHTARGETS_TANGENT: boolean;
  96880. NUM_MORPH_INFLUENCERS: number;
  96881. NONUNIFORMSCALING: boolean;
  96882. PREMULTIPLYALPHA: boolean;
  96883. IMAGEPROCESSING: boolean;
  96884. VIGNETTE: boolean;
  96885. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96886. VIGNETTEBLENDMODEOPAQUE: boolean;
  96887. TONEMAPPING: boolean;
  96888. TONEMAPPING_ACES: boolean;
  96889. CONTRAST: boolean;
  96890. COLORCURVES: boolean;
  96891. COLORGRADING: boolean;
  96892. COLORGRADING3D: boolean;
  96893. SAMPLER3DGREENDEPTH: boolean;
  96894. SAMPLER3DBGRMAP: boolean;
  96895. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96896. MULTIVIEW: boolean;
  96897. /**
  96898. * If the reflection texture on this material is in linear color space
  96899. * @hidden
  96900. */
  96901. IS_REFLECTION_LINEAR: boolean;
  96902. /**
  96903. * If the refraction texture on this material is in linear color space
  96904. * @hidden
  96905. */
  96906. IS_REFRACTION_LINEAR: boolean;
  96907. EXPOSURE: boolean;
  96908. constructor();
  96909. setReflectionMode(modeToEnable: string): void;
  96910. }
  96911. /**
  96912. * This is the default material used in Babylon. It is the best trade off between quality
  96913. * and performances.
  96914. * @see http://doc.babylonjs.com/babylon101/materials
  96915. */
  96916. export class StandardMaterial extends PushMaterial {
  96917. private _diffuseTexture;
  96918. /**
  96919. * The basic texture of the material as viewed under a light.
  96920. */
  96921. diffuseTexture: Nullable<BaseTexture>;
  96922. private _ambientTexture;
  96923. /**
  96924. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96925. */
  96926. ambientTexture: Nullable<BaseTexture>;
  96927. private _opacityTexture;
  96928. /**
  96929. * Define the transparency of the material from a texture.
  96930. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96931. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96932. */
  96933. opacityTexture: Nullable<BaseTexture>;
  96934. private _reflectionTexture;
  96935. /**
  96936. * Define the texture used to display the reflection.
  96937. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96938. */
  96939. reflectionTexture: Nullable<BaseTexture>;
  96940. private _emissiveTexture;
  96941. /**
  96942. * Define texture of the material as if self lit.
  96943. * This will be mixed in the final result even in the absence of light.
  96944. */
  96945. emissiveTexture: Nullable<BaseTexture>;
  96946. private _specularTexture;
  96947. /**
  96948. * Define how the color and intensity of the highlight given by the light in the material.
  96949. */
  96950. specularTexture: Nullable<BaseTexture>;
  96951. private _bumpTexture;
  96952. /**
  96953. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96954. * 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.
  96955. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96956. */
  96957. bumpTexture: Nullable<BaseTexture>;
  96958. private _lightmapTexture;
  96959. /**
  96960. * Complex lighting can be computationally expensive to compute at runtime.
  96961. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96962. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96963. */
  96964. lightmapTexture: Nullable<BaseTexture>;
  96965. private _refractionTexture;
  96966. /**
  96967. * Define the texture used to display the refraction.
  96968. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96969. */
  96970. refractionTexture: Nullable<BaseTexture>;
  96971. /**
  96972. * The color of the material lit by the environmental background lighting.
  96973. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96974. */
  96975. ambientColor: Color3;
  96976. /**
  96977. * The basic color of the material as viewed under a light.
  96978. */
  96979. diffuseColor: Color3;
  96980. /**
  96981. * Define how the color and intensity of the highlight given by the light in the material.
  96982. */
  96983. specularColor: Color3;
  96984. /**
  96985. * Define the color of the material as if self lit.
  96986. * This will be mixed in the final result even in the absence of light.
  96987. */
  96988. emissiveColor: Color3;
  96989. /**
  96990. * Defines how sharp are the highlights in the material.
  96991. * The bigger the value the sharper giving a more glossy feeling to the result.
  96992. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96993. */
  96994. specularPower: number;
  96995. private _useAlphaFromDiffuseTexture;
  96996. /**
  96997. * Does the transparency come from the diffuse texture alpha channel.
  96998. */
  96999. useAlphaFromDiffuseTexture: boolean;
  97000. private _useEmissiveAsIllumination;
  97001. /**
  97002. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97003. */
  97004. useEmissiveAsIllumination: boolean;
  97005. private _linkEmissiveWithDiffuse;
  97006. /**
  97007. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97008. * the emissive level when the final color is close to one.
  97009. */
  97010. linkEmissiveWithDiffuse: boolean;
  97011. private _useSpecularOverAlpha;
  97012. /**
  97013. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97014. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97015. */
  97016. useSpecularOverAlpha: boolean;
  97017. private _useReflectionOverAlpha;
  97018. /**
  97019. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97020. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97021. */
  97022. useReflectionOverAlpha: boolean;
  97023. private _disableLighting;
  97024. /**
  97025. * Does lights from the scene impacts this material.
  97026. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97027. */
  97028. disableLighting: boolean;
  97029. private _useObjectSpaceNormalMap;
  97030. /**
  97031. * Allows using an object space normal map (instead of tangent space).
  97032. */
  97033. useObjectSpaceNormalMap: boolean;
  97034. private _useParallax;
  97035. /**
  97036. * Is parallax enabled or not.
  97037. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97038. */
  97039. useParallax: boolean;
  97040. private _useParallaxOcclusion;
  97041. /**
  97042. * Is parallax occlusion enabled or not.
  97043. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97044. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97045. */
  97046. useParallaxOcclusion: boolean;
  97047. /**
  97048. * 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.
  97049. */
  97050. parallaxScaleBias: number;
  97051. private _roughness;
  97052. /**
  97053. * Helps to define how blurry the reflections should appears in the material.
  97054. */
  97055. roughness: number;
  97056. /**
  97057. * In case of refraction, define the value of the indice of refraction.
  97058. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97059. */
  97060. indexOfRefraction: number;
  97061. /**
  97062. * Invert the refraction texture alongside the y axis.
  97063. * It can be useful with procedural textures or probe for instance.
  97064. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97065. */
  97066. invertRefractionY: boolean;
  97067. /**
  97068. * Defines the alpha limits in alpha test mode.
  97069. */
  97070. alphaCutOff: number;
  97071. private _useLightmapAsShadowmap;
  97072. /**
  97073. * In case of light mapping, define whether the map contains light or shadow informations.
  97074. */
  97075. useLightmapAsShadowmap: boolean;
  97076. private _diffuseFresnelParameters;
  97077. /**
  97078. * Define the diffuse fresnel parameters of the material.
  97079. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97080. */
  97081. diffuseFresnelParameters: FresnelParameters;
  97082. private _opacityFresnelParameters;
  97083. /**
  97084. * Define the opacity fresnel parameters of the material.
  97085. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97086. */
  97087. opacityFresnelParameters: FresnelParameters;
  97088. private _reflectionFresnelParameters;
  97089. /**
  97090. * Define the reflection fresnel parameters of the material.
  97091. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97092. */
  97093. reflectionFresnelParameters: FresnelParameters;
  97094. private _refractionFresnelParameters;
  97095. /**
  97096. * Define the refraction fresnel parameters of the material.
  97097. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97098. */
  97099. refractionFresnelParameters: FresnelParameters;
  97100. private _emissiveFresnelParameters;
  97101. /**
  97102. * Define the emissive fresnel parameters of the material.
  97103. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97104. */
  97105. emissiveFresnelParameters: FresnelParameters;
  97106. private _useReflectionFresnelFromSpecular;
  97107. /**
  97108. * If true automatically deducts the fresnels values from the material specularity.
  97109. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97110. */
  97111. useReflectionFresnelFromSpecular: boolean;
  97112. private _useGlossinessFromSpecularMapAlpha;
  97113. /**
  97114. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97115. */
  97116. useGlossinessFromSpecularMapAlpha: boolean;
  97117. private _maxSimultaneousLights;
  97118. /**
  97119. * Defines the maximum number of lights that can be used in the material
  97120. */
  97121. maxSimultaneousLights: number;
  97122. private _invertNormalMapX;
  97123. /**
  97124. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97125. */
  97126. invertNormalMapX: boolean;
  97127. private _invertNormalMapY;
  97128. /**
  97129. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97130. */
  97131. invertNormalMapY: boolean;
  97132. private _twoSidedLighting;
  97133. /**
  97134. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97135. */
  97136. twoSidedLighting: boolean;
  97137. /**
  97138. * Default configuration related to image processing available in the standard Material.
  97139. */
  97140. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97141. /**
  97142. * Gets the image processing configuration used either in this material.
  97143. */
  97144. /**
  97145. * Sets the Default image processing configuration used either in the this material.
  97146. *
  97147. * If sets to null, the scene one is in use.
  97148. */
  97149. imageProcessingConfiguration: ImageProcessingConfiguration;
  97150. /**
  97151. * Keep track of the image processing observer to allow dispose and replace.
  97152. */
  97153. private _imageProcessingObserver;
  97154. /**
  97155. * Attaches a new image processing configuration to the Standard Material.
  97156. * @param configuration
  97157. */
  97158. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97159. /**
  97160. * Gets wether the color curves effect is enabled.
  97161. */
  97162. /**
  97163. * Sets wether the color curves effect is enabled.
  97164. */
  97165. cameraColorCurvesEnabled: boolean;
  97166. /**
  97167. * Gets wether the color grading effect is enabled.
  97168. */
  97169. /**
  97170. * Gets wether the color grading effect is enabled.
  97171. */
  97172. cameraColorGradingEnabled: boolean;
  97173. /**
  97174. * Gets wether tonemapping is enabled or not.
  97175. */
  97176. /**
  97177. * Sets wether tonemapping is enabled or not
  97178. */
  97179. cameraToneMappingEnabled: boolean;
  97180. /**
  97181. * The camera exposure used on this material.
  97182. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97183. * This corresponds to a photographic exposure.
  97184. */
  97185. /**
  97186. * The camera exposure used on this material.
  97187. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97188. * This corresponds to a photographic exposure.
  97189. */
  97190. cameraExposure: number;
  97191. /**
  97192. * Gets The camera contrast used on this material.
  97193. */
  97194. /**
  97195. * Sets The camera contrast used on this material.
  97196. */
  97197. cameraContrast: number;
  97198. /**
  97199. * Gets the Color Grading 2D Lookup Texture.
  97200. */
  97201. /**
  97202. * Sets the Color Grading 2D Lookup Texture.
  97203. */
  97204. cameraColorGradingTexture: Nullable<BaseTexture>;
  97205. /**
  97206. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97207. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97208. * 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;
  97209. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97210. */
  97211. /**
  97212. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97213. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97214. * 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;
  97215. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97216. */
  97217. cameraColorCurves: Nullable<ColorCurves>;
  97218. /**
  97219. * Custom callback helping to override the default shader used in the material.
  97220. */
  97221. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97222. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97223. protected _worldViewProjectionMatrix: Matrix;
  97224. protected _globalAmbientColor: Color3;
  97225. protected _useLogarithmicDepth: boolean;
  97226. /**
  97227. * Instantiates a new standard material.
  97228. * This is the default material used in Babylon. It is the best trade off between quality
  97229. * and performances.
  97230. * @see http://doc.babylonjs.com/babylon101/materials
  97231. * @param name Define the name of the material in the scene
  97232. * @param scene Define the scene the material belong to
  97233. */
  97234. constructor(name: string, scene: Scene);
  97235. /**
  97236. * Gets a boolean indicating that current material needs to register RTT
  97237. */
  97238. readonly hasRenderTargetTextures: boolean;
  97239. /**
  97240. * Gets the current class name of the material e.g. "StandardMaterial"
  97241. * Mainly use in serialization.
  97242. * @returns the class name
  97243. */
  97244. getClassName(): string;
  97245. /**
  97246. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97247. * You can try switching to logarithmic depth.
  97248. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97249. */
  97250. useLogarithmicDepth: boolean;
  97251. /**
  97252. * Specifies if the material will require alpha blending
  97253. * @returns a boolean specifying if alpha blending is needed
  97254. */
  97255. needAlphaBlending(): boolean;
  97256. /**
  97257. * Specifies if this material should be rendered in alpha test mode
  97258. * @returns a boolean specifying if an alpha test is needed.
  97259. */
  97260. needAlphaTesting(): boolean;
  97261. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97262. /**
  97263. * Get the texture used for alpha test purpose.
  97264. * @returns the diffuse texture in case of the standard material.
  97265. */
  97266. getAlphaTestTexture(): Nullable<BaseTexture>;
  97267. /**
  97268. * Get if the submesh is ready to be used and all its information available.
  97269. * Child classes can use it to update shaders
  97270. * @param mesh defines the mesh to check
  97271. * @param subMesh defines which submesh to check
  97272. * @param useInstances specifies that instances should be used
  97273. * @returns a boolean indicating that the submesh is ready or not
  97274. */
  97275. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97276. /**
  97277. * Builds the material UBO layouts.
  97278. * Used internally during the effect preparation.
  97279. */
  97280. buildUniformLayout(): void;
  97281. /**
  97282. * Unbinds the material from the mesh
  97283. */
  97284. unbind(): void;
  97285. /**
  97286. * Binds the submesh to this material by preparing the effect and shader to draw
  97287. * @param world defines the world transformation matrix
  97288. * @param mesh defines the mesh containing the submesh
  97289. * @param subMesh defines the submesh to bind the material to
  97290. */
  97291. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97292. /**
  97293. * Get the list of animatables in the material.
  97294. * @returns the list of animatables object used in the material
  97295. */
  97296. getAnimatables(): IAnimatable[];
  97297. /**
  97298. * Gets the active textures from the material
  97299. * @returns an array of textures
  97300. */
  97301. getActiveTextures(): BaseTexture[];
  97302. /**
  97303. * Specifies if the material uses a texture
  97304. * @param texture defines the texture to check against the material
  97305. * @returns a boolean specifying if the material uses the texture
  97306. */
  97307. hasTexture(texture: BaseTexture): boolean;
  97308. /**
  97309. * Disposes the material
  97310. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97311. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97312. */
  97313. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97314. /**
  97315. * Makes a duplicate of the material, and gives it a new name
  97316. * @param name defines the new name for the duplicated material
  97317. * @returns the cloned material
  97318. */
  97319. clone(name: string): StandardMaterial;
  97320. /**
  97321. * Serializes this material in a JSON representation
  97322. * @returns the serialized material object
  97323. */
  97324. serialize(): any;
  97325. /**
  97326. * Creates a standard material from parsed material data
  97327. * @param source defines the JSON representation of the material
  97328. * @param scene defines the hosting scene
  97329. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97330. * @returns a new standard material
  97331. */
  97332. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97333. /**
  97334. * Are diffuse textures enabled in the application.
  97335. */
  97336. static DiffuseTextureEnabled: boolean;
  97337. /**
  97338. * Are ambient textures enabled in the application.
  97339. */
  97340. static AmbientTextureEnabled: boolean;
  97341. /**
  97342. * Are opacity textures enabled in the application.
  97343. */
  97344. static OpacityTextureEnabled: boolean;
  97345. /**
  97346. * Are reflection textures enabled in the application.
  97347. */
  97348. static ReflectionTextureEnabled: boolean;
  97349. /**
  97350. * Are emissive textures enabled in the application.
  97351. */
  97352. static EmissiveTextureEnabled: boolean;
  97353. /**
  97354. * Are specular textures enabled in the application.
  97355. */
  97356. static SpecularTextureEnabled: boolean;
  97357. /**
  97358. * Are bump textures enabled in the application.
  97359. */
  97360. static BumpTextureEnabled: boolean;
  97361. /**
  97362. * Are lightmap textures enabled in the application.
  97363. */
  97364. static LightmapTextureEnabled: boolean;
  97365. /**
  97366. * Are refraction textures enabled in the application.
  97367. */
  97368. static RefractionTextureEnabled: boolean;
  97369. /**
  97370. * Are color grading textures enabled in the application.
  97371. */
  97372. static ColorGradingTextureEnabled: boolean;
  97373. /**
  97374. * Are fresnels enabled in the application.
  97375. */
  97376. static FresnelEnabled: boolean;
  97377. }
  97378. }
  97379. declare module BABYLON {
  97380. /**
  97381. * A class extending Texture allowing drawing on a texture
  97382. * @see http://doc.babylonjs.com/how_to/dynamictexture
  97383. */
  97384. export class DynamicTexture extends Texture {
  97385. private _generateMipMaps;
  97386. private _canvas;
  97387. private _context;
  97388. private _engine;
  97389. /**
  97390. * Creates a DynamicTexture
  97391. * @param name defines the name of the texture
  97392. * @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
  97393. * @param scene defines the scene where you want the texture
  97394. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  97395. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  97396. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  97397. */
  97398. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  97399. /**
  97400. * Get the current class name of the texture useful for serialization or dynamic coding.
  97401. * @returns "DynamicTexture"
  97402. */
  97403. getClassName(): string;
  97404. /**
  97405. * Gets the current state of canRescale
  97406. */
  97407. readonly canRescale: boolean;
  97408. private _recreate;
  97409. /**
  97410. * Scales the texture
  97411. * @param ratio the scale factor to apply to both width and height
  97412. */
  97413. scale(ratio: number): void;
  97414. /**
  97415. * Resizes the texture
  97416. * @param width the new width
  97417. * @param height the new height
  97418. */
  97419. scaleTo(width: number, height: number): void;
  97420. /**
  97421. * Gets the context of the canvas used by the texture
  97422. * @returns the canvas context of the dynamic texture
  97423. */
  97424. getContext(): CanvasRenderingContext2D;
  97425. /**
  97426. * Clears the texture
  97427. */
  97428. clear(): void;
  97429. /**
  97430. * Updates the texture
  97431. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97432. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  97433. */
  97434. update(invertY?: boolean, premulAlpha?: boolean): void;
  97435. /**
  97436. * Draws text onto the texture
  97437. * @param text defines the text to be drawn
  97438. * @param x defines the placement of the text from the left
  97439. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  97440. * @param font defines the font to be used with font-style, font-size, font-name
  97441. * @param color defines the color used for the text
  97442. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  97443. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97444. * @param update defines whether texture is immediately update (default is true)
  97445. */
  97446. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  97447. /**
  97448. * Clones the texture
  97449. * @returns the clone of the texture.
  97450. */
  97451. clone(): DynamicTexture;
  97452. /**
  97453. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  97454. * @returns a serialized dynamic texture object
  97455. */
  97456. serialize(): any;
  97457. /** @hidden */
  97458. _rebuild(): void;
  97459. }
  97460. }
  97461. declare module BABYLON {
  97462. /** @hidden */
  97463. export var imageProcessingPixelShader: {
  97464. name: string;
  97465. shader: string;
  97466. };
  97467. }
  97468. declare module BABYLON {
  97469. /**
  97470. * ImageProcessingPostProcess
  97471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  97472. */
  97473. export class ImageProcessingPostProcess extends PostProcess {
  97474. /**
  97475. * Default configuration related to image processing available in the PBR Material.
  97476. */
  97477. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97478. /**
  97479. * Gets the image processing configuration used either in this material.
  97480. */
  97481. /**
  97482. * Sets the Default image processing configuration used either in the this material.
  97483. *
  97484. * If sets to null, the scene one is in use.
  97485. */
  97486. imageProcessingConfiguration: ImageProcessingConfiguration;
  97487. /**
  97488. * Keep track of the image processing observer to allow dispose and replace.
  97489. */
  97490. private _imageProcessingObserver;
  97491. /**
  97492. * Attaches a new image processing configuration to the PBR Material.
  97493. * @param configuration
  97494. */
  97495. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  97496. /**
  97497. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97498. */
  97499. /**
  97500. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97501. */
  97502. colorCurves: Nullable<ColorCurves>;
  97503. /**
  97504. * Gets wether the color curves effect is enabled.
  97505. */
  97506. /**
  97507. * Sets wether the color curves effect is enabled.
  97508. */
  97509. colorCurvesEnabled: boolean;
  97510. /**
  97511. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97512. */
  97513. /**
  97514. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97515. */
  97516. colorGradingTexture: Nullable<BaseTexture>;
  97517. /**
  97518. * Gets wether the color grading effect is enabled.
  97519. */
  97520. /**
  97521. * Gets wether the color grading effect is enabled.
  97522. */
  97523. colorGradingEnabled: boolean;
  97524. /**
  97525. * Gets exposure used in the effect.
  97526. */
  97527. /**
  97528. * Sets exposure used in the effect.
  97529. */
  97530. exposure: number;
  97531. /**
  97532. * Gets wether tonemapping is enabled or not.
  97533. */
  97534. /**
  97535. * Sets wether tonemapping is enabled or not
  97536. */
  97537. toneMappingEnabled: boolean;
  97538. /**
  97539. * Gets the type of tone mapping effect.
  97540. */
  97541. /**
  97542. * Sets the type of tone mapping effect.
  97543. */
  97544. toneMappingType: number;
  97545. /**
  97546. * Gets contrast used in the effect.
  97547. */
  97548. /**
  97549. * Sets contrast used in the effect.
  97550. */
  97551. contrast: number;
  97552. /**
  97553. * Gets Vignette stretch size.
  97554. */
  97555. /**
  97556. * Sets Vignette stretch size.
  97557. */
  97558. vignetteStretch: number;
  97559. /**
  97560. * Gets Vignette centre X Offset.
  97561. */
  97562. /**
  97563. * Sets Vignette centre X Offset.
  97564. */
  97565. vignetteCentreX: number;
  97566. /**
  97567. * Gets Vignette centre Y Offset.
  97568. */
  97569. /**
  97570. * Sets Vignette centre Y Offset.
  97571. */
  97572. vignetteCentreY: number;
  97573. /**
  97574. * Gets Vignette weight or intensity of the vignette effect.
  97575. */
  97576. /**
  97577. * Sets Vignette weight or intensity of the vignette effect.
  97578. */
  97579. vignetteWeight: number;
  97580. /**
  97581. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97582. * if vignetteEnabled is set to true.
  97583. */
  97584. /**
  97585. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97586. * if vignetteEnabled is set to true.
  97587. */
  97588. vignetteColor: Color4;
  97589. /**
  97590. * Gets Camera field of view used by the Vignette effect.
  97591. */
  97592. /**
  97593. * Sets Camera field of view used by the Vignette effect.
  97594. */
  97595. vignetteCameraFov: number;
  97596. /**
  97597. * Gets the vignette blend mode allowing different kind of effect.
  97598. */
  97599. /**
  97600. * Sets the vignette blend mode allowing different kind of effect.
  97601. */
  97602. vignetteBlendMode: number;
  97603. /**
  97604. * Gets wether the vignette effect is enabled.
  97605. */
  97606. /**
  97607. * Sets wether the vignette effect is enabled.
  97608. */
  97609. vignetteEnabled: boolean;
  97610. private _fromLinearSpace;
  97611. /**
  97612. * Gets wether the input of the processing is in Gamma or Linear Space.
  97613. */
  97614. /**
  97615. * Sets wether the input of the processing is in Gamma or Linear Space.
  97616. */
  97617. fromLinearSpace: boolean;
  97618. /**
  97619. * Defines cache preventing GC.
  97620. */
  97621. private _defines;
  97622. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  97623. /**
  97624. * "ImageProcessingPostProcess"
  97625. * @returns "ImageProcessingPostProcess"
  97626. */
  97627. getClassName(): string;
  97628. protected _updateParameters(): void;
  97629. dispose(camera?: Camera): void;
  97630. }
  97631. }
  97632. declare module BABYLON {
  97633. /**
  97634. * Class containing static functions to help procedurally build meshes
  97635. */
  97636. export class GroundBuilder {
  97637. /**
  97638. * Creates a ground mesh
  97639. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  97640. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  97641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97642. * @param name defines the name of the mesh
  97643. * @param options defines the options used to create the mesh
  97644. * @param scene defines the hosting scene
  97645. * @returns the ground mesh
  97646. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  97647. */
  97648. static CreateGround(name: string, options: {
  97649. width?: number;
  97650. height?: number;
  97651. subdivisions?: number;
  97652. subdivisionsX?: number;
  97653. subdivisionsY?: number;
  97654. updatable?: boolean;
  97655. }, scene: any): Mesh;
  97656. /**
  97657. * Creates a tiled ground mesh
  97658. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  97659. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  97660. * * 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
  97661. * * 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
  97662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97663. * @param name defines the name of the mesh
  97664. * @param options defines the options used to create the mesh
  97665. * @param scene defines the hosting scene
  97666. * @returns the tiled ground mesh
  97667. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  97668. */
  97669. static CreateTiledGround(name: string, options: {
  97670. xmin: number;
  97671. zmin: number;
  97672. xmax: number;
  97673. zmax: number;
  97674. subdivisions?: {
  97675. w: number;
  97676. h: number;
  97677. };
  97678. precision?: {
  97679. w: number;
  97680. h: number;
  97681. };
  97682. updatable?: boolean;
  97683. }, scene: Scene): Mesh;
  97684. /**
  97685. * Creates a ground mesh from a height map
  97686. * * The parameter `url` sets the URL of the height map image resource.
  97687. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  97688. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  97689. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  97690. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  97691. * * 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.
  97692. * * 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).
  97693. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97695. * @param name defines the name of the mesh
  97696. * @param url defines the url to the height map
  97697. * @param options defines the options used to create the mesh
  97698. * @param scene defines the hosting scene
  97699. * @returns the ground mesh
  97700. * @see https://doc.babylonjs.com/babylon101/height_map
  97701. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  97702. */
  97703. static CreateGroundFromHeightMap(name: string, url: string, options: {
  97704. width?: number;
  97705. height?: number;
  97706. subdivisions?: number;
  97707. minHeight?: number;
  97708. maxHeight?: number;
  97709. colorFilter?: Color3;
  97710. alphaFilter?: number;
  97711. updatable?: boolean;
  97712. onReady?: (mesh: GroundMesh) => void;
  97713. }, scene: Scene): GroundMesh;
  97714. }
  97715. }
  97716. declare module BABYLON {
  97717. /**
  97718. * Class containing static functions to help procedurally build meshes
  97719. */
  97720. export class TorusBuilder {
  97721. /**
  97722. * Creates a torus mesh
  97723. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  97724. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  97725. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  97726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97729. * @param name defines the name of the mesh
  97730. * @param options defines the options used to create the mesh
  97731. * @param scene defines the hosting scene
  97732. * @returns the torus mesh
  97733. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  97734. */
  97735. static CreateTorus(name: string, options: {
  97736. diameter?: number;
  97737. thickness?: number;
  97738. tessellation?: number;
  97739. updatable?: boolean;
  97740. sideOrientation?: number;
  97741. frontUVs?: Vector4;
  97742. backUVs?: Vector4;
  97743. }, scene: any): Mesh;
  97744. }
  97745. }
  97746. declare module BABYLON {
  97747. /**
  97748. * Class containing static functions to help procedurally build meshes
  97749. */
  97750. export class CylinderBuilder {
  97751. /**
  97752. * Creates a cylinder or a cone mesh
  97753. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  97754. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  97755. * * 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.
  97756. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  97757. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  97758. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  97759. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  97760. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  97761. * * 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).
  97762. * * 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
  97763. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  97764. * * 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
  97765. * * 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.
  97766. * * If `enclose` is false, a ring surface is one element.
  97767. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  97768. * * 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
  97769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97772. * @param name defines the name of the mesh
  97773. * @param options defines the options used to create the mesh
  97774. * @param scene defines the hosting scene
  97775. * @returns the cylinder mesh
  97776. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  97777. */
  97778. static CreateCylinder(name: string, options: {
  97779. height?: number;
  97780. diameterTop?: number;
  97781. diameterBottom?: number;
  97782. diameter?: number;
  97783. tessellation?: number;
  97784. subdivisions?: number;
  97785. arc?: number;
  97786. faceColors?: Color4[];
  97787. faceUV?: Vector4[];
  97788. updatable?: boolean;
  97789. hasRings?: boolean;
  97790. enclose?: boolean;
  97791. sideOrientation?: number;
  97792. frontUVs?: Vector4;
  97793. backUVs?: Vector4;
  97794. }, scene: any): Mesh;
  97795. }
  97796. }
  97797. declare module BABYLON {
  97798. /**
  97799. * Manager for handling gamepads
  97800. */
  97801. export class GamepadManager {
  97802. private _scene?;
  97803. private _babylonGamepads;
  97804. private _oneGamepadConnected;
  97805. /** @hidden */
  97806. _isMonitoring: boolean;
  97807. private _gamepadEventSupported;
  97808. private _gamepadSupport;
  97809. /**
  97810. * observable to be triggered when the gamepad controller has been connected
  97811. */
  97812. onGamepadConnectedObservable: Observable<Gamepad>;
  97813. /**
  97814. * observable to be triggered when the gamepad controller has been disconnected
  97815. */
  97816. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97817. private _onGamepadConnectedEvent;
  97818. private _onGamepadDisconnectedEvent;
  97819. /**
  97820. * Initializes the gamepad manager
  97821. * @param _scene BabylonJS scene
  97822. */
  97823. constructor(_scene?: Scene | undefined);
  97824. /**
  97825. * The gamepads in the game pad manager
  97826. */
  97827. readonly gamepads: Gamepad[];
  97828. /**
  97829. * Get the gamepad controllers based on type
  97830. * @param type The type of gamepad controller
  97831. * @returns Nullable gamepad
  97832. */
  97833. getGamepadByType(type?: number): Nullable<Gamepad>;
  97834. /**
  97835. * Disposes the gamepad manager
  97836. */
  97837. dispose(): void;
  97838. private _addNewGamepad;
  97839. private _startMonitoringGamepads;
  97840. private _stopMonitoringGamepads;
  97841. /** @hidden */
  97842. _checkGamepadsStatus(): void;
  97843. private _updateGamepadObjects;
  97844. }
  97845. }
  97846. declare module BABYLON {
  97847. interface Scene {
  97848. /** @hidden */
  97849. _gamepadManager: Nullable<GamepadManager>;
  97850. /**
  97851. * Gets the gamepad manager associated with the scene
  97852. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97853. */
  97854. gamepadManager: GamepadManager;
  97855. }
  97856. /**
  97857. * Interface representing a free camera inputs manager
  97858. */
  97859. interface FreeCameraInputsManager {
  97860. /**
  97861. * Adds gamepad input support to the FreeCameraInputsManager.
  97862. * @returns the FreeCameraInputsManager
  97863. */
  97864. addGamepad(): FreeCameraInputsManager;
  97865. }
  97866. /**
  97867. * Interface representing an arc rotate camera inputs manager
  97868. */
  97869. interface ArcRotateCameraInputsManager {
  97870. /**
  97871. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97872. * @returns the camera inputs manager
  97873. */
  97874. addGamepad(): ArcRotateCameraInputsManager;
  97875. }
  97876. /**
  97877. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97878. */
  97879. export class GamepadSystemSceneComponent implements ISceneComponent {
  97880. /**
  97881. * The component name helpfull to identify the component in the list of scene components.
  97882. */
  97883. readonly name: string;
  97884. /**
  97885. * The scene the component belongs to.
  97886. */
  97887. scene: Scene;
  97888. /**
  97889. * Creates a new instance of the component for the given scene
  97890. * @param scene Defines the scene to register the component in
  97891. */
  97892. constructor(scene: Scene);
  97893. /**
  97894. * Registers the component in a given scene
  97895. */
  97896. register(): void;
  97897. /**
  97898. * Rebuilds the elements related to this component in case of
  97899. * context lost for instance.
  97900. */
  97901. rebuild(): void;
  97902. /**
  97903. * Disposes the component and the associated ressources
  97904. */
  97905. dispose(): void;
  97906. private _beforeCameraUpdate;
  97907. }
  97908. }
  97909. declare module BABYLON {
  97910. /**
  97911. * Options to modify the vr teleportation behavior.
  97912. */
  97913. export interface VRTeleportationOptions {
  97914. /**
  97915. * The name of the mesh which should be used as the teleportation floor. (default: null)
  97916. */
  97917. floorMeshName?: string;
  97918. /**
  97919. * A list of meshes to be used as the teleportation floor. (default: empty)
  97920. */
  97921. floorMeshes?: Mesh[];
  97922. }
  97923. /**
  97924. * Options to modify the vr experience helper's behavior.
  97925. */
  97926. export interface VRExperienceHelperOptions extends WebVROptions {
  97927. /**
  97928. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  97929. */
  97930. createDeviceOrientationCamera?: boolean;
  97931. /**
  97932. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  97933. */
  97934. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  97935. /**
  97936. * Uses the main button on the controller to toggle the laser casted. (default: true)
  97937. */
  97938. laserToggle?: boolean;
  97939. /**
  97940. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  97941. */
  97942. floorMeshes?: Mesh[];
  97943. /**
  97944. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  97945. */
  97946. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  97947. }
  97948. /**
  97949. * Event containing information after VR has been entered
  97950. */
  97951. export class OnAfterEnteringVRObservableEvent {
  97952. /**
  97953. * If entering vr was successful
  97954. */
  97955. success: boolean;
  97956. }
  97957. /**
  97958. * Helps to quickly add VR support to an existing scene.
  97959. * See http://doc.babylonjs.com/how_to/webvr_helper
  97960. */
  97961. export class VRExperienceHelper {
  97962. /** Options to modify the vr experience helper's behavior. */
  97963. webVROptions: VRExperienceHelperOptions;
  97964. private _scene;
  97965. private _position;
  97966. private _btnVR;
  97967. private _btnVRDisplayed;
  97968. private _webVRsupported;
  97969. private _webVRready;
  97970. private _webVRrequesting;
  97971. private _webVRpresenting;
  97972. private _hasEnteredVR;
  97973. private _fullscreenVRpresenting;
  97974. private _canvas;
  97975. private _webVRCamera;
  97976. private _vrDeviceOrientationCamera;
  97977. private _deviceOrientationCamera;
  97978. private _existingCamera;
  97979. private _onKeyDown;
  97980. private _onVrDisplayPresentChange;
  97981. private _onVRDisplayChanged;
  97982. private _onVRRequestPresentStart;
  97983. private _onVRRequestPresentComplete;
  97984. /**
  97985. * Observable raised right before entering VR.
  97986. */
  97987. onEnteringVRObservable: Observable<VRExperienceHelper>;
  97988. /**
  97989. * Observable raised when entering VR has completed.
  97990. */
  97991. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  97992. /**
  97993. * Observable raised when exiting VR.
  97994. */
  97995. onExitingVRObservable: Observable<VRExperienceHelper>;
  97996. /**
  97997. * Observable raised when controller mesh is loaded.
  97998. */
  97999. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98000. /** Return this.onEnteringVRObservable
  98001. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  98002. */
  98003. readonly onEnteringVR: Observable<VRExperienceHelper>;
  98004. /** Return this.onExitingVRObservable
  98005. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  98006. */
  98007. readonly onExitingVR: Observable<VRExperienceHelper>;
  98008. /** Return this.onControllerMeshLoadedObservable
  98009. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  98010. */
  98011. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98012. private _rayLength;
  98013. private _useCustomVRButton;
  98014. private _teleportationRequested;
  98015. private _teleportActive;
  98016. private _floorMeshName;
  98017. private _floorMeshesCollection;
  98018. private _rotationAllowed;
  98019. private _teleportBackwardsVector;
  98020. private _teleportationTarget;
  98021. private _isDefaultTeleportationTarget;
  98022. private _postProcessMove;
  98023. private _teleportationFillColor;
  98024. private _teleportationBorderColor;
  98025. private _rotationAngle;
  98026. private _haloCenter;
  98027. private _cameraGazer;
  98028. private _padSensibilityUp;
  98029. private _padSensibilityDown;
  98030. private _leftController;
  98031. private _rightController;
  98032. /**
  98033. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98034. */
  98035. onNewMeshSelected: Observable<AbstractMesh>;
  98036. /**
  98037. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98038. */
  98039. onNewMeshPicked: Observable<PickingInfo>;
  98040. private _circleEase;
  98041. /**
  98042. * Observable raised before camera teleportation
  98043. */
  98044. onBeforeCameraTeleport: Observable<Vector3>;
  98045. /**
  98046. * Observable raised after camera teleportation
  98047. */
  98048. onAfterCameraTeleport: Observable<Vector3>;
  98049. /**
  98050. * Observable raised when current selected mesh gets unselected
  98051. */
  98052. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98053. private _raySelectionPredicate;
  98054. /**
  98055. * To be optionaly changed by user to define custom ray selection
  98056. */
  98057. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  98058. /**
  98059. * To be optionaly changed by user to define custom selection logic (after ray selection)
  98060. */
  98061. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  98062. /**
  98063. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  98064. */
  98065. teleportationEnabled: boolean;
  98066. private _defaultHeight;
  98067. private _teleportationInitialized;
  98068. private _interactionsEnabled;
  98069. private _interactionsRequested;
  98070. private _displayGaze;
  98071. private _displayLaserPointer;
  98072. /**
  98073. * The mesh used to display where the user is going to teleport.
  98074. */
  98075. /**
  98076. * Sets the mesh to be used to display where the user is going to teleport.
  98077. */
  98078. teleportationTarget: Mesh;
  98079. /**
  98080. * 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
  98081. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  98082. * See http://doc.babylonjs.com/resources/baking_transformations
  98083. */
  98084. gazeTrackerMesh: Mesh;
  98085. /**
  98086. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  98087. */
  98088. updateGazeTrackerScale: boolean;
  98089. /**
  98090. * If the gaze trackers color should be updated when selecting meshes
  98091. */
  98092. updateGazeTrackerColor: boolean;
  98093. /**
  98094. * The gaze tracking mesh corresponding to the left controller
  98095. */
  98096. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  98097. /**
  98098. * The gaze tracking mesh corresponding to the right controller
  98099. */
  98100. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  98101. /**
  98102. * If the ray of the gaze should be displayed.
  98103. */
  98104. /**
  98105. * Sets if the ray of the gaze should be displayed.
  98106. */
  98107. displayGaze: boolean;
  98108. /**
  98109. * If the ray of the LaserPointer should be displayed.
  98110. */
  98111. /**
  98112. * Sets if the ray of the LaserPointer should be displayed.
  98113. */
  98114. displayLaserPointer: boolean;
  98115. /**
  98116. * The deviceOrientationCamera used as the camera when not in VR.
  98117. */
  98118. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  98119. /**
  98120. * Based on the current WebVR support, returns the current VR camera used.
  98121. */
  98122. readonly currentVRCamera: Nullable<Camera>;
  98123. /**
  98124. * The webVRCamera which is used when in VR.
  98125. */
  98126. readonly webVRCamera: WebVRFreeCamera;
  98127. /**
  98128. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  98129. */
  98130. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  98131. private readonly _teleportationRequestInitiated;
  98132. /**
  98133. * Defines wether or not Pointer lock should be requested when switching to
  98134. * full screen.
  98135. */
  98136. requestPointerLockOnFullScreen: boolean;
  98137. /**
  98138. * Instantiates a VRExperienceHelper.
  98139. * Helps to quickly add VR support to an existing scene.
  98140. * @param scene The scene the VRExperienceHelper belongs to.
  98141. * @param webVROptions Options to modify the vr experience helper's behavior.
  98142. */
  98143. constructor(scene: Scene,
  98144. /** Options to modify the vr experience helper's behavior. */
  98145. webVROptions?: VRExperienceHelperOptions);
  98146. private _onDefaultMeshLoaded;
  98147. private _onResize;
  98148. private _onFullscreenChange;
  98149. /**
  98150. * Gets a value indicating if we are currently in VR mode.
  98151. */
  98152. readonly isInVRMode: boolean;
  98153. private onVrDisplayPresentChange;
  98154. private onVRDisplayChanged;
  98155. private moveButtonToBottomRight;
  98156. private displayVRButton;
  98157. private updateButtonVisibility;
  98158. private _cachedAngularSensibility;
  98159. /**
  98160. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  98161. * Otherwise, will use the fullscreen API.
  98162. */
  98163. enterVR(): void;
  98164. /**
  98165. * Attempt to exit VR, or fullscreen.
  98166. */
  98167. exitVR(): void;
  98168. /**
  98169. * The position of the vr experience helper.
  98170. */
  98171. /**
  98172. * Sets the position of the vr experience helper.
  98173. */
  98174. position: Vector3;
  98175. /**
  98176. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  98177. */
  98178. enableInteractions(): void;
  98179. private readonly _noControllerIsActive;
  98180. private beforeRender;
  98181. private _isTeleportationFloor;
  98182. /**
  98183. * Adds a floor mesh to be used for teleportation.
  98184. * @param floorMesh the mesh to be used for teleportation.
  98185. */
  98186. addFloorMesh(floorMesh: Mesh): void;
  98187. /**
  98188. * Removes a floor mesh from being used for teleportation.
  98189. * @param floorMesh the mesh to be removed.
  98190. */
  98191. removeFloorMesh(floorMesh: Mesh): void;
  98192. /**
  98193. * Enables interactions and teleportation using the VR controllers and gaze.
  98194. * @param vrTeleportationOptions options to modify teleportation behavior.
  98195. */
  98196. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  98197. private _onNewGamepadConnected;
  98198. private _tryEnableInteractionOnController;
  98199. private _onNewGamepadDisconnected;
  98200. private _enableInteractionOnController;
  98201. private _checkTeleportWithRay;
  98202. private _checkRotate;
  98203. private _checkTeleportBackwards;
  98204. private _enableTeleportationOnController;
  98205. private _createTeleportationCircles;
  98206. private _displayTeleportationTarget;
  98207. private _hideTeleportationTarget;
  98208. private _rotateCamera;
  98209. private _moveTeleportationSelectorTo;
  98210. private _workingVector;
  98211. private _workingQuaternion;
  98212. private _workingMatrix;
  98213. /**
  98214. * Teleports the users feet to the desired location
  98215. * @param location The location where the user's feet should be placed
  98216. */
  98217. teleportCamera(location: Vector3): void;
  98218. private _convertNormalToDirectionOfRay;
  98219. private _castRayAndSelectObject;
  98220. private _notifySelectedMeshUnselected;
  98221. /**
  98222. * Sets the color of the laser ray from the vr controllers.
  98223. * @param color new color for the ray.
  98224. */
  98225. changeLaserColor(color: Color3): void;
  98226. /**
  98227. * Sets the color of the ray from the vr headsets gaze.
  98228. * @param color new color for the ray.
  98229. */
  98230. changeGazeColor(color: Color3): void;
  98231. /**
  98232. * Exits VR and disposes of the vr experience helper
  98233. */
  98234. dispose(): void;
  98235. /**
  98236. * Gets the name of the VRExperienceHelper class
  98237. * @returns "VRExperienceHelper"
  98238. */
  98239. getClassName(): string;
  98240. }
  98241. }
  98242. declare module BABYLON {
  98243. /**
  98244. * Manages an XRSession
  98245. * @see https://doc.babylonjs.com/how_to/webxr
  98246. */
  98247. export class WebXRSessionManager implements IDisposable {
  98248. private scene;
  98249. /**
  98250. * Fires every time a new xrFrame arrives which can be used to update the camera
  98251. */
  98252. onXRFrameObservable: Observable<any>;
  98253. /**
  98254. * Fires when the xr session is ended either by the device or manually done
  98255. */
  98256. onXRSessionEnded: Observable<any>;
  98257. /** @hidden */
  98258. _xrSession: XRSession;
  98259. /** @hidden */
  98260. _frameOfReference: XRFrameOfReference;
  98261. /** @hidden */
  98262. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  98263. /** @hidden */
  98264. _currentXRFrame: Nullable<XRFrame>;
  98265. private _xrNavigator;
  98266. private _xrDevice;
  98267. private _tmpMatrix;
  98268. /**
  98269. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  98270. * @param scene The scene which the session should be created for
  98271. */
  98272. constructor(scene: Scene);
  98273. /**
  98274. * Initializes the manager
  98275. * After initialization enterXR can be called to start an XR session
  98276. * @returns Promise which resolves after it is initialized
  98277. */
  98278. initializeAsync(): Promise<void>;
  98279. /**
  98280. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  98281. * @param sessionCreationOptions xr options to create the session with
  98282. * @param frameOfReferenceType option to configure how the xr pose is expressed
  98283. * @returns Promise which resolves after it enters XR
  98284. */
  98285. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  98286. /**
  98287. * Stops the xrSession and restores the renderloop
  98288. * @returns Promise which resolves after it exits XR
  98289. */
  98290. exitXRAsync(): Promise<void>;
  98291. /**
  98292. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98293. * @param ray ray to cast into the environment
  98294. * @returns Promise which resolves with a collision point in the environment if it exists
  98295. */
  98296. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98297. /**
  98298. * Checks if a session would be supported for the creation options specified
  98299. * @param options creation options to check if they are supported
  98300. * @returns true if supported
  98301. */
  98302. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98303. /**
  98304. * @hidden
  98305. * Converts the render layer of xrSession to a render target
  98306. * @param session session to create render target for
  98307. * @param scene scene the new render target should be created for
  98308. */
  98309. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  98310. /**
  98311. * Disposes of the session manager
  98312. */
  98313. dispose(): void;
  98314. }
  98315. }
  98316. declare module BABYLON {
  98317. /**
  98318. * WebXR Camera which holds the views for the xrSession
  98319. * @see https://doc.babylonjs.com/how_to/webxr
  98320. */
  98321. export class WebXRCamera extends FreeCamera {
  98322. private static _TmpMatrix;
  98323. /**
  98324. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  98325. * @param name the name of the camera
  98326. * @param scene the scene to add the camera to
  98327. */
  98328. constructor(name: string, scene: Scene);
  98329. private _updateNumberOfRigCameras;
  98330. /** @hidden */
  98331. _updateForDualEyeDebugging(pupilDistance?: number): void;
  98332. /**
  98333. * Updates the cameras position from the current pose information of the XR session
  98334. * @param xrSessionManager the session containing pose information
  98335. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  98336. */
  98337. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  98338. }
  98339. }
  98340. declare module BABYLON {
  98341. /**
  98342. * States of the webXR experience
  98343. */
  98344. export enum WebXRState {
  98345. /**
  98346. * Transitioning to being in XR mode
  98347. */
  98348. ENTERING_XR = 0,
  98349. /**
  98350. * Transitioning to non XR mode
  98351. */
  98352. EXITING_XR = 1,
  98353. /**
  98354. * In XR mode and presenting
  98355. */
  98356. IN_XR = 2,
  98357. /**
  98358. * Not entered XR mode
  98359. */
  98360. NOT_IN_XR = 3
  98361. }
  98362. /**
  98363. * Helper class used to enable XR
  98364. * @see https://doc.babylonjs.com/how_to/webxr
  98365. */
  98366. export class WebXRExperienceHelper implements IDisposable {
  98367. private scene;
  98368. /**
  98369. * 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
  98370. */
  98371. container: AbstractMesh;
  98372. /**
  98373. * Camera used to render xr content
  98374. */
  98375. camera: WebXRCamera;
  98376. /**
  98377. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  98378. */
  98379. state: WebXRState;
  98380. private _setState;
  98381. private static _TmpVector;
  98382. /**
  98383. * Fires when the state of the experience helper has changed
  98384. */
  98385. onStateChangedObservable: Observable<WebXRState>;
  98386. /** @hidden */
  98387. _sessionManager: WebXRSessionManager;
  98388. private _nonVRCamera;
  98389. private _originalSceneAutoClear;
  98390. private _supported;
  98391. /**
  98392. * Creates the experience helper
  98393. * @param scene the scene to attach the experience helper to
  98394. * @returns a promise for the experience helper
  98395. */
  98396. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  98397. /**
  98398. * Creates a WebXRExperienceHelper
  98399. * @param scene The scene the helper should be created in
  98400. */
  98401. private constructor();
  98402. /**
  98403. * Exits XR mode and returns the scene to its original state
  98404. * @returns promise that resolves after xr mode has exited
  98405. */
  98406. exitXRAsync(): Promise<void>;
  98407. /**
  98408. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  98409. * @param sessionCreationOptions options for the XR session
  98410. * @param frameOfReference frame of reference of the XR session
  98411. * @returns promise that resolves after xr mode has entered
  98412. */
  98413. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  98414. /**
  98415. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98416. * @param ray ray to cast into the environment
  98417. * @returns Promise which resolves with a collision point in the environment if it exists
  98418. */
  98419. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98420. /**
  98421. * Updates the global position of the camera by moving the camera's container
  98422. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  98423. * @param position The desired global position of the camera
  98424. */
  98425. setPositionOfCameraUsingContainer(position: Vector3): void;
  98426. /**
  98427. * Rotates the xr camera by rotating the camera's container around the camera's position
  98428. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  98429. * @param rotation the desired quaternion rotation to apply to the camera
  98430. */
  98431. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  98432. /**
  98433. * Checks if the creation options are supported by the xr session
  98434. * @param options creation options
  98435. * @returns true if supported
  98436. */
  98437. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98438. /**
  98439. * Disposes of the experience helper
  98440. */
  98441. dispose(): void;
  98442. }
  98443. }
  98444. declare module BABYLON {
  98445. /**
  98446. * Button which can be used to enter a different mode of XR
  98447. */
  98448. export class WebXREnterExitUIButton {
  98449. /** button element */
  98450. element: HTMLElement;
  98451. /** XR initialization options for the button */
  98452. initializationOptions: XRSessionCreationOptions;
  98453. /**
  98454. * Creates a WebXREnterExitUIButton
  98455. * @param element button element
  98456. * @param initializationOptions XR initialization options for the button
  98457. */
  98458. constructor(
  98459. /** button element */
  98460. element: HTMLElement,
  98461. /** XR initialization options for the button */
  98462. initializationOptions: XRSessionCreationOptions);
  98463. /**
  98464. * Overwritable function which can be used to update the button's visuals when the state changes
  98465. * @param activeButton the current active button in the UI
  98466. */
  98467. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  98468. }
  98469. /**
  98470. * Options to create the webXR UI
  98471. */
  98472. export class WebXREnterExitUIOptions {
  98473. /**
  98474. * Context to enter xr with
  98475. */
  98476. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  98477. /**
  98478. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  98479. */
  98480. customButtons?: Array<WebXREnterExitUIButton>;
  98481. }
  98482. /**
  98483. * UI to allow the user to enter/exit XR mode
  98484. */
  98485. export class WebXREnterExitUI implements IDisposable {
  98486. private scene;
  98487. private _overlay;
  98488. private _buttons;
  98489. private _activeButton;
  98490. /**
  98491. * Fired every time the active button is changed.
  98492. *
  98493. * When xr is entered via a button that launches xr that button will be the callback parameter
  98494. *
  98495. * When exiting xr the callback parameter will be null)
  98496. */
  98497. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  98498. /**
  98499. * Creates UI to allow the user to enter/exit XR mode
  98500. * @param scene the scene to add the ui to
  98501. * @param helper the xr experience helper to enter/exit xr with
  98502. * @param options options to configure the UI
  98503. * @returns the created ui
  98504. */
  98505. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  98506. private constructor();
  98507. private _updateButtons;
  98508. /**
  98509. * Disposes of the object
  98510. */
  98511. dispose(): void;
  98512. }
  98513. }
  98514. declare module BABYLON {
  98515. /**
  98516. * Represents an XR input
  98517. */
  98518. export class WebXRController {
  98519. /**
  98520. * 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
  98521. */
  98522. grip?: AbstractMesh;
  98523. /**
  98524. * Pointer which can be used to select objects or attach a visible laser to
  98525. */
  98526. pointer: AbstractMesh;
  98527. /**
  98528. * Creates the controller
  98529. * @see https://doc.babylonjs.com/how_to/webxr
  98530. * @param scene the scene which the controller should be associated to
  98531. */
  98532. constructor(scene: Scene);
  98533. /**
  98534. * Disposes of the object
  98535. */
  98536. dispose(): void;
  98537. }
  98538. /**
  98539. * XR input used to track XR inputs such as controllers/rays
  98540. */
  98541. export class WebXRInput implements IDisposable {
  98542. private helper;
  98543. /**
  98544. * XR controllers being tracked
  98545. */
  98546. controllers: Array<WebXRController>;
  98547. private _tmpMatrix;
  98548. private _frameObserver;
  98549. /**
  98550. * Initializes the WebXRInput
  98551. * @param helper experience helper which the input should be created for
  98552. */
  98553. constructor(helper: WebXRExperienceHelper);
  98554. /**
  98555. * Disposes of the object
  98556. */
  98557. dispose(): void;
  98558. }
  98559. }
  98560. declare module BABYLON {
  98561. /**
  98562. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  98563. */
  98564. export class WebXRManagedOutputCanvas implements IDisposable {
  98565. private _canvas;
  98566. /**
  98567. * xrpresent context of the canvas which can be used to display/mirror xr content
  98568. */
  98569. canvasContext: Nullable<WebGLRenderingContext>;
  98570. /**
  98571. * Initializes the canvas to be added/removed upon entering/exiting xr
  98572. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  98573. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  98574. */
  98575. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  98576. /**
  98577. * Disposes of the object
  98578. */
  98579. dispose(): void;
  98580. private _setManagedOutputCanvas;
  98581. private _addCanvas;
  98582. private _removeCanvas;
  98583. }
  98584. }
  98585. declare module BABYLON {
  98586. /**
  98587. * Contains an array of blocks representing the octree
  98588. */
  98589. export interface IOctreeContainer<T> {
  98590. /**
  98591. * Blocks within the octree
  98592. */
  98593. blocks: Array<OctreeBlock<T>>;
  98594. }
  98595. /**
  98596. * Class used to store a cell in an octree
  98597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98598. */
  98599. export class OctreeBlock<T> {
  98600. /**
  98601. * Gets the content of the current block
  98602. */
  98603. entries: T[];
  98604. /**
  98605. * Gets the list of block children
  98606. */
  98607. blocks: Array<OctreeBlock<T>>;
  98608. private _depth;
  98609. private _maxDepth;
  98610. private _capacity;
  98611. private _minPoint;
  98612. private _maxPoint;
  98613. private _boundingVectors;
  98614. private _creationFunc;
  98615. /**
  98616. * Creates a new block
  98617. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  98618. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  98619. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98620. * @param depth defines the current depth of this block in the octree
  98621. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  98622. * @param creationFunc defines a callback to call when an element is added to the block
  98623. */
  98624. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  98625. /**
  98626. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98627. */
  98628. readonly capacity: number;
  98629. /**
  98630. * Gets the minimum vector (in world space) of the block's bounding box
  98631. */
  98632. readonly minPoint: Vector3;
  98633. /**
  98634. * Gets the maximum vector (in world space) of the block's bounding box
  98635. */
  98636. readonly maxPoint: Vector3;
  98637. /**
  98638. * Add a new element to this block
  98639. * @param entry defines the element to add
  98640. */
  98641. addEntry(entry: T): void;
  98642. /**
  98643. * Remove an element from this block
  98644. * @param entry defines the element to remove
  98645. */
  98646. removeEntry(entry: T): void;
  98647. /**
  98648. * Add an array of elements to this block
  98649. * @param entries defines the array of elements to add
  98650. */
  98651. addEntries(entries: T[]): void;
  98652. /**
  98653. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  98654. * @param frustumPlanes defines the frustum planes to test
  98655. * @param selection defines the array to store current content if selection is positive
  98656. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98657. */
  98658. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98659. /**
  98660. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  98661. * @param sphereCenter defines the bounding sphere center
  98662. * @param sphereRadius defines the bounding sphere radius
  98663. * @param selection defines the array to store current content if selection is positive
  98664. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98665. */
  98666. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98667. /**
  98668. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  98669. * @param ray defines the ray to test with
  98670. * @param selection defines the array to store current content if selection is positive
  98671. */
  98672. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  98673. /**
  98674. * Subdivide the content into child blocks (this block will then be empty)
  98675. */
  98676. createInnerBlocks(): void;
  98677. /**
  98678. * @hidden
  98679. */
  98680. 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;
  98681. }
  98682. }
  98683. declare module BABYLON {
  98684. /**
  98685. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  98686. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98687. */
  98688. export class Octree<T> {
  98689. /** 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.) */
  98690. maxDepth: number;
  98691. /**
  98692. * Blocks within the octree containing objects
  98693. */
  98694. blocks: Array<OctreeBlock<T>>;
  98695. /**
  98696. * Content stored in the octree
  98697. */
  98698. dynamicContent: T[];
  98699. private _maxBlockCapacity;
  98700. private _selectionContent;
  98701. private _creationFunc;
  98702. /**
  98703. * Creates a octree
  98704. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98705. * @param creationFunc function to be used to instatiate the octree
  98706. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  98707. * @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.)
  98708. */
  98709. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  98710. /** 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.) */
  98711. maxDepth?: number);
  98712. /**
  98713. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  98714. * @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);
  98715. * @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);
  98716. * @param entries meshes to be added to the octree blocks
  98717. */
  98718. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  98719. /**
  98720. * Adds a mesh to the octree
  98721. * @param entry Mesh to add to the octree
  98722. */
  98723. addMesh(entry: T): void;
  98724. /**
  98725. * Remove an element from the octree
  98726. * @param entry defines the element to remove
  98727. */
  98728. removeMesh(entry: T): void;
  98729. /**
  98730. * Selects an array of meshes within the frustum
  98731. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  98732. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  98733. * @returns array of meshes within the frustum
  98734. */
  98735. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  98736. /**
  98737. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  98738. * @param sphereCenter defines the bounding sphere center
  98739. * @param sphereRadius defines the bounding sphere radius
  98740. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98741. * @returns an array of objects that intersect the sphere
  98742. */
  98743. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  98744. /**
  98745. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  98746. * @param ray defines the ray to test with
  98747. * @returns array of intersected objects
  98748. */
  98749. intersectsRay(ray: Ray): SmartArray<T>;
  98750. /**
  98751. * Adds a mesh into the octree block if it intersects the block
  98752. */
  98753. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  98754. /**
  98755. * Adds a submesh into the octree block if it intersects the block
  98756. */
  98757. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  98758. }
  98759. }
  98760. declare module BABYLON {
  98761. interface Scene {
  98762. /**
  98763. * @hidden
  98764. * Backing Filed
  98765. */
  98766. _selectionOctree: Octree<AbstractMesh>;
  98767. /**
  98768. * Gets the octree used to boost mesh selection (picking)
  98769. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98770. */
  98771. selectionOctree: Octree<AbstractMesh>;
  98772. /**
  98773. * Creates or updates the octree used to boost selection (picking)
  98774. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98775. * @param maxCapacity defines the maximum capacity per leaf
  98776. * @param maxDepth defines the maximum depth of the octree
  98777. * @returns an octree of AbstractMesh
  98778. */
  98779. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  98780. }
  98781. interface AbstractMesh {
  98782. /**
  98783. * @hidden
  98784. * Backing Field
  98785. */
  98786. _submeshesOctree: Octree<SubMesh>;
  98787. /**
  98788. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  98789. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  98790. * @param maxCapacity defines the maximum size of each block (64 by default)
  98791. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  98792. * @returns the new octree
  98793. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  98794. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98795. */
  98796. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  98797. }
  98798. /**
  98799. * Defines the octree scene component responsible to manage any octrees
  98800. * in a given scene.
  98801. */
  98802. export class OctreeSceneComponent {
  98803. /**
  98804. * The component name helpfull to identify the component in the list of scene components.
  98805. */
  98806. readonly name: string;
  98807. /**
  98808. * The scene the component belongs to.
  98809. */
  98810. scene: Scene;
  98811. /**
  98812. * Indicates if the meshes have been checked to make sure they are isEnabled()
  98813. */
  98814. readonly checksIsEnabled: boolean;
  98815. /**
  98816. * Creates a new instance of the component for the given scene
  98817. * @param scene Defines the scene to register the component in
  98818. */
  98819. constructor(scene: Scene);
  98820. /**
  98821. * Registers the component in a given scene
  98822. */
  98823. register(): void;
  98824. /**
  98825. * Return the list of active meshes
  98826. * @returns the list of active meshes
  98827. */
  98828. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98829. /**
  98830. * Return the list of active sub meshes
  98831. * @param mesh The mesh to get the candidates sub meshes from
  98832. * @returns the list of active sub meshes
  98833. */
  98834. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98835. private _tempRay;
  98836. /**
  98837. * Return the list of sub meshes intersecting with a given local ray
  98838. * @param mesh defines the mesh to find the submesh for
  98839. * @param localRay defines the ray in local space
  98840. * @returns the list of intersecting sub meshes
  98841. */
  98842. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  98843. /**
  98844. * Return the list of sub meshes colliding with a collider
  98845. * @param mesh defines the mesh to find the submesh for
  98846. * @param collider defines the collider to evaluate the collision against
  98847. * @returns the list of colliding sub meshes
  98848. */
  98849. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  98850. /**
  98851. * Rebuilds the elements related to this component in case of
  98852. * context lost for instance.
  98853. */
  98854. rebuild(): void;
  98855. /**
  98856. * Disposes the component and the associated ressources.
  98857. */
  98858. dispose(): void;
  98859. }
  98860. }
  98861. declare module BABYLON {
  98862. /**
  98863. * Class containing static functions to help procedurally build meshes
  98864. */
  98865. export class LinesBuilder {
  98866. /**
  98867. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  98868. * * 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
  98869. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  98870. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  98871. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  98872. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  98873. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  98874. * * 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
  98875. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  98876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  98878. * @param name defines the name of the new line system
  98879. * @param options defines the options used to create the line system
  98880. * @param scene defines the hosting scene
  98881. * @returns a new line system mesh
  98882. */
  98883. static CreateLineSystem(name: string, options: {
  98884. lines: Vector3[][];
  98885. updatable?: boolean;
  98886. instance?: Nullable<LinesMesh>;
  98887. colors?: Nullable<Color4[][]>;
  98888. useVertexAlpha?: boolean;
  98889. }, scene: Nullable<Scene>): LinesMesh;
  98890. /**
  98891. * Creates a line mesh
  98892. * 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
  98893. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98894. * * The parameter `points` is an array successive Vector3
  98895. * * 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
  98896. * * The optional parameter `colors` is an array of successive Color4, one per line point
  98897. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  98898. * * When updating an instance, remember that only point positions can change, not the number of points
  98899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  98901. * @param name defines the name of the new line system
  98902. * @param options defines the options used to create the line system
  98903. * @param scene defines the hosting scene
  98904. * @returns a new line mesh
  98905. */
  98906. static CreateLines(name: string, options: {
  98907. points: Vector3[];
  98908. updatable?: boolean;
  98909. instance?: Nullable<LinesMesh>;
  98910. colors?: Color4[];
  98911. useVertexAlpha?: boolean;
  98912. }, scene?: Nullable<Scene>): LinesMesh;
  98913. /**
  98914. * Creates a dashed line mesh
  98915. * * 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
  98916. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98917. * * The parameter `points` is an array successive Vector3
  98918. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  98919. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  98920. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98921. * * 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
  98922. * * When updating an instance, remember that only point positions can change, not the number of points
  98923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98924. * @param name defines the name of the mesh
  98925. * @param options defines the options used to create the mesh
  98926. * @param scene defines the hosting scene
  98927. * @returns the dashed line mesh
  98928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  98929. */
  98930. static CreateDashedLines(name: string, options: {
  98931. points: Vector3[];
  98932. dashSize?: number;
  98933. gapSize?: number;
  98934. dashNb?: number;
  98935. updatable?: boolean;
  98936. instance?: LinesMesh;
  98937. }, scene?: Nullable<Scene>): LinesMesh;
  98938. }
  98939. }
  98940. declare module BABYLON {
  98941. /**
  98942. * Renders a layer on top of an existing scene
  98943. */
  98944. export class UtilityLayerRenderer implements IDisposable {
  98945. /** the original scene that will be rendered on top of */
  98946. originalScene: Scene;
  98947. private _pointerCaptures;
  98948. private _lastPointerEvents;
  98949. private static _DefaultUtilityLayer;
  98950. private static _DefaultKeepDepthUtilityLayer;
  98951. /**
  98952. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  98953. */
  98954. pickUtilitySceneFirst: boolean;
  98955. /**
  98956. * 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)
  98957. */
  98958. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  98959. /**
  98960. * 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)
  98961. */
  98962. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  98963. /**
  98964. * The scene that is rendered on top of the original scene
  98965. */
  98966. utilityLayerScene: Scene;
  98967. /**
  98968. * If the utility layer should automatically be rendered on top of existing scene
  98969. */
  98970. shouldRender: boolean;
  98971. /**
  98972. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  98973. */
  98974. onlyCheckPointerDownEvents: boolean;
  98975. /**
  98976. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  98977. */
  98978. processAllEvents: boolean;
  98979. /**
  98980. * Observable raised when the pointer move from the utility layer scene to the main scene
  98981. */
  98982. onPointerOutObservable: Observable<number>;
  98983. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  98984. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  98985. private _afterRenderObserver;
  98986. private _sceneDisposeObserver;
  98987. private _originalPointerObserver;
  98988. /**
  98989. * Instantiates a UtilityLayerRenderer
  98990. * @param originalScene the original scene that will be rendered on top of
  98991. * @param handleEvents boolean indicating if the utility layer should handle events
  98992. */
  98993. constructor(
  98994. /** the original scene that will be rendered on top of */
  98995. originalScene: Scene, handleEvents?: boolean);
  98996. private _notifyObservers;
  98997. /**
  98998. * Renders the utility layers scene on top of the original scene
  98999. */
  99000. render(): void;
  99001. /**
  99002. * Disposes of the renderer
  99003. */
  99004. dispose(): void;
  99005. private _updateCamera;
  99006. }
  99007. }
  99008. declare module BABYLON {
  99009. /**
  99010. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  99011. */
  99012. export class Gizmo implements IDisposable {
  99013. /** The utility layer the gizmo will be added to */
  99014. gizmoLayer: UtilityLayerRenderer;
  99015. /**
  99016. * The root mesh of the gizmo
  99017. */
  99018. _rootMesh: Mesh;
  99019. private _attachedMesh;
  99020. /**
  99021. * Ratio for the scale of the gizmo (Default: 1)
  99022. */
  99023. scaleRatio: number;
  99024. private _tmpMatrix;
  99025. /**
  99026. * If a custom mesh has been set (Default: false)
  99027. */
  99028. protected _customMeshSet: boolean;
  99029. /**
  99030. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99031. * * When set, interactions will be enabled
  99032. */
  99033. attachedMesh: Nullable<AbstractMesh>;
  99034. /**
  99035. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99036. * @param mesh The mesh to replace the default mesh of the gizmo
  99037. */
  99038. setCustomMesh(mesh: Mesh): void;
  99039. /**
  99040. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99041. */
  99042. updateGizmoRotationToMatchAttachedMesh: boolean;
  99043. /**
  99044. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99045. */
  99046. updateGizmoPositionToMatchAttachedMesh: boolean;
  99047. /**
  99048. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99049. */
  99050. protected _updateScale: boolean;
  99051. protected _interactionsEnabled: boolean;
  99052. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99053. private _beforeRenderObserver;
  99054. /**
  99055. * Creates a gizmo
  99056. * @param gizmoLayer The utility layer the gizmo will be added to
  99057. */
  99058. constructor(
  99059. /** The utility layer the gizmo will be added to */
  99060. gizmoLayer?: UtilityLayerRenderer);
  99061. private _tempVector;
  99062. /**
  99063. * @hidden
  99064. * Updates the gizmo to match the attached mesh's position/rotation
  99065. */
  99066. protected _update(): void;
  99067. /**
  99068. * Disposes of the gizmo
  99069. */
  99070. dispose(): void;
  99071. }
  99072. }
  99073. declare module BABYLON {
  99074. /**
  99075. * Single axis drag gizmo
  99076. */
  99077. export class AxisDragGizmo extends Gizmo {
  99078. /**
  99079. * Drag behavior responsible for the gizmos dragging interactions
  99080. */
  99081. dragBehavior: PointerDragBehavior;
  99082. private _pointerObserver;
  99083. /**
  99084. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99085. */
  99086. snapDistance: number;
  99087. /**
  99088. * Event that fires each time the gizmo snaps to a new location.
  99089. * * snapDistance is the the change in distance
  99090. */
  99091. onSnapObservable: Observable<{
  99092. snapDistance: number;
  99093. }>;
  99094. /** @hidden */
  99095. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99096. /** @hidden */
  99097. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99098. /**
  99099. * Creates an AxisDragGizmo
  99100. * @param gizmoLayer The utility layer the gizmo will be added to
  99101. * @param dragAxis The axis which the gizmo will be able to drag on
  99102. * @param color The color of the gizmo
  99103. */
  99104. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99105. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99106. /**
  99107. * Disposes of the gizmo
  99108. */
  99109. dispose(): void;
  99110. }
  99111. }
  99112. declare module BABYLON.Debug {
  99113. /**
  99114. * The Axes viewer will show 3 axes in a specific point in space
  99115. */
  99116. export class AxesViewer {
  99117. private _xAxis;
  99118. private _yAxis;
  99119. private _zAxis;
  99120. private _scaleLinesFactor;
  99121. private _instanced;
  99122. /**
  99123. * Gets the hosting scene
  99124. */
  99125. scene: Scene;
  99126. /**
  99127. * Gets or sets a number used to scale line length
  99128. */
  99129. scaleLines: number;
  99130. /** Gets the node hierarchy used to render x-axis */
  99131. readonly xAxis: TransformNode;
  99132. /** Gets the node hierarchy used to render y-axis */
  99133. readonly yAxis: TransformNode;
  99134. /** Gets the node hierarchy used to render z-axis */
  99135. readonly zAxis: TransformNode;
  99136. /**
  99137. * Creates a new AxesViewer
  99138. * @param scene defines the hosting scene
  99139. * @param scaleLines defines a number used to scale line length (1 by default)
  99140. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  99141. * @param xAxis defines the node hierarchy used to render the x-axis
  99142. * @param yAxis defines the node hierarchy used to render the y-axis
  99143. * @param zAxis defines the node hierarchy used to render the z-axis
  99144. */
  99145. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  99146. /**
  99147. * Force the viewer to update
  99148. * @param position defines the position of the viewer
  99149. * @param xaxis defines the x axis of the viewer
  99150. * @param yaxis defines the y axis of the viewer
  99151. * @param zaxis defines the z axis of the viewer
  99152. */
  99153. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  99154. /**
  99155. * Creates an instance of this axes viewer.
  99156. * @returns a new axes viewer with instanced meshes
  99157. */
  99158. createInstance(): AxesViewer;
  99159. /** Releases resources */
  99160. dispose(): void;
  99161. private static _SetRenderingGroupId;
  99162. }
  99163. }
  99164. declare module BABYLON.Debug {
  99165. /**
  99166. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  99167. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  99168. */
  99169. export class BoneAxesViewer extends AxesViewer {
  99170. /**
  99171. * Gets or sets the target mesh where to display the axes viewer
  99172. */
  99173. mesh: Nullable<Mesh>;
  99174. /**
  99175. * Gets or sets the target bone where to display the axes viewer
  99176. */
  99177. bone: Nullable<Bone>;
  99178. /** Gets current position */
  99179. pos: Vector3;
  99180. /** Gets direction of X axis */
  99181. xaxis: Vector3;
  99182. /** Gets direction of Y axis */
  99183. yaxis: Vector3;
  99184. /** Gets direction of Z axis */
  99185. zaxis: Vector3;
  99186. /**
  99187. * Creates a new BoneAxesViewer
  99188. * @param scene defines the hosting scene
  99189. * @param bone defines the target bone
  99190. * @param mesh defines the target mesh
  99191. * @param scaleLines defines a scaling factor for line length (1 by default)
  99192. */
  99193. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  99194. /**
  99195. * Force the viewer to update
  99196. */
  99197. update(): void;
  99198. /** Releases resources */
  99199. dispose(): void;
  99200. }
  99201. }
  99202. declare module BABYLON {
  99203. /**
  99204. * Interface used to define scene explorer extensibility option
  99205. */
  99206. export interface IExplorerExtensibilityOption {
  99207. /**
  99208. * Define the option label
  99209. */
  99210. label: string;
  99211. /**
  99212. * Defines the action to execute on click
  99213. */
  99214. action: (entity: any) => void;
  99215. }
  99216. /**
  99217. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  99218. */
  99219. export interface IExplorerExtensibilityGroup {
  99220. /**
  99221. * Defines a predicate to test if a given type mut be extended
  99222. */
  99223. predicate: (entity: any) => boolean;
  99224. /**
  99225. * Gets the list of options added to a type
  99226. */
  99227. entries: IExplorerExtensibilityOption[];
  99228. }
  99229. /**
  99230. * Interface used to define the options to use to create the Inspector
  99231. */
  99232. export interface IInspectorOptions {
  99233. /**
  99234. * Display in overlay mode (default: false)
  99235. */
  99236. overlay?: boolean;
  99237. /**
  99238. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  99239. */
  99240. globalRoot?: HTMLElement;
  99241. /**
  99242. * Display the Scene explorer
  99243. */
  99244. showExplorer?: boolean;
  99245. /**
  99246. * Display the property inspector
  99247. */
  99248. showInspector?: boolean;
  99249. /**
  99250. * Display in embed mode (both panes on the right)
  99251. */
  99252. embedMode?: boolean;
  99253. /**
  99254. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  99255. */
  99256. handleResize?: boolean;
  99257. /**
  99258. * Allow the panes to popup (default: true)
  99259. */
  99260. enablePopup?: boolean;
  99261. /**
  99262. * Allow the panes to be closed by users (default: true)
  99263. */
  99264. enableClose?: boolean;
  99265. /**
  99266. * Optional list of extensibility entries
  99267. */
  99268. explorerExtensibility?: IExplorerExtensibilityGroup[];
  99269. /**
  99270. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  99271. */
  99272. inspectorURL?: string;
  99273. }
  99274. interface Scene {
  99275. /**
  99276. * @hidden
  99277. * Backing field
  99278. */
  99279. _debugLayer: DebugLayer;
  99280. /**
  99281. * Gets the debug layer (aka Inspector) associated with the scene
  99282. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99283. */
  99284. debugLayer: DebugLayer;
  99285. }
  99286. /**
  99287. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99288. * what is happening in your scene
  99289. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99290. */
  99291. export class DebugLayer {
  99292. /**
  99293. * Define the url to get the inspector script from.
  99294. * By default it uses the babylonjs CDN.
  99295. * @ignoreNaming
  99296. */
  99297. static InspectorURL: string;
  99298. private _scene;
  99299. private BJSINSPECTOR;
  99300. /**
  99301. * Observable triggered when a property is changed through the inspector.
  99302. */
  99303. onPropertyChangedObservable: Observable<{
  99304. object: any;
  99305. property: string;
  99306. value: any;
  99307. initialValue: any;
  99308. }>;
  99309. /**
  99310. * Instantiates a new debug layer.
  99311. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99312. * what is happening in your scene
  99313. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99314. * @param scene Defines the scene to inspect
  99315. */
  99316. constructor(scene: Scene);
  99317. /** Creates the inspector window. */
  99318. private _createInspector;
  99319. /**
  99320. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  99321. * @param entity defines the entity to select
  99322. * @param lineContainerTitle defines the specific block to highlight
  99323. */
  99324. select(entity: any, lineContainerTitle?: string): void;
  99325. /** Get the inspector from bundle or global */
  99326. private _getGlobalInspector;
  99327. /**
  99328. * Get if the inspector is visible or not.
  99329. * @returns true if visible otherwise, false
  99330. */
  99331. isVisible(): boolean;
  99332. /**
  99333. * Hide the inspector and close its window.
  99334. */
  99335. hide(): void;
  99336. /**
  99337. * Launch the debugLayer.
  99338. * @param config Define the configuration of the inspector
  99339. * @return a promise fulfilled when the debug layer is visible
  99340. */
  99341. show(config?: IInspectorOptions): Promise<DebugLayer>;
  99342. }
  99343. }
  99344. declare module BABYLON {
  99345. /**
  99346. * Class containing static functions to help procedurally build meshes
  99347. */
  99348. export class BoxBuilder {
  99349. /**
  99350. * Creates a box mesh
  99351. * * The parameter `size` sets the size (float) of each box side (default 1)
  99352. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  99353. * * 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)
  99354. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  99355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99358. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  99359. * @param name defines the name of the mesh
  99360. * @param options defines the options used to create the mesh
  99361. * @param scene defines the hosting scene
  99362. * @returns the box mesh
  99363. */
  99364. static CreateBox(name: string, options: {
  99365. size?: number;
  99366. width?: number;
  99367. height?: number;
  99368. depth?: number;
  99369. faceUV?: Vector4[];
  99370. faceColors?: Color4[];
  99371. sideOrientation?: number;
  99372. frontUVs?: Vector4;
  99373. backUVs?: Vector4;
  99374. updatable?: boolean;
  99375. }, scene?: Nullable<Scene>): Mesh;
  99376. }
  99377. }
  99378. declare module BABYLON {
  99379. /**
  99380. * Class containing static functions to help procedurally build meshes
  99381. */
  99382. export class SphereBuilder {
  99383. /**
  99384. * Creates a sphere mesh
  99385. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  99386. * * 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`)
  99387. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  99388. * * 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
  99389. * * 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)
  99390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99393. * @param name defines the name of the mesh
  99394. * @param options defines the options used to create the mesh
  99395. * @param scene defines the hosting scene
  99396. * @returns the sphere mesh
  99397. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  99398. */
  99399. static CreateSphere(name: string, options: {
  99400. segments?: number;
  99401. diameter?: number;
  99402. diameterX?: number;
  99403. diameterY?: number;
  99404. diameterZ?: number;
  99405. arc?: number;
  99406. slice?: number;
  99407. sideOrientation?: number;
  99408. frontUVs?: Vector4;
  99409. backUVs?: Vector4;
  99410. updatable?: boolean;
  99411. }, scene: any): Mesh;
  99412. }
  99413. }
  99414. declare module BABYLON.Debug {
  99415. /**
  99416. * Used to show the physics impostor around the specific mesh
  99417. */
  99418. export class PhysicsViewer {
  99419. /** @hidden */
  99420. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  99421. /** @hidden */
  99422. protected _meshes: Array<Nullable<AbstractMesh>>;
  99423. /** @hidden */
  99424. protected _scene: Nullable<Scene>;
  99425. /** @hidden */
  99426. protected _numMeshes: number;
  99427. /** @hidden */
  99428. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  99429. private _renderFunction;
  99430. private _utilityLayer;
  99431. private _debugBoxMesh;
  99432. private _debugSphereMesh;
  99433. private _debugMaterial;
  99434. /**
  99435. * Creates a new PhysicsViewer
  99436. * @param scene defines the hosting scene
  99437. */
  99438. constructor(scene: Scene);
  99439. /** @hidden */
  99440. protected _updateDebugMeshes(): void;
  99441. /**
  99442. * Renders a specified physic impostor
  99443. * @param impostor defines the impostor to render
  99444. * @returns the new debug mesh used to render the impostor
  99445. */
  99446. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  99447. /**
  99448. * Hides a specified physic impostor
  99449. * @param impostor defines the impostor to hide
  99450. */
  99451. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  99452. private _getDebugMaterial;
  99453. private _getDebugBoxMesh;
  99454. private _getDebugSphereMesh;
  99455. private _getDebugMesh;
  99456. /** Releases all resources */
  99457. dispose(): void;
  99458. }
  99459. }
  99460. declare module BABYLON {
  99461. /**
  99462. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99463. * in order to better appreciate the issue one might have.
  99464. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99465. */
  99466. export class RayHelper {
  99467. /**
  99468. * Defines the ray we are currently tryin to visualize.
  99469. */
  99470. ray: Nullable<Ray>;
  99471. private _renderPoints;
  99472. private _renderLine;
  99473. private _renderFunction;
  99474. private _scene;
  99475. private _updateToMeshFunction;
  99476. private _attachedToMesh;
  99477. private _meshSpaceDirection;
  99478. private _meshSpaceOrigin;
  99479. /**
  99480. * Helper function to create a colored helper in a scene in one line.
  99481. * @param ray Defines the ray we are currently tryin to visualize
  99482. * @param scene Defines the scene the ray is used in
  99483. * @param color Defines the color we want to see the ray in
  99484. * @returns The newly created ray helper.
  99485. */
  99486. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  99487. /**
  99488. * Instantiate a new ray helper.
  99489. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99490. * in order to better appreciate the issue one might have.
  99491. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99492. * @param ray Defines the ray we are currently tryin to visualize
  99493. */
  99494. constructor(ray: Ray);
  99495. /**
  99496. * Shows the ray we are willing to debug.
  99497. * @param scene Defines the scene the ray needs to be rendered in
  99498. * @param color Defines the color the ray needs to be rendered in
  99499. */
  99500. show(scene: Scene, color?: Color3): void;
  99501. /**
  99502. * Hides the ray we are debugging.
  99503. */
  99504. hide(): void;
  99505. private _render;
  99506. /**
  99507. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  99508. * @param mesh Defines the mesh we want the helper attached to
  99509. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  99510. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  99511. * @param length Defines the length of the ray
  99512. */
  99513. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  99514. /**
  99515. * Detach the ray helper from the mesh it has previously been attached to.
  99516. */
  99517. detachFromMesh(): void;
  99518. private _updateToMesh;
  99519. /**
  99520. * Dispose the helper and release its associated resources.
  99521. */
  99522. dispose(): void;
  99523. }
  99524. }
  99525. declare module BABYLON.Debug {
  99526. /**
  99527. * Class used to render a debug view of a given skeleton
  99528. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  99529. */
  99530. export class SkeletonViewer {
  99531. /** defines the skeleton to render */
  99532. skeleton: Skeleton;
  99533. /** defines the mesh attached to the skeleton */
  99534. mesh: AbstractMesh;
  99535. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99536. autoUpdateBonesMatrices: boolean;
  99537. /** defines the rendering group id to use with the viewer */
  99538. renderingGroupId: number;
  99539. /** Gets or sets the color used to render the skeleton */
  99540. color: Color3;
  99541. private _scene;
  99542. private _debugLines;
  99543. private _debugMesh;
  99544. private _isEnabled;
  99545. private _renderFunction;
  99546. private _utilityLayer;
  99547. /**
  99548. * Returns the mesh used to render the bones
  99549. */
  99550. readonly debugMesh: Nullable<LinesMesh>;
  99551. /**
  99552. * Creates a new SkeletonViewer
  99553. * @param skeleton defines the skeleton to render
  99554. * @param mesh defines the mesh attached to the skeleton
  99555. * @param scene defines the hosting scene
  99556. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  99557. * @param renderingGroupId defines the rendering group id to use with the viewer
  99558. */
  99559. constructor(
  99560. /** defines the skeleton to render */
  99561. skeleton: Skeleton,
  99562. /** defines the mesh attached to the skeleton */
  99563. mesh: AbstractMesh, scene: Scene,
  99564. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99565. autoUpdateBonesMatrices?: boolean,
  99566. /** defines the rendering group id to use with the viewer */
  99567. renderingGroupId?: number);
  99568. /** Gets or sets a boolean indicating if the viewer is enabled */
  99569. isEnabled: boolean;
  99570. private _getBonePosition;
  99571. private _getLinesForBonesWithLength;
  99572. private _getLinesForBonesNoLength;
  99573. /** Update the viewer to sync with current skeleton state */
  99574. update(): void;
  99575. /** Release associated resources */
  99576. dispose(): void;
  99577. }
  99578. }
  99579. declare module BABYLON {
  99580. /**
  99581. * Options to create the null engine
  99582. */
  99583. export class NullEngineOptions {
  99584. /**
  99585. * Render width (Default: 512)
  99586. */
  99587. renderWidth: number;
  99588. /**
  99589. * Render height (Default: 256)
  99590. */
  99591. renderHeight: number;
  99592. /**
  99593. * Texture size (Default: 512)
  99594. */
  99595. textureSize: number;
  99596. /**
  99597. * If delta time between frames should be constant
  99598. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99599. */
  99600. deterministicLockstep: boolean;
  99601. /**
  99602. * Maximum about of steps between frames (Default: 4)
  99603. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99604. */
  99605. lockstepMaxSteps: number;
  99606. }
  99607. /**
  99608. * The null engine class provides support for headless version of babylon.js.
  99609. * This can be used in server side scenario or for testing purposes
  99610. */
  99611. export class NullEngine extends Engine {
  99612. private _options;
  99613. /**
  99614. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99615. */
  99616. isDeterministicLockStep(): boolean;
  99617. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  99618. getLockstepMaxSteps(): number;
  99619. /**
  99620. * Sets hardware scaling, used to save performance if needed
  99621. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99622. */
  99623. getHardwareScalingLevel(): number;
  99624. constructor(options?: NullEngineOptions);
  99625. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99626. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  99627. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99628. getRenderWidth(useScreen?: boolean): number;
  99629. getRenderHeight(useScreen?: boolean): number;
  99630. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  99631. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  99632. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  99633. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  99634. bindSamplers(effect: Effect): void;
  99635. enableEffect(effect: Effect): void;
  99636. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99637. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  99638. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  99639. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  99640. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  99641. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  99642. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  99643. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  99644. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  99645. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  99646. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  99647. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  99648. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  99649. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  99650. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  99651. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99652. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99653. setFloat(uniform: WebGLUniformLocation, value: number): void;
  99654. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  99655. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  99656. setBool(uniform: WebGLUniformLocation, bool: number): void;
  99657. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  99658. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  99659. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  99660. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99661. bindBuffers(vertexBuffers: {
  99662. [key: string]: VertexBuffer;
  99663. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  99664. wipeCaches(bruteForce?: boolean): void;
  99665. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99666. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99667. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99668. /** @hidden */
  99669. _createTexture(): WebGLTexture;
  99670. /** @hidden */
  99671. _releaseTexture(texture: InternalTexture): void;
  99672. 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;
  99673. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  99674. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  99675. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  99676. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99677. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99678. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  99679. areAllEffectsReady(): boolean;
  99680. /**
  99681. * @hidden
  99682. * Get the current error code of the webGL context
  99683. * @returns the error code
  99684. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  99685. */
  99686. getError(): number;
  99687. /** @hidden */
  99688. _getUnpackAlignement(): number;
  99689. /** @hidden */
  99690. _unpackFlipY(value: boolean): void;
  99691. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  99692. /**
  99693. * Updates a dynamic vertex buffer.
  99694. * @param vertexBuffer the vertex buffer to update
  99695. * @param data the data used to update the vertex buffer
  99696. * @param byteOffset the byte offset of the data (optional)
  99697. * @param byteLength the byte length of the data (optional)
  99698. */
  99699. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  99700. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  99701. /** @hidden */
  99702. _bindTexture(channel: number, texture: InternalTexture): void;
  99703. /** @hidden */
  99704. _releaseBuffer(buffer: WebGLBuffer): boolean;
  99705. releaseEffects(): void;
  99706. displayLoadingUI(): void;
  99707. hideLoadingUI(): void;
  99708. /** @hidden */
  99709. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99710. /** @hidden */
  99711. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99712. /** @hidden */
  99713. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99714. /** @hidden */
  99715. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  99716. }
  99717. }
  99718. declare module BABYLON {
  99719. /** @hidden */
  99720. export class _OcclusionDataStorage {
  99721. /** @hidden */
  99722. occlusionInternalRetryCounter: number;
  99723. /** @hidden */
  99724. isOcclusionQueryInProgress: boolean;
  99725. /** @hidden */
  99726. isOccluded: boolean;
  99727. /** @hidden */
  99728. occlusionRetryCount: number;
  99729. /** @hidden */
  99730. occlusionType: number;
  99731. /** @hidden */
  99732. occlusionQueryAlgorithmType: number;
  99733. }
  99734. interface Engine {
  99735. /**
  99736. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  99737. * @return the new query
  99738. */
  99739. createQuery(): WebGLQuery;
  99740. /**
  99741. * Delete and release a webGL query
  99742. * @param query defines the query to delete
  99743. * @return the current engine
  99744. */
  99745. deleteQuery(query: WebGLQuery): Engine;
  99746. /**
  99747. * Check if a given query has resolved and got its value
  99748. * @param query defines the query to check
  99749. * @returns true if the query got its value
  99750. */
  99751. isQueryResultAvailable(query: WebGLQuery): boolean;
  99752. /**
  99753. * Gets the value of a given query
  99754. * @param query defines the query to check
  99755. * @returns the value of the query
  99756. */
  99757. getQueryResult(query: WebGLQuery): number;
  99758. /**
  99759. * Initiates an occlusion query
  99760. * @param algorithmType defines the algorithm to use
  99761. * @param query defines the query to use
  99762. * @returns the current engine
  99763. * @see http://doc.babylonjs.com/features/occlusionquery
  99764. */
  99765. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  99766. /**
  99767. * Ends an occlusion query
  99768. * @see http://doc.babylonjs.com/features/occlusionquery
  99769. * @param algorithmType defines the algorithm to use
  99770. * @returns the current engine
  99771. */
  99772. endOcclusionQuery(algorithmType: number): Engine;
  99773. /**
  99774. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  99775. * Please note that only one query can be issued at a time
  99776. * @returns a time token used to track the time span
  99777. */
  99778. startTimeQuery(): Nullable<_TimeToken>;
  99779. /**
  99780. * Ends a time query
  99781. * @param token defines the token used to measure the time span
  99782. * @returns the time spent (in ns)
  99783. */
  99784. endTimeQuery(token: _TimeToken): int;
  99785. /** @hidden */
  99786. _currentNonTimestampToken: Nullable<_TimeToken>;
  99787. /** @hidden */
  99788. _createTimeQuery(): WebGLQuery;
  99789. /** @hidden */
  99790. _deleteTimeQuery(query: WebGLQuery): void;
  99791. /** @hidden */
  99792. _getGlAlgorithmType(algorithmType: number): number;
  99793. /** @hidden */
  99794. _getTimeQueryResult(query: WebGLQuery): any;
  99795. /** @hidden */
  99796. _getTimeQueryAvailability(query: WebGLQuery): any;
  99797. }
  99798. interface AbstractMesh {
  99799. /**
  99800. * Backing filed
  99801. * @hidden
  99802. */
  99803. __occlusionDataStorage: _OcclusionDataStorage;
  99804. /**
  99805. * Access property
  99806. * @hidden
  99807. */
  99808. _occlusionDataStorage: _OcclusionDataStorage;
  99809. /**
  99810. * 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.
  99811. * The default value is -1 which means don't break the query and wait till the result
  99812. * @see http://doc.babylonjs.com/features/occlusionquery
  99813. */
  99814. occlusionRetryCount: number;
  99815. /**
  99816. * 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:
  99817. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  99818. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  99819. * * 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.
  99820. * @see http://doc.babylonjs.com/features/occlusionquery
  99821. */
  99822. occlusionType: number;
  99823. /**
  99824. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  99825. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  99826. * * 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.
  99827. * @see http://doc.babylonjs.com/features/occlusionquery
  99828. */
  99829. occlusionQueryAlgorithmType: number;
  99830. /**
  99831. * 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
  99832. * @see http://doc.babylonjs.com/features/occlusionquery
  99833. */
  99834. isOccluded: boolean;
  99835. /**
  99836. * Flag to check the progress status of the query
  99837. * @see http://doc.babylonjs.com/features/occlusionquery
  99838. */
  99839. isOcclusionQueryInProgress: boolean;
  99840. }
  99841. }
  99842. declare module BABYLON {
  99843. /** @hidden */
  99844. export var _forceTransformFeedbackToBundle: boolean;
  99845. interface Engine {
  99846. /**
  99847. * Creates a webGL transform feedback object
  99848. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  99849. * @returns the webGL transform feedback object
  99850. */
  99851. createTransformFeedback(): WebGLTransformFeedback;
  99852. /**
  99853. * Delete a webGL transform feedback object
  99854. * @param value defines the webGL transform feedback object to delete
  99855. */
  99856. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  99857. /**
  99858. * Bind a webGL transform feedback object to the webgl context
  99859. * @param value defines the webGL transform feedback object to bind
  99860. */
  99861. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  99862. /**
  99863. * Begins a transform feedback operation
  99864. * @param usePoints defines if points or triangles must be used
  99865. */
  99866. beginTransformFeedback(usePoints: boolean): void;
  99867. /**
  99868. * Ends a transform feedback operation
  99869. */
  99870. endTransformFeedback(): void;
  99871. /**
  99872. * Specify the varyings to use with transform feedback
  99873. * @param program defines the associated webGL program
  99874. * @param value defines the list of strings representing the varying names
  99875. */
  99876. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  99877. /**
  99878. * Bind a webGL buffer for a transform feedback operation
  99879. * @param value defines the webGL buffer to bind
  99880. */
  99881. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  99882. }
  99883. }
  99884. declare module BABYLON {
  99885. /**
  99886. * Gather the list of clipboard event types as constants.
  99887. */
  99888. export class ClipboardEventTypes {
  99889. /**
  99890. * The clipboard event is fired when a copy command is active (pressed).
  99891. */
  99892. static readonly COPY: number;
  99893. /**
  99894. * The clipboard event is fired when a cut command is active (pressed).
  99895. */
  99896. static readonly CUT: number;
  99897. /**
  99898. * The clipboard event is fired when a paste command is active (pressed).
  99899. */
  99900. static readonly PASTE: number;
  99901. }
  99902. /**
  99903. * This class is used to store clipboard related info for the onClipboardObservable event.
  99904. */
  99905. export class ClipboardInfo {
  99906. /**
  99907. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99908. */
  99909. type: number;
  99910. /**
  99911. * Defines the related dom event
  99912. */
  99913. event: ClipboardEvent;
  99914. /**
  99915. *Creates an instance of ClipboardInfo.
  99916. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  99917. * @param event Defines the related dom event
  99918. */
  99919. constructor(
  99920. /**
  99921. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99922. */
  99923. type: number,
  99924. /**
  99925. * Defines the related dom event
  99926. */
  99927. event: ClipboardEvent);
  99928. /**
  99929. * Get the clipboard event's type from the keycode.
  99930. * @param keyCode Defines the keyCode for the current keyboard event.
  99931. * @return {number}
  99932. */
  99933. static GetTypeFromCharacter(keyCode: number): number;
  99934. }
  99935. }
  99936. declare module BABYLON {
  99937. /**
  99938. * Class used to represent data loading progression
  99939. */
  99940. export class SceneLoaderProgressEvent {
  99941. /** defines if data length to load can be evaluated */
  99942. readonly lengthComputable: boolean;
  99943. /** defines the loaded data length */
  99944. readonly loaded: number;
  99945. /** defines the data length to load */
  99946. readonly total: number;
  99947. /**
  99948. * Create a new progress event
  99949. * @param lengthComputable defines if data length to load can be evaluated
  99950. * @param loaded defines the loaded data length
  99951. * @param total defines the data length to load
  99952. */
  99953. constructor(
  99954. /** defines if data length to load can be evaluated */
  99955. lengthComputable: boolean,
  99956. /** defines the loaded data length */
  99957. loaded: number,
  99958. /** defines the data length to load */
  99959. total: number);
  99960. /**
  99961. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  99962. * @param event defines the source event
  99963. * @returns a new SceneLoaderProgressEvent
  99964. */
  99965. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  99966. }
  99967. /**
  99968. * Interface used by SceneLoader plugins to define supported file extensions
  99969. */
  99970. export interface ISceneLoaderPluginExtensions {
  99971. /**
  99972. * Defines the list of supported extensions
  99973. */
  99974. [extension: string]: {
  99975. isBinary: boolean;
  99976. };
  99977. }
  99978. /**
  99979. * Interface used by SceneLoader plugin factory
  99980. */
  99981. export interface ISceneLoaderPluginFactory {
  99982. /**
  99983. * Defines the name of the factory
  99984. */
  99985. name: string;
  99986. /**
  99987. * Function called to create a new plugin
  99988. * @return the new plugin
  99989. */
  99990. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  99991. /**
  99992. * Boolean indicating if the plugin can direct load specific data
  99993. */
  99994. canDirectLoad?: (data: string) => boolean;
  99995. }
  99996. /**
  99997. * Interface used to define a SceneLoader plugin
  99998. */
  99999. export interface ISceneLoaderPlugin {
  100000. /**
  100001. * The friendly name of this plugin.
  100002. */
  100003. name: string;
  100004. /**
  100005. * The file extensions supported by this plugin.
  100006. */
  100007. extensions: string | ISceneLoaderPluginExtensions;
  100008. /**
  100009. * Import meshes into a scene.
  100010. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100011. * @param scene The scene to import into
  100012. * @param data The data to import
  100013. * @param rootUrl The root url for scene and resources
  100014. * @param meshes The meshes array to import into
  100015. * @param particleSystems The particle systems array to import into
  100016. * @param skeletons The skeletons array to import into
  100017. * @param onError The callback when import fails
  100018. * @returns True if successful or false otherwise
  100019. */
  100020. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100021. /**
  100022. * Load into a scene.
  100023. * @param scene The scene to load into
  100024. * @param data The data to import
  100025. * @param rootUrl The root url for scene and resources
  100026. * @param onError The callback when import fails
  100027. * @returns true if successful or false otherwise
  100028. */
  100029. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100030. /**
  100031. * The callback that returns true if the data can be directly loaded.
  100032. */
  100033. canDirectLoad?: (data: string) => boolean;
  100034. /**
  100035. * The callback that allows custom handling of the root url based on the response url.
  100036. */
  100037. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100038. /**
  100039. * Load into an asset container.
  100040. * @param scene The scene to load into
  100041. * @param data The data to import
  100042. * @param rootUrl The root url for scene and resources
  100043. * @param onError The callback when import fails
  100044. * @returns The loaded asset container
  100045. */
  100046. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  100047. }
  100048. /**
  100049. * Interface used to define an async SceneLoader plugin
  100050. */
  100051. export interface ISceneLoaderPluginAsync {
  100052. /**
  100053. * The friendly name of this plugin.
  100054. */
  100055. name: string;
  100056. /**
  100057. * The file extensions supported by this plugin.
  100058. */
  100059. extensions: string | ISceneLoaderPluginExtensions;
  100060. /**
  100061. * Import meshes into a scene.
  100062. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100063. * @param scene The scene to import into
  100064. * @param data The data to import
  100065. * @param rootUrl The root url for scene and resources
  100066. * @param onProgress The callback when the load progresses
  100067. * @param fileName Defines the name of the file to load
  100068. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  100069. */
  100070. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  100071. meshes: AbstractMesh[];
  100072. particleSystems: IParticleSystem[];
  100073. skeletons: Skeleton[];
  100074. animationGroups: AnimationGroup[];
  100075. }>;
  100076. /**
  100077. * Load into a scene.
  100078. * @param scene The scene to load into
  100079. * @param data The data to import
  100080. * @param rootUrl The root url for scene and resources
  100081. * @param onProgress The callback when the load progresses
  100082. * @param fileName Defines the name of the file to load
  100083. * @returns Nothing
  100084. */
  100085. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  100086. /**
  100087. * The callback that returns true if the data can be directly loaded.
  100088. */
  100089. canDirectLoad?: (data: string) => boolean;
  100090. /**
  100091. * The callback that allows custom handling of the root url based on the response url.
  100092. */
  100093. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100094. /**
  100095. * Load into an asset container.
  100096. * @param scene The scene to load into
  100097. * @param data The data to import
  100098. * @param rootUrl The root url for scene and resources
  100099. * @param onProgress The callback when the load progresses
  100100. * @param fileName Defines the name of the file to load
  100101. * @returns The loaded asset container
  100102. */
  100103. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  100104. }
  100105. /**
  100106. * Class used to load scene from various file formats using registered plugins
  100107. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  100108. */
  100109. export class SceneLoader {
  100110. /**
  100111. * No logging while loading
  100112. */
  100113. static readonly NO_LOGGING: number;
  100114. /**
  100115. * Minimal logging while loading
  100116. */
  100117. static readonly MINIMAL_LOGGING: number;
  100118. /**
  100119. * Summary logging while loading
  100120. */
  100121. static readonly SUMMARY_LOGGING: number;
  100122. /**
  100123. * Detailled logging while loading
  100124. */
  100125. static readonly DETAILED_LOGGING: number;
  100126. /**
  100127. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  100128. */
  100129. static ForceFullSceneLoadingForIncremental: boolean;
  100130. /**
  100131. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  100132. */
  100133. static ShowLoadingScreen: boolean;
  100134. /**
  100135. * Defines the current logging level (while loading the scene)
  100136. * @ignorenaming
  100137. */
  100138. static loggingLevel: number;
  100139. /**
  100140. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  100141. */
  100142. static CleanBoneMatrixWeights: boolean;
  100143. /**
  100144. * Event raised when a plugin is used to load a scene
  100145. */
  100146. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  100147. private static _registeredPlugins;
  100148. private static _getDefaultPlugin;
  100149. private static _getPluginForExtension;
  100150. private static _getPluginForDirectLoad;
  100151. private static _getPluginForFilename;
  100152. private static _getDirectLoad;
  100153. private static _loadData;
  100154. private static _getFileInfo;
  100155. /**
  100156. * Gets a plugin that can load the given extension
  100157. * @param extension defines the extension to load
  100158. * @returns a plugin or null if none works
  100159. */
  100160. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  100161. /**
  100162. * Gets a boolean indicating that the given extension can be loaded
  100163. * @param extension defines the extension to load
  100164. * @returns true if the extension is supported
  100165. */
  100166. static IsPluginForExtensionAvailable(extension: string): boolean;
  100167. /**
  100168. * Adds a new plugin to the list of registered plugins
  100169. * @param plugin defines the plugin to add
  100170. */
  100171. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  100172. /**
  100173. * Import meshes into a scene
  100174. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100175. * @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)
  100176. * @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)
  100177. * @param scene the instance of BABYLON.Scene to append to
  100178. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  100179. * @param onProgress a callback with a progress event for each file being loaded
  100180. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100181. * @param pluginExtension the extension used to determine the plugin
  100182. * @returns The loaded plugin
  100183. */
  100184. 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>;
  100185. /**
  100186. * Import meshes into a scene
  100187. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100188. * @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)
  100189. * @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)
  100190. * @param scene the instance of BABYLON.Scene to append to
  100191. * @param onProgress a callback with a progress event for each file being loaded
  100192. * @param pluginExtension the extension used to determine the plugin
  100193. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  100194. */
  100195. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  100196. meshes: AbstractMesh[];
  100197. particleSystems: IParticleSystem[];
  100198. skeletons: Skeleton[];
  100199. animationGroups: AnimationGroup[];
  100200. }>;
  100201. /**
  100202. * Load a scene
  100203. * @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)
  100204. * @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)
  100205. * @param engine is the instance of BABYLON.Engine to use to create the scene
  100206. * @param onSuccess a callback with the scene when import succeeds
  100207. * @param onProgress a callback with a progress event for each file being loaded
  100208. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100209. * @param pluginExtension the extension used to determine the plugin
  100210. * @returns The loaded plugin
  100211. */
  100212. 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>;
  100213. /**
  100214. * Load a scene
  100215. * @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)
  100216. * @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)
  100217. * @param engine is the instance of BABYLON.Engine to use to create the scene
  100218. * @param onProgress a callback with a progress event for each file being loaded
  100219. * @param pluginExtension the extension used to determine the plugin
  100220. * @returns The loaded scene
  100221. */
  100222. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100223. /**
  100224. * Append a scene
  100225. * @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)
  100226. * @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)
  100227. * @param scene is the instance of BABYLON.Scene to append to
  100228. * @param onSuccess a callback with the scene when import succeeds
  100229. * @param onProgress a callback with a progress event for each file being loaded
  100230. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100231. * @param pluginExtension the extension used to determine the plugin
  100232. * @returns The loaded plugin
  100233. */
  100234. 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>;
  100235. /**
  100236. * Append a scene
  100237. * @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)
  100238. * @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)
  100239. * @param scene is the instance of BABYLON.Scene to append to
  100240. * @param onProgress a callback with a progress event for each file being loaded
  100241. * @param pluginExtension the extension used to determine the plugin
  100242. * @returns The given scene
  100243. */
  100244. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100245. /**
  100246. * Load a scene into an asset container
  100247. * @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)
  100248. * @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)
  100249. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  100250. * @param onSuccess a callback with the scene when import succeeds
  100251. * @param onProgress a callback with a progress event for each file being loaded
  100252. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100253. * @param pluginExtension the extension used to determine the plugin
  100254. * @returns The loaded plugin
  100255. */
  100256. 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>;
  100257. /**
  100258. * Load a scene into an asset container
  100259. * @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)
  100260. * @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)
  100261. * @param scene is the instance of Scene to append to
  100262. * @param onProgress a callback with a progress event for each file being loaded
  100263. * @param pluginExtension the extension used to determine the plugin
  100264. * @returns The loaded asset container
  100265. */
  100266. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  100267. }
  100268. }
  100269. declare module BABYLON {
  100270. /**
  100271. * Google Daydream controller
  100272. */
  100273. export class DaydreamController extends WebVRController {
  100274. /**
  100275. * Base Url for the controller model.
  100276. */
  100277. static MODEL_BASE_URL: string;
  100278. /**
  100279. * File name for the controller model.
  100280. */
  100281. static MODEL_FILENAME: string;
  100282. /**
  100283. * Gamepad Id prefix used to identify Daydream Controller.
  100284. */
  100285. static readonly GAMEPAD_ID_PREFIX: string;
  100286. /**
  100287. * Creates a new DaydreamController from a gamepad
  100288. * @param vrGamepad the gamepad that the controller should be created from
  100289. */
  100290. constructor(vrGamepad: any);
  100291. /**
  100292. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100293. * @param scene scene in which to add meshes
  100294. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100295. */
  100296. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100297. /**
  100298. * Called once for each button that changed state since the last frame
  100299. * @param buttonIdx Which button index changed
  100300. * @param state New state of the button
  100301. * @param changes Which properties on the state changed since last frame
  100302. */
  100303. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100304. }
  100305. }
  100306. declare module BABYLON {
  100307. /**
  100308. * Gear VR Controller
  100309. */
  100310. export class GearVRController extends WebVRController {
  100311. /**
  100312. * Base Url for the controller model.
  100313. */
  100314. static MODEL_BASE_URL: string;
  100315. /**
  100316. * File name for the controller model.
  100317. */
  100318. static MODEL_FILENAME: string;
  100319. /**
  100320. * Gamepad Id prefix used to identify this controller.
  100321. */
  100322. static readonly GAMEPAD_ID_PREFIX: string;
  100323. private readonly _buttonIndexToObservableNameMap;
  100324. /**
  100325. * Creates a new GearVRController from a gamepad
  100326. * @param vrGamepad the gamepad that the controller should be created from
  100327. */
  100328. constructor(vrGamepad: any);
  100329. /**
  100330. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100331. * @param scene scene in which to add meshes
  100332. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100333. */
  100334. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100335. /**
  100336. * Called once for each button that changed state since the last frame
  100337. * @param buttonIdx Which button index changed
  100338. * @param state New state of the button
  100339. * @param changes Which properties on the state changed since last frame
  100340. */
  100341. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100342. }
  100343. }
  100344. declare module BABYLON {
  100345. /**
  100346. * Generic Controller
  100347. */
  100348. export class GenericController extends WebVRController {
  100349. /**
  100350. * Base Url for the controller model.
  100351. */
  100352. static readonly MODEL_BASE_URL: string;
  100353. /**
  100354. * File name for the controller model.
  100355. */
  100356. static readonly MODEL_FILENAME: string;
  100357. /**
  100358. * Creates a new GenericController from a gamepad
  100359. * @param vrGamepad the gamepad that the controller should be created from
  100360. */
  100361. constructor(vrGamepad: any);
  100362. /**
  100363. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100364. * @param scene scene in which to add meshes
  100365. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100366. */
  100367. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100368. /**
  100369. * Called once for each button that changed state since the last frame
  100370. * @param buttonIdx Which button index changed
  100371. * @param state New state of the button
  100372. * @param changes Which properties on the state changed since last frame
  100373. */
  100374. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100375. }
  100376. }
  100377. declare module BABYLON {
  100378. /**
  100379. * Oculus Touch Controller
  100380. */
  100381. export class OculusTouchController extends WebVRController {
  100382. /**
  100383. * Base Url for the controller model.
  100384. */
  100385. static MODEL_BASE_URL: string;
  100386. /**
  100387. * File name for the left controller model.
  100388. */
  100389. static MODEL_LEFT_FILENAME: string;
  100390. /**
  100391. * File name for the right controller model.
  100392. */
  100393. static MODEL_RIGHT_FILENAME: string;
  100394. /**
  100395. * Fired when the secondary trigger on this controller is modified
  100396. */
  100397. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100398. /**
  100399. * Fired when the thumb rest on this controller is modified
  100400. */
  100401. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  100402. /**
  100403. * Creates a new OculusTouchController from a gamepad
  100404. * @param vrGamepad the gamepad that the controller should be created from
  100405. */
  100406. constructor(vrGamepad: any);
  100407. /**
  100408. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100409. * @param scene scene in which to add meshes
  100410. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100411. */
  100412. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100413. /**
  100414. * Fired when the A button on this controller is modified
  100415. */
  100416. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100417. /**
  100418. * Fired when the B button on this controller is modified
  100419. */
  100420. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100421. /**
  100422. * Fired when the X button on this controller is modified
  100423. */
  100424. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100425. /**
  100426. * Fired when the Y button on this controller is modified
  100427. */
  100428. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100429. /**
  100430. * Called once for each button that changed state since the last frame
  100431. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  100432. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  100433. * 2) secondary trigger (same)
  100434. * 3) A (right) X (left), touch, pressed = value
  100435. * 4) B / Y
  100436. * 5) thumb rest
  100437. * @param buttonIdx Which button index changed
  100438. * @param state New state of the button
  100439. * @param changes Which properties on the state changed since last frame
  100440. */
  100441. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100442. }
  100443. }
  100444. declare module BABYLON {
  100445. /**
  100446. * Vive Controller
  100447. */
  100448. export class ViveController extends WebVRController {
  100449. /**
  100450. * Base Url for the controller model.
  100451. */
  100452. static MODEL_BASE_URL: string;
  100453. /**
  100454. * File name for the controller model.
  100455. */
  100456. static MODEL_FILENAME: string;
  100457. /**
  100458. * Creates a new ViveController from a gamepad
  100459. * @param vrGamepad the gamepad that the controller should be created from
  100460. */
  100461. constructor(vrGamepad: any);
  100462. /**
  100463. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100464. * @param scene scene in which to add meshes
  100465. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100466. */
  100467. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100468. /**
  100469. * Fired when the left button on this controller is modified
  100470. */
  100471. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100472. /**
  100473. * Fired when the right button on this controller is modified
  100474. */
  100475. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100476. /**
  100477. * Fired when the menu button on this controller is modified
  100478. */
  100479. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100480. /**
  100481. * Called once for each button that changed state since the last frame
  100482. * Vive mapping:
  100483. * 0: touchpad
  100484. * 1: trigger
  100485. * 2: left AND right buttons
  100486. * 3: menu button
  100487. * @param buttonIdx Which button index changed
  100488. * @param state New state of the button
  100489. * @param changes Which properties on the state changed since last frame
  100490. */
  100491. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100492. }
  100493. }
  100494. declare module BABYLON {
  100495. /**
  100496. * Defines the WindowsMotionController object that the state of the windows motion controller
  100497. */
  100498. export class WindowsMotionController extends WebVRController {
  100499. /**
  100500. * The base url used to load the left and right controller models
  100501. */
  100502. static MODEL_BASE_URL: string;
  100503. /**
  100504. * The name of the left controller model file
  100505. */
  100506. static MODEL_LEFT_FILENAME: string;
  100507. /**
  100508. * The name of the right controller model file
  100509. */
  100510. static MODEL_RIGHT_FILENAME: string;
  100511. /**
  100512. * The controller name prefix for this controller type
  100513. */
  100514. static readonly GAMEPAD_ID_PREFIX: string;
  100515. /**
  100516. * The controller id pattern for this controller type
  100517. */
  100518. private static readonly GAMEPAD_ID_PATTERN;
  100519. private _loadedMeshInfo;
  100520. private readonly _mapping;
  100521. /**
  100522. * Fired when the trackpad on this controller is clicked
  100523. */
  100524. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  100525. /**
  100526. * Fired when the trackpad on this controller is modified
  100527. */
  100528. onTrackpadValuesChangedObservable: Observable<StickValues>;
  100529. /**
  100530. * The current x and y values of this controller's trackpad
  100531. */
  100532. trackpad: StickValues;
  100533. /**
  100534. * Creates a new WindowsMotionController from a gamepad
  100535. * @param vrGamepad the gamepad that the controller should be created from
  100536. */
  100537. constructor(vrGamepad: any);
  100538. /**
  100539. * Fired when the trigger on this controller is modified
  100540. */
  100541. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100542. /**
  100543. * Fired when the menu button on this controller is modified
  100544. */
  100545. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100546. /**
  100547. * Fired when the grip button on this controller is modified
  100548. */
  100549. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100550. /**
  100551. * Fired when the thumbstick button on this controller is modified
  100552. */
  100553. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100554. /**
  100555. * Fired when the touchpad button on this controller is modified
  100556. */
  100557. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100558. /**
  100559. * Fired when the touchpad values on this controller are modified
  100560. */
  100561. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  100562. private _updateTrackpad;
  100563. /**
  100564. * Called once per frame by the engine.
  100565. */
  100566. update(): void;
  100567. /**
  100568. * Called once for each button that changed state since the last frame
  100569. * @param buttonIdx Which button index changed
  100570. * @param state New state of the button
  100571. * @param changes Which properties on the state changed since last frame
  100572. */
  100573. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100574. /**
  100575. * Moves the buttons on the controller mesh based on their current state
  100576. * @param buttonName the name of the button to move
  100577. * @param buttonValue the value of the button which determines the buttons new position
  100578. */
  100579. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  100580. /**
  100581. * Moves the axis on the controller mesh based on its current state
  100582. * @param axis the index of the axis
  100583. * @param axisValue the value of the axis which determines the meshes new position
  100584. * @hidden
  100585. */
  100586. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  100587. /**
  100588. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100589. * @param scene scene in which to add meshes
  100590. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100591. */
  100592. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  100593. /**
  100594. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  100595. * can be transformed by button presses and axes values, based on this._mapping.
  100596. *
  100597. * @param scene scene in which the meshes exist
  100598. * @param meshes list of meshes that make up the controller model to process
  100599. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  100600. */
  100601. private processModel;
  100602. private createMeshInfo;
  100603. /**
  100604. * Gets the ray of the controller in the direction the controller is pointing
  100605. * @param length the length the resulting ray should be
  100606. * @returns a ray in the direction the controller is pointing
  100607. */
  100608. getForwardRay(length?: number): Ray;
  100609. /**
  100610. * Disposes of the controller
  100611. */
  100612. dispose(): void;
  100613. }
  100614. }
  100615. declare module BABYLON {
  100616. /**
  100617. * Single axis scale gizmo
  100618. */
  100619. export class AxisScaleGizmo extends Gizmo {
  100620. private _coloredMaterial;
  100621. /**
  100622. * Drag behavior responsible for the gizmos dragging interactions
  100623. */
  100624. dragBehavior: PointerDragBehavior;
  100625. private _pointerObserver;
  100626. /**
  100627. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100628. */
  100629. snapDistance: number;
  100630. /**
  100631. * Event that fires each time the gizmo snaps to a new location.
  100632. * * snapDistance is the the change in distance
  100633. */
  100634. onSnapObservable: Observable<{
  100635. snapDistance: number;
  100636. }>;
  100637. /**
  100638. * If the scaling operation should be done on all axis (default: false)
  100639. */
  100640. uniformScaling: boolean;
  100641. /**
  100642. * Creates an AxisScaleGizmo
  100643. * @param gizmoLayer The utility layer the gizmo will be added to
  100644. * @param dragAxis The axis which the gizmo will be able to scale on
  100645. * @param color The color of the gizmo
  100646. */
  100647. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100648. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100649. /**
  100650. * Disposes of the gizmo
  100651. */
  100652. dispose(): void;
  100653. /**
  100654. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100655. * @param mesh The mesh to replace the default mesh of the gizmo
  100656. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  100657. */
  100658. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  100659. }
  100660. }
  100661. declare module BABYLON {
  100662. /**
  100663. * Bounding box gizmo
  100664. */
  100665. export class BoundingBoxGizmo extends Gizmo {
  100666. private _lineBoundingBox;
  100667. private _rotateSpheresParent;
  100668. private _scaleBoxesParent;
  100669. private _boundingDimensions;
  100670. private _renderObserver;
  100671. private _pointerObserver;
  100672. private _scaleDragSpeed;
  100673. private _tmpQuaternion;
  100674. private _tmpVector;
  100675. private _tmpRotationMatrix;
  100676. /**
  100677. * 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)
  100678. */
  100679. ignoreChildren: boolean;
  100680. /**
  100681. * 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)
  100682. */
  100683. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  100684. /**
  100685. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  100686. */
  100687. rotationSphereSize: number;
  100688. /**
  100689. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  100690. */
  100691. scaleBoxSize: number;
  100692. /**
  100693. * 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)
  100694. */
  100695. fixedDragMeshScreenSize: boolean;
  100696. /**
  100697. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  100698. */
  100699. fixedDragMeshScreenSizeDistanceFactor: number;
  100700. /**
  100701. * Fired when a rotation sphere or scale box is dragged
  100702. */
  100703. onDragStartObservable: Observable<{}>;
  100704. /**
  100705. * Fired when a scale box is dragged
  100706. */
  100707. onScaleBoxDragObservable: Observable<{}>;
  100708. /**
  100709. * Fired when a scale box drag is ended
  100710. */
  100711. onScaleBoxDragEndObservable: Observable<{}>;
  100712. /**
  100713. * Fired when a rotation sphere is dragged
  100714. */
  100715. onRotationSphereDragObservable: Observable<{}>;
  100716. /**
  100717. * Fired when a rotation sphere drag is ended
  100718. */
  100719. onRotationSphereDragEndObservable: Observable<{}>;
  100720. /**
  100721. * 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)
  100722. */
  100723. scalePivot: Nullable<Vector3>;
  100724. private _anchorMesh;
  100725. private _existingMeshScale;
  100726. private _dragMesh;
  100727. private pointerDragBehavior;
  100728. private coloredMaterial;
  100729. private hoverColoredMaterial;
  100730. /**
  100731. * Sets the color of the bounding box gizmo
  100732. * @param color the color to set
  100733. */
  100734. setColor(color: Color3): void;
  100735. /**
  100736. * Creates an BoundingBoxGizmo
  100737. * @param gizmoLayer The utility layer the gizmo will be added to
  100738. * @param color The color of the gizmo
  100739. */
  100740. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100741. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100742. private _selectNode;
  100743. /**
  100744. * Updates the bounding box information for the Gizmo
  100745. */
  100746. updateBoundingBox(): void;
  100747. private _updateRotationSpheres;
  100748. private _updateScaleBoxes;
  100749. /**
  100750. * Enables rotation on the specified axis and disables rotation on the others
  100751. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  100752. */
  100753. setEnabledRotationAxis(axis: string): void;
  100754. /**
  100755. * Enables/disables scaling
  100756. * @param enable if scaling should be enabled
  100757. */
  100758. setEnabledScaling(enable: boolean): void;
  100759. private _updateDummy;
  100760. /**
  100761. * Enables a pointer drag behavior on the bounding box of the gizmo
  100762. */
  100763. enableDragBehavior(): void;
  100764. /**
  100765. * Disposes of the gizmo
  100766. */
  100767. dispose(): void;
  100768. /**
  100769. * 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)
  100770. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  100771. * @returns the bounding box mesh with the passed in mesh as a child
  100772. */
  100773. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  100774. /**
  100775. * CustomMeshes are not supported by this gizmo
  100776. * @param mesh The mesh to replace the default mesh of the gizmo
  100777. */
  100778. setCustomMesh(mesh: Mesh): void;
  100779. }
  100780. }
  100781. declare module BABYLON {
  100782. /**
  100783. * Single plane rotation gizmo
  100784. */
  100785. export class PlaneRotationGizmo extends Gizmo {
  100786. /**
  100787. * Drag behavior responsible for the gizmos dragging interactions
  100788. */
  100789. dragBehavior: PointerDragBehavior;
  100790. private _pointerObserver;
  100791. /**
  100792. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  100793. */
  100794. snapDistance: number;
  100795. /**
  100796. * Event that fires each time the gizmo snaps to a new location.
  100797. * * snapDistance is the the change in distance
  100798. */
  100799. onSnapObservable: Observable<{
  100800. snapDistance: number;
  100801. }>;
  100802. /**
  100803. * Creates a PlaneRotationGizmo
  100804. * @param gizmoLayer The utility layer the gizmo will be added to
  100805. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  100806. * @param color The color of the gizmo
  100807. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100808. */
  100809. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100810. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100811. /**
  100812. * Disposes of the gizmo
  100813. */
  100814. dispose(): void;
  100815. }
  100816. }
  100817. declare module BABYLON {
  100818. /**
  100819. * Gizmo that enables rotating a mesh along 3 axis
  100820. */
  100821. export class RotationGizmo extends Gizmo {
  100822. /**
  100823. * Internal gizmo used for interactions on the x axis
  100824. */
  100825. xGizmo: PlaneRotationGizmo;
  100826. /**
  100827. * Internal gizmo used for interactions on the y axis
  100828. */
  100829. yGizmo: PlaneRotationGizmo;
  100830. /**
  100831. * Internal gizmo used for interactions on the z axis
  100832. */
  100833. zGizmo: PlaneRotationGizmo;
  100834. /** Fires an event when any of it's sub gizmos are dragged */
  100835. onDragStartObservable: Observable<{}>;
  100836. /** Fires an event when any of it's sub gizmos are released from dragging */
  100837. onDragEndObservable: Observable<{}>;
  100838. attachedMesh: Nullable<AbstractMesh>;
  100839. /**
  100840. * Creates a RotationGizmo
  100841. * @param gizmoLayer The utility layer the gizmo will be added to
  100842. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100843. */
  100844. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100845. updateGizmoRotationToMatchAttachedMesh: boolean;
  100846. /**
  100847. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100848. */
  100849. snapDistance: number;
  100850. /**
  100851. * Ratio for the scale of the gizmo (Default: 1)
  100852. */
  100853. scaleRatio: number;
  100854. /**
  100855. * Disposes of the gizmo
  100856. */
  100857. dispose(): void;
  100858. /**
  100859. * CustomMeshes are not supported by this gizmo
  100860. * @param mesh The mesh to replace the default mesh of the gizmo
  100861. */
  100862. setCustomMesh(mesh: Mesh): void;
  100863. }
  100864. }
  100865. declare module BABYLON {
  100866. /**
  100867. * Gizmo that enables dragging a mesh along 3 axis
  100868. */
  100869. export class PositionGizmo extends Gizmo {
  100870. /**
  100871. * Internal gizmo used for interactions on the x axis
  100872. */
  100873. xGizmo: AxisDragGizmo;
  100874. /**
  100875. * Internal gizmo used for interactions on the y axis
  100876. */
  100877. yGizmo: AxisDragGizmo;
  100878. /**
  100879. * Internal gizmo used for interactions on the z axis
  100880. */
  100881. zGizmo: AxisDragGizmo;
  100882. /** Fires an event when any of it's sub gizmos are dragged */
  100883. onDragStartObservable: Observable<{}>;
  100884. /** Fires an event when any of it's sub gizmos are released from dragging */
  100885. onDragEndObservable: Observable<{}>;
  100886. attachedMesh: Nullable<AbstractMesh>;
  100887. /**
  100888. * Creates a PositionGizmo
  100889. * @param gizmoLayer The utility layer the gizmo will be added to
  100890. */
  100891. constructor(gizmoLayer?: UtilityLayerRenderer);
  100892. updateGizmoRotationToMatchAttachedMesh: boolean;
  100893. /**
  100894. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100895. */
  100896. snapDistance: number;
  100897. /**
  100898. * Ratio for the scale of the gizmo (Default: 1)
  100899. */
  100900. scaleRatio: number;
  100901. /**
  100902. * Disposes of the gizmo
  100903. */
  100904. dispose(): void;
  100905. /**
  100906. * CustomMeshes are not supported by this gizmo
  100907. * @param mesh The mesh to replace the default mesh of the gizmo
  100908. */
  100909. setCustomMesh(mesh: Mesh): void;
  100910. }
  100911. }
  100912. declare module BABYLON {
  100913. /**
  100914. * Class containing static functions to help procedurally build meshes
  100915. */
  100916. export class PolyhedronBuilder {
  100917. /**
  100918. * Creates a polyhedron mesh
  100919. * * 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
  100920. * * The parameter `size` (positive float, default 1) sets the polygon size
  100921. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  100922. * * 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`
  100923. * * 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
  100924. * * 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)`)
  100925. * * 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
  100926. * * 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
  100927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100930. * @param name defines the name of the mesh
  100931. * @param options defines the options used to create the mesh
  100932. * @param scene defines the hosting scene
  100933. * @returns the polyhedron mesh
  100934. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  100935. */
  100936. static CreatePolyhedron(name: string, options: {
  100937. type?: number;
  100938. size?: number;
  100939. sizeX?: number;
  100940. sizeY?: number;
  100941. sizeZ?: number;
  100942. custom?: any;
  100943. faceUV?: Vector4[];
  100944. faceColors?: Color4[];
  100945. flat?: boolean;
  100946. updatable?: boolean;
  100947. sideOrientation?: number;
  100948. frontUVs?: Vector4;
  100949. backUVs?: Vector4;
  100950. }, scene: Scene): Mesh;
  100951. }
  100952. }
  100953. declare module BABYLON {
  100954. /**
  100955. * Gizmo that enables scaling a mesh along 3 axis
  100956. */
  100957. export class ScaleGizmo extends Gizmo {
  100958. /**
  100959. * Internal gizmo used for interactions on the x axis
  100960. */
  100961. xGizmo: AxisScaleGizmo;
  100962. /**
  100963. * Internal gizmo used for interactions on the y axis
  100964. */
  100965. yGizmo: AxisScaleGizmo;
  100966. /**
  100967. * Internal gizmo used for interactions on the z axis
  100968. */
  100969. zGizmo: AxisScaleGizmo;
  100970. /**
  100971. * Internal gizmo used to scale all axis equally
  100972. */
  100973. uniformScaleGizmo: AxisScaleGizmo;
  100974. /** Fires an event when any of it's sub gizmos are dragged */
  100975. onDragStartObservable: Observable<{}>;
  100976. /** Fires an event when any of it's sub gizmos are released from dragging */
  100977. onDragEndObservable: Observable<{}>;
  100978. attachedMesh: Nullable<AbstractMesh>;
  100979. /**
  100980. * Creates a ScaleGizmo
  100981. * @param gizmoLayer The utility layer the gizmo will be added to
  100982. */
  100983. constructor(gizmoLayer?: UtilityLayerRenderer);
  100984. updateGizmoRotationToMatchAttachedMesh: boolean;
  100985. /**
  100986. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100987. */
  100988. snapDistance: number;
  100989. /**
  100990. * Ratio for the scale of the gizmo (Default: 1)
  100991. */
  100992. scaleRatio: number;
  100993. /**
  100994. * Disposes of the gizmo
  100995. */
  100996. dispose(): void;
  100997. }
  100998. }
  100999. declare module BABYLON {
  101000. /**
  101001. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  101002. */
  101003. export class GizmoManager implements IDisposable {
  101004. private scene;
  101005. /**
  101006. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  101007. */
  101008. gizmos: {
  101009. positionGizmo: Nullable<PositionGizmo>;
  101010. rotationGizmo: Nullable<RotationGizmo>;
  101011. scaleGizmo: Nullable<ScaleGizmo>;
  101012. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101013. };
  101014. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101015. clearGizmoOnEmptyPointerEvent: boolean;
  101016. /** Fires an event when the manager is attached to a mesh */
  101017. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101018. private _gizmosEnabled;
  101019. private _pointerObserver;
  101020. private _attachedMesh;
  101021. private _boundingBoxColor;
  101022. private _defaultUtilityLayer;
  101023. private _defaultKeepDepthUtilityLayer;
  101024. /**
  101025. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101026. */
  101027. boundingBoxDragBehavior: SixDofDragBehavior;
  101028. /**
  101029. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101030. */
  101031. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101032. /**
  101033. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101034. */
  101035. usePointerToAttachGizmos: boolean;
  101036. /**
  101037. * Instatiates a gizmo manager
  101038. * @param scene the scene to overlay the gizmos on top of
  101039. */
  101040. constructor(scene: Scene);
  101041. /**
  101042. * Attaches a set of gizmos to the specified mesh
  101043. * @param mesh The mesh the gizmo's should be attached to
  101044. */
  101045. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101046. /**
  101047. * If the position gizmo is enabled
  101048. */
  101049. positionGizmoEnabled: boolean;
  101050. /**
  101051. * If the rotation gizmo is enabled
  101052. */
  101053. rotationGizmoEnabled: boolean;
  101054. /**
  101055. * If the scale gizmo is enabled
  101056. */
  101057. scaleGizmoEnabled: boolean;
  101058. /**
  101059. * If the boundingBox gizmo is enabled
  101060. */
  101061. boundingBoxGizmoEnabled: boolean;
  101062. /**
  101063. * Disposes of the gizmo manager
  101064. */
  101065. dispose(): void;
  101066. }
  101067. }
  101068. declare module BABYLON {
  101069. /**
  101070. * Gizmo that enables viewing a light
  101071. */
  101072. export class LightGizmo extends Gizmo {
  101073. private _box;
  101074. /**
  101075. * Creates a LightGizmo
  101076. * @param gizmoLayer The utility layer the gizmo will be added to
  101077. */
  101078. constructor(gizmoLayer?: UtilityLayerRenderer);
  101079. private _light;
  101080. /**
  101081. * The light that the gizmo is attached to
  101082. */
  101083. light: Nullable<Light>;
  101084. /**
  101085. * @hidden
  101086. * Updates the gizmo to match the attached mesh's position/rotation
  101087. */
  101088. protected _update(): void;
  101089. }
  101090. }
  101091. declare module BABYLON {
  101092. /** @hidden */
  101093. export var backgroundFragmentDeclaration: {
  101094. name: string;
  101095. shader: string;
  101096. };
  101097. }
  101098. declare module BABYLON {
  101099. /** @hidden */
  101100. export var backgroundUboDeclaration: {
  101101. name: string;
  101102. shader: string;
  101103. };
  101104. }
  101105. declare module BABYLON {
  101106. /** @hidden */
  101107. export var backgroundPixelShader: {
  101108. name: string;
  101109. shader: string;
  101110. };
  101111. }
  101112. declare module BABYLON {
  101113. /** @hidden */
  101114. export var backgroundVertexDeclaration: {
  101115. name: string;
  101116. shader: string;
  101117. };
  101118. }
  101119. declare module BABYLON {
  101120. /** @hidden */
  101121. export var backgroundVertexShader: {
  101122. name: string;
  101123. shader: string;
  101124. };
  101125. }
  101126. declare module BABYLON {
  101127. /**
  101128. * Background material used to create an efficient environement around your scene.
  101129. */
  101130. export class BackgroundMaterial extends PushMaterial {
  101131. /**
  101132. * Standard reflectance value at parallel view angle.
  101133. */
  101134. static StandardReflectance0: number;
  101135. /**
  101136. * Standard reflectance value at grazing angle.
  101137. */
  101138. static StandardReflectance90: number;
  101139. protected _primaryColor: Color3;
  101140. /**
  101141. * Key light Color (multiply against the environement texture)
  101142. */
  101143. primaryColor: Color3;
  101144. protected __perceptualColor: Nullable<Color3>;
  101145. /**
  101146. * Experimental Internal Use Only.
  101147. *
  101148. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  101149. * This acts as a helper to set the primary color to a more "human friendly" value.
  101150. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  101151. * output color as close as possible from the chosen value.
  101152. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  101153. * part of lighting setup.)
  101154. */
  101155. _perceptualColor: Nullable<Color3>;
  101156. protected _primaryColorShadowLevel: float;
  101157. /**
  101158. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  101159. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  101160. */
  101161. primaryColorShadowLevel: float;
  101162. protected _primaryColorHighlightLevel: float;
  101163. /**
  101164. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  101165. * The primary color is used at the level chosen to define what the white area would look.
  101166. */
  101167. primaryColorHighlightLevel: float;
  101168. protected _reflectionTexture: Nullable<BaseTexture>;
  101169. /**
  101170. * Reflection Texture used in the material.
  101171. * Should be author in a specific way for the best result (refer to the documentation).
  101172. */
  101173. reflectionTexture: Nullable<BaseTexture>;
  101174. protected _reflectionBlur: float;
  101175. /**
  101176. * Reflection Texture level of blur.
  101177. *
  101178. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  101179. * texture twice.
  101180. */
  101181. reflectionBlur: float;
  101182. protected _diffuseTexture: Nullable<BaseTexture>;
  101183. /**
  101184. * Diffuse Texture used in the material.
  101185. * Should be author in a specific way for the best result (refer to the documentation).
  101186. */
  101187. diffuseTexture: Nullable<BaseTexture>;
  101188. protected _shadowLights: Nullable<IShadowLight[]>;
  101189. /**
  101190. * Specify the list of lights casting shadow on the material.
  101191. * All scene shadow lights will be included if null.
  101192. */
  101193. shadowLights: Nullable<IShadowLight[]>;
  101194. protected _shadowLevel: float;
  101195. /**
  101196. * Helps adjusting the shadow to a softer level if required.
  101197. * 0 means black shadows and 1 means no shadows.
  101198. */
  101199. shadowLevel: float;
  101200. protected _sceneCenter: Vector3;
  101201. /**
  101202. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  101203. * It is usually zero but might be interesting to modify according to your setup.
  101204. */
  101205. sceneCenter: Vector3;
  101206. protected _opacityFresnel: boolean;
  101207. /**
  101208. * This helps specifying that the material is falling off to the sky box at grazing angle.
  101209. * This helps ensuring a nice transition when the camera goes under the ground.
  101210. */
  101211. opacityFresnel: boolean;
  101212. protected _reflectionFresnel: boolean;
  101213. /**
  101214. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  101215. * This helps adding a mirror texture on the ground.
  101216. */
  101217. reflectionFresnel: boolean;
  101218. protected _reflectionFalloffDistance: number;
  101219. /**
  101220. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  101221. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  101222. */
  101223. reflectionFalloffDistance: number;
  101224. protected _reflectionAmount: number;
  101225. /**
  101226. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  101227. */
  101228. reflectionAmount: number;
  101229. protected _reflectionReflectance0: number;
  101230. /**
  101231. * This specifies the weight of the reflection at grazing angle.
  101232. */
  101233. reflectionReflectance0: number;
  101234. protected _reflectionReflectance90: number;
  101235. /**
  101236. * This specifies the weight of the reflection at a perpendicular point of view.
  101237. */
  101238. reflectionReflectance90: number;
  101239. /**
  101240. * Sets the reflection reflectance fresnel values according to the default standard
  101241. * empirically know to work well :-)
  101242. */
  101243. reflectionStandardFresnelWeight: number;
  101244. protected _useRGBColor: boolean;
  101245. /**
  101246. * Helps to directly use the maps channels instead of their level.
  101247. */
  101248. useRGBColor: boolean;
  101249. protected _enableNoise: boolean;
  101250. /**
  101251. * This helps reducing the banding effect that could occur on the background.
  101252. */
  101253. enableNoise: boolean;
  101254. /**
  101255. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101256. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  101257. * Recommended to be keep at 1.0 except for special cases.
  101258. */
  101259. fovMultiplier: number;
  101260. private _fovMultiplier;
  101261. /**
  101262. * Enable the FOV adjustment feature controlled by fovMultiplier.
  101263. */
  101264. useEquirectangularFOV: boolean;
  101265. private _maxSimultaneousLights;
  101266. /**
  101267. * Number of Simultaneous lights allowed on the material.
  101268. */
  101269. maxSimultaneousLights: int;
  101270. /**
  101271. * Default configuration related to image processing available in the Background Material.
  101272. */
  101273. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101274. /**
  101275. * Keep track of the image processing observer to allow dispose and replace.
  101276. */
  101277. private _imageProcessingObserver;
  101278. /**
  101279. * Attaches a new image processing configuration to the PBR Material.
  101280. * @param configuration (if null the scene configuration will be use)
  101281. */
  101282. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101283. /**
  101284. * Gets the image processing configuration used either in this material.
  101285. */
  101286. /**
  101287. * Sets the Default image processing configuration used either in the this material.
  101288. *
  101289. * If sets to null, the scene one is in use.
  101290. */
  101291. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  101292. /**
  101293. * Gets wether the color curves effect is enabled.
  101294. */
  101295. /**
  101296. * Sets wether the color curves effect is enabled.
  101297. */
  101298. cameraColorCurvesEnabled: boolean;
  101299. /**
  101300. * Gets wether the color grading effect is enabled.
  101301. */
  101302. /**
  101303. * Gets wether the color grading effect is enabled.
  101304. */
  101305. cameraColorGradingEnabled: boolean;
  101306. /**
  101307. * Gets wether tonemapping is enabled or not.
  101308. */
  101309. /**
  101310. * Sets wether tonemapping is enabled or not
  101311. */
  101312. cameraToneMappingEnabled: boolean;
  101313. /**
  101314. * The camera exposure used on this material.
  101315. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101316. * This corresponds to a photographic exposure.
  101317. */
  101318. /**
  101319. * The camera exposure used on this material.
  101320. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101321. * This corresponds to a photographic exposure.
  101322. */
  101323. cameraExposure: float;
  101324. /**
  101325. * Gets The camera contrast used on this material.
  101326. */
  101327. /**
  101328. * Sets The camera contrast used on this material.
  101329. */
  101330. cameraContrast: float;
  101331. /**
  101332. * Gets the Color Grading 2D Lookup Texture.
  101333. */
  101334. /**
  101335. * Sets the Color Grading 2D Lookup Texture.
  101336. */
  101337. cameraColorGradingTexture: Nullable<BaseTexture>;
  101338. /**
  101339. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101340. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101341. * 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;
  101342. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101343. */
  101344. /**
  101345. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101346. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101347. * 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;
  101348. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101349. */
  101350. cameraColorCurves: Nullable<ColorCurves>;
  101351. /**
  101352. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  101353. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  101354. */
  101355. switchToBGR: boolean;
  101356. private _renderTargets;
  101357. private _reflectionControls;
  101358. private _white;
  101359. private _primaryShadowColor;
  101360. private _primaryHighlightColor;
  101361. /**
  101362. * Instantiates a Background Material in the given scene
  101363. * @param name The friendly name of the material
  101364. * @param scene The scene to add the material to
  101365. */
  101366. constructor(name: string, scene: Scene);
  101367. /**
  101368. * Gets a boolean indicating that current material needs to register RTT
  101369. */
  101370. readonly hasRenderTargetTextures: boolean;
  101371. /**
  101372. * The entire material has been created in order to prevent overdraw.
  101373. * @returns false
  101374. */
  101375. needAlphaTesting(): boolean;
  101376. /**
  101377. * The entire material has been created in order to prevent overdraw.
  101378. * @returns true if blending is enable
  101379. */
  101380. needAlphaBlending(): boolean;
  101381. /**
  101382. * Checks wether the material is ready to be rendered for a given mesh.
  101383. * @param mesh The mesh to render
  101384. * @param subMesh The submesh to check against
  101385. * @param useInstances Specify wether or not the material is used with instances
  101386. * @returns true if all the dependencies are ready (Textures, Effects...)
  101387. */
  101388. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101389. /**
  101390. * Compute the primary color according to the chosen perceptual color.
  101391. */
  101392. private _computePrimaryColorFromPerceptualColor;
  101393. /**
  101394. * Compute the highlights and shadow colors according to their chosen levels.
  101395. */
  101396. private _computePrimaryColors;
  101397. /**
  101398. * Build the uniform buffer used in the material.
  101399. */
  101400. buildUniformLayout(): void;
  101401. /**
  101402. * Unbind the material.
  101403. */
  101404. unbind(): void;
  101405. /**
  101406. * Bind only the world matrix to the material.
  101407. * @param world The world matrix to bind.
  101408. */
  101409. bindOnlyWorldMatrix(world: Matrix): void;
  101410. /**
  101411. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  101412. * @param world The world matrix to bind.
  101413. * @param subMesh The submesh to bind for.
  101414. */
  101415. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101416. /**
  101417. * Dispose the material.
  101418. * @param forceDisposeEffect Force disposal of the associated effect.
  101419. * @param forceDisposeTextures Force disposal of the associated textures.
  101420. */
  101421. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101422. /**
  101423. * Clones the material.
  101424. * @param name The cloned name.
  101425. * @returns The cloned material.
  101426. */
  101427. clone(name: string): BackgroundMaterial;
  101428. /**
  101429. * Serializes the current material to its JSON representation.
  101430. * @returns The JSON representation.
  101431. */
  101432. serialize(): any;
  101433. /**
  101434. * Gets the class name of the material
  101435. * @returns "BackgroundMaterial"
  101436. */
  101437. getClassName(): string;
  101438. /**
  101439. * Parse a JSON input to create back a background material.
  101440. * @param source The JSON data to parse
  101441. * @param scene The scene to create the parsed material in
  101442. * @param rootUrl The root url of the assets the material depends upon
  101443. * @returns the instantiated BackgroundMaterial.
  101444. */
  101445. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  101446. }
  101447. }
  101448. declare module BABYLON {
  101449. /**
  101450. * Represents the different options available during the creation of
  101451. * a Environment helper.
  101452. *
  101453. * This can control the default ground, skybox and image processing setup of your scene.
  101454. */
  101455. export interface IEnvironmentHelperOptions {
  101456. /**
  101457. * Specifies wether or not to create a ground.
  101458. * True by default.
  101459. */
  101460. createGround: boolean;
  101461. /**
  101462. * Specifies the ground size.
  101463. * 15 by default.
  101464. */
  101465. groundSize: number;
  101466. /**
  101467. * The texture used on the ground for the main color.
  101468. * Comes from the BabylonJS CDN by default.
  101469. *
  101470. * Remarks: Can be either a texture or a url.
  101471. */
  101472. groundTexture: string | BaseTexture;
  101473. /**
  101474. * The color mixed in the ground texture by default.
  101475. * BabylonJS clearColor by default.
  101476. */
  101477. groundColor: Color3;
  101478. /**
  101479. * Specifies the ground opacity.
  101480. * 1 by default.
  101481. */
  101482. groundOpacity: number;
  101483. /**
  101484. * Enables the ground to receive shadows.
  101485. * True by default.
  101486. */
  101487. enableGroundShadow: boolean;
  101488. /**
  101489. * Helps preventing the shadow to be fully black on the ground.
  101490. * 0.5 by default.
  101491. */
  101492. groundShadowLevel: number;
  101493. /**
  101494. * Creates a mirror texture attach to the ground.
  101495. * false by default.
  101496. */
  101497. enableGroundMirror: boolean;
  101498. /**
  101499. * Specifies the ground mirror size ratio.
  101500. * 0.3 by default as the default kernel is 64.
  101501. */
  101502. groundMirrorSizeRatio: number;
  101503. /**
  101504. * Specifies the ground mirror blur kernel size.
  101505. * 64 by default.
  101506. */
  101507. groundMirrorBlurKernel: number;
  101508. /**
  101509. * Specifies the ground mirror visibility amount.
  101510. * 1 by default
  101511. */
  101512. groundMirrorAmount: number;
  101513. /**
  101514. * Specifies the ground mirror reflectance weight.
  101515. * This uses the standard weight of the background material to setup the fresnel effect
  101516. * of the mirror.
  101517. * 1 by default.
  101518. */
  101519. groundMirrorFresnelWeight: number;
  101520. /**
  101521. * Specifies the ground mirror Falloff distance.
  101522. * This can helps reducing the size of the reflection.
  101523. * 0 by Default.
  101524. */
  101525. groundMirrorFallOffDistance: number;
  101526. /**
  101527. * Specifies the ground mirror texture type.
  101528. * Unsigned Int by Default.
  101529. */
  101530. groundMirrorTextureType: number;
  101531. /**
  101532. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  101533. * the shown objects.
  101534. */
  101535. groundYBias: number;
  101536. /**
  101537. * Specifies wether or not to create a skybox.
  101538. * True by default.
  101539. */
  101540. createSkybox: boolean;
  101541. /**
  101542. * Specifies the skybox size.
  101543. * 20 by default.
  101544. */
  101545. skyboxSize: number;
  101546. /**
  101547. * The texture used on the skybox for the main color.
  101548. * Comes from the BabylonJS CDN by default.
  101549. *
  101550. * Remarks: Can be either a texture or a url.
  101551. */
  101552. skyboxTexture: string | BaseTexture;
  101553. /**
  101554. * The color mixed in the skybox texture by default.
  101555. * BabylonJS clearColor by default.
  101556. */
  101557. skyboxColor: Color3;
  101558. /**
  101559. * The background rotation around the Y axis of the scene.
  101560. * This helps aligning the key lights of your scene with the background.
  101561. * 0 by default.
  101562. */
  101563. backgroundYRotation: number;
  101564. /**
  101565. * Compute automatically the size of the elements to best fit with the scene.
  101566. */
  101567. sizeAuto: boolean;
  101568. /**
  101569. * Default position of the rootMesh if autoSize is not true.
  101570. */
  101571. rootPosition: Vector3;
  101572. /**
  101573. * Sets up the image processing in the scene.
  101574. * true by default.
  101575. */
  101576. setupImageProcessing: boolean;
  101577. /**
  101578. * The texture used as your environment texture in the scene.
  101579. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  101580. *
  101581. * Remarks: Can be either a texture or a url.
  101582. */
  101583. environmentTexture: string | BaseTexture;
  101584. /**
  101585. * The value of the exposure to apply to the scene.
  101586. * 0.6 by default if setupImageProcessing is true.
  101587. */
  101588. cameraExposure: number;
  101589. /**
  101590. * The value of the contrast to apply to the scene.
  101591. * 1.6 by default if setupImageProcessing is true.
  101592. */
  101593. cameraContrast: number;
  101594. /**
  101595. * Specifies wether or not tonemapping should be enabled in the scene.
  101596. * true by default if setupImageProcessing is true.
  101597. */
  101598. toneMappingEnabled: boolean;
  101599. }
  101600. /**
  101601. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  101602. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  101603. * It also helps with the default setup of your imageProcessing configuration.
  101604. */
  101605. export class EnvironmentHelper {
  101606. /**
  101607. * Default ground texture URL.
  101608. */
  101609. private static _groundTextureCDNUrl;
  101610. /**
  101611. * Default skybox texture URL.
  101612. */
  101613. private static _skyboxTextureCDNUrl;
  101614. /**
  101615. * Default environment texture URL.
  101616. */
  101617. private static _environmentTextureCDNUrl;
  101618. /**
  101619. * Creates the default options for the helper.
  101620. */
  101621. private static _getDefaultOptions;
  101622. private _rootMesh;
  101623. /**
  101624. * Gets the root mesh created by the helper.
  101625. */
  101626. readonly rootMesh: Mesh;
  101627. private _skybox;
  101628. /**
  101629. * Gets the skybox created by the helper.
  101630. */
  101631. readonly skybox: Nullable<Mesh>;
  101632. private _skyboxTexture;
  101633. /**
  101634. * Gets the skybox texture created by the helper.
  101635. */
  101636. readonly skyboxTexture: Nullable<BaseTexture>;
  101637. private _skyboxMaterial;
  101638. /**
  101639. * Gets the skybox material created by the helper.
  101640. */
  101641. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  101642. private _ground;
  101643. /**
  101644. * Gets the ground mesh created by the helper.
  101645. */
  101646. readonly ground: Nullable<Mesh>;
  101647. private _groundTexture;
  101648. /**
  101649. * Gets the ground texture created by the helper.
  101650. */
  101651. readonly groundTexture: Nullable<BaseTexture>;
  101652. private _groundMirror;
  101653. /**
  101654. * Gets the ground mirror created by the helper.
  101655. */
  101656. readonly groundMirror: Nullable<MirrorTexture>;
  101657. /**
  101658. * Gets the ground mirror render list to helps pushing the meshes
  101659. * you wish in the ground reflection.
  101660. */
  101661. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  101662. private _groundMaterial;
  101663. /**
  101664. * Gets the ground material created by the helper.
  101665. */
  101666. readonly groundMaterial: Nullable<BackgroundMaterial>;
  101667. /**
  101668. * Stores the creation options.
  101669. */
  101670. private readonly _scene;
  101671. private _options;
  101672. /**
  101673. * This observable will be notified with any error during the creation of the environment,
  101674. * mainly texture creation errors.
  101675. */
  101676. onErrorObservable: Observable<{
  101677. message?: string;
  101678. exception?: any;
  101679. }>;
  101680. /**
  101681. * constructor
  101682. * @param options Defines the options we want to customize the helper
  101683. * @param scene The scene to add the material to
  101684. */
  101685. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  101686. /**
  101687. * Updates the background according to the new options
  101688. * @param options
  101689. */
  101690. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  101691. /**
  101692. * Sets the primary color of all the available elements.
  101693. * @param color the main color to affect to the ground and the background
  101694. */
  101695. setMainColor(color: Color3): void;
  101696. /**
  101697. * Setup the image processing according to the specified options.
  101698. */
  101699. private _setupImageProcessing;
  101700. /**
  101701. * Setup the environment texture according to the specified options.
  101702. */
  101703. private _setupEnvironmentTexture;
  101704. /**
  101705. * Setup the background according to the specified options.
  101706. */
  101707. private _setupBackground;
  101708. /**
  101709. * Get the scene sizes according to the setup.
  101710. */
  101711. private _getSceneSize;
  101712. /**
  101713. * Setup the ground according to the specified options.
  101714. */
  101715. private _setupGround;
  101716. /**
  101717. * Setup the ground material according to the specified options.
  101718. */
  101719. private _setupGroundMaterial;
  101720. /**
  101721. * Setup the ground diffuse texture according to the specified options.
  101722. */
  101723. private _setupGroundDiffuseTexture;
  101724. /**
  101725. * Setup the ground mirror texture according to the specified options.
  101726. */
  101727. private _setupGroundMirrorTexture;
  101728. /**
  101729. * Setup the ground to receive the mirror texture.
  101730. */
  101731. private _setupMirrorInGroundMaterial;
  101732. /**
  101733. * Setup the skybox according to the specified options.
  101734. */
  101735. private _setupSkybox;
  101736. /**
  101737. * Setup the skybox material according to the specified options.
  101738. */
  101739. private _setupSkyboxMaterial;
  101740. /**
  101741. * Setup the skybox reflection texture according to the specified options.
  101742. */
  101743. private _setupSkyboxReflectionTexture;
  101744. private _errorHandler;
  101745. /**
  101746. * Dispose all the elements created by the Helper.
  101747. */
  101748. dispose(): void;
  101749. }
  101750. }
  101751. declare module BABYLON {
  101752. /**
  101753. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  101754. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  101755. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  101756. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101757. */
  101758. export class PhotoDome extends TransformNode {
  101759. private _useDirectMapping;
  101760. /**
  101761. * The texture being displayed on the sphere
  101762. */
  101763. protected _photoTexture: Texture;
  101764. /**
  101765. * Gets or sets the texture being displayed on the sphere
  101766. */
  101767. photoTexture: Texture;
  101768. /**
  101769. * Observable raised when an error occured while loading the 360 image
  101770. */
  101771. onLoadErrorObservable: Observable<string>;
  101772. /**
  101773. * The skybox material
  101774. */
  101775. protected _material: BackgroundMaterial;
  101776. /**
  101777. * The surface used for the skybox
  101778. */
  101779. protected _mesh: Mesh;
  101780. /**
  101781. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101782. * Also see the options.resolution property.
  101783. */
  101784. fovMultiplier: number;
  101785. /**
  101786. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  101787. * @param name Element's name, child elements will append suffixes for their own names.
  101788. * @param urlsOfPhoto defines the url of the photo to display
  101789. * @param options defines an object containing optional or exposed sub element properties
  101790. * @param onError defines a callback called when an error occured while loading the texture
  101791. */
  101792. constructor(name: string, urlOfPhoto: string, options: {
  101793. resolution?: number;
  101794. size?: number;
  101795. useDirectMapping?: boolean;
  101796. faceForward?: boolean;
  101797. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  101798. /**
  101799. * Releases resources associated with this node.
  101800. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101801. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101802. */
  101803. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101804. }
  101805. }
  101806. declare module BABYLON {
  101807. /**
  101808. * Class used to host texture specific utilities
  101809. */
  101810. export class BRDFTextureTools {
  101811. /**
  101812. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  101813. * @param texture the texture to expand.
  101814. */
  101815. private static _ExpandDefaultBRDFTexture;
  101816. /**
  101817. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  101818. * @param scene defines the hosting scene
  101819. * @returns the environment BRDF texture
  101820. */
  101821. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  101822. private static _environmentBRDFBase64Texture;
  101823. }
  101824. }
  101825. declare module BABYLON {
  101826. /**
  101827. * @hidden
  101828. */
  101829. export interface IMaterialClearCoatDefines {
  101830. CLEARCOAT: boolean;
  101831. CLEARCOAT_DEFAULTIOR: boolean;
  101832. CLEARCOAT_TEXTURE: boolean;
  101833. CLEARCOAT_TEXTUREDIRECTUV: number;
  101834. CLEARCOAT_BUMP: boolean;
  101835. CLEARCOAT_BUMPDIRECTUV: number;
  101836. CLEARCOAT_TINT: boolean;
  101837. CLEARCOAT_TINT_TEXTURE: boolean;
  101838. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  101839. /** @hidden */
  101840. _areTexturesDirty: boolean;
  101841. }
  101842. /**
  101843. * Define the code related to the clear coat parameters of the pbr material.
  101844. */
  101845. export class PBRClearCoatConfiguration {
  101846. /**
  101847. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101848. * The default fits with a polyurethane material.
  101849. */
  101850. private static readonly _DefaultIndiceOfRefraction;
  101851. private _isEnabled;
  101852. /**
  101853. * Defines if the clear coat is enabled in the material.
  101854. */
  101855. isEnabled: boolean;
  101856. /**
  101857. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  101858. */
  101859. intensity: number;
  101860. /**
  101861. * Defines the clear coat layer roughness.
  101862. */
  101863. roughness: number;
  101864. private _indiceOfRefraction;
  101865. /**
  101866. * Defines the indice of refraction of the clear coat.
  101867. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101868. * The default fits with a polyurethane material.
  101869. * Changing the default value is more performance intensive.
  101870. */
  101871. indiceOfRefraction: number;
  101872. private _texture;
  101873. /**
  101874. * Stores the clear coat values in a texture.
  101875. */
  101876. texture: Nullable<BaseTexture>;
  101877. private _bumpTexture;
  101878. /**
  101879. * Define the clear coat specific bump texture.
  101880. */
  101881. bumpTexture: Nullable<BaseTexture>;
  101882. private _isTintEnabled;
  101883. /**
  101884. * Defines if the clear coat tint is enabled in the material.
  101885. */
  101886. isTintEnabled: boolean;
  101887. /**
  101888. * Defines if the clear coat tint is enabled in the material.
  101889. * This is only use if tint is enabled
  101890. */
  101891. tintColor: Color3;
  101892. /**
  101893. * Defines if the distance at which the tint color should be found in the
  101894. * clear coat media.
  101895. * This is only use if tint is enabled
  101896. */
  101897. tintColorAtDistance: number;
  101898. /**
  101899. * Defines the clear coat layer thickness.
  101900. * This is only use if tint is enabled
  101901. */
  101902. tintThickness: number;
  101903. private _tintTexture;
  101904. /**
  101905. * Stores the clear tint values in a texture.
  101906. * rgb is tint
  101907. * a is a thickness factor
  101908. */
  101909. tintTexture: Nullable<BaseTexture>;
  101910. /** @hidden */
  101911. private _internalMarkAllSubMeshesAsTexturesDirty;
  101912. /** @hidden */
  101913. _markAllSubMeshesAsTexturesDirty(): void;
  101914. /**
  101915. * Instantiate a new istance of clear coat configuration.
  101916. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101917. */
  101918. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101919. /**
  101920. * Specifies that the submesh is ready to be used.
  101921. * @param defines the list of "defines" to update.
  101922. * @param scene defines the scene the material belongs to.
  101923. * @param engine defines the engine the material belongs to.
  101924. * @param disableBumpMap defines wether the material disables bump or not.
  101925. * @returns - boolean indicating that the submesh is ready or not.
  101926. */
  101927. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  101928. /**
  101929. * Checks to see if a texture is used in the material.
  101930. * @param defines the list of "defines" to update.
  101931. * @param scene defines the scene to the material belongs to.
  101932. */
  101933. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  101934. /**
  101935. * Binds the material data.
  101936. * @param uniformBuffer defines the Uniform buffer to fill in.
  101937. * @param scene defines the scene the material belongs to.
  101938. * @param engine defines the engine the material belongs to.
  101939. * @param disableBumpMap defines wether the material disables bump or not.
  101940. * @param isFrozen defines wether the material is frozen or not.
  101941. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101942. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101943. */
  101944. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  101945. /**
  101946. * Checks to see if a texture is used in the material.
  101947. * @param texture - Base texture to use.
  101948. * @returns - Boolean specifying if a texture is used in the material.
  101949. */
  101950. hasTexture(texture: BaseTexture): boolean;
  101951. /**
  101952. * Returns an array of the actively used textures.
  101953. * @param activeTextures Array of BaseTextures
  101954. */
  101955. getActiveTextures(activeTextures: BaseTexture[]): void;
  101956. /**
  101957. * Returns the animatable textures.
  101958. * @param animatables Array of animatable textures.
  101959. */
  101960. getAnimatables(animatables: IAnimatable[]): void;
  101961. /**
  101962. * Disposes the resources of the material.
  101963. * @param forceDisposeTextures - Forces the disposal of all textures.
  101964. */
  101965. dispose(forceDisposeTextures?: boolean): void;
  101966. /**
  101967. * Get the current class name of the texture useful for serialization or dynamic coding.
  101968. * @returns "PBRClearCoatConfiguration"
  101969. */
  101970. getClassName(): string;
  101971. /**
  101972. * Add fallbacks to the effect fallbacks list.
  101973. * @param defines defines the Base texture to use.
  101974. * @param fallbacks defines the current fallback list.
  101975. * @param currentRank defines the current fallback rank.
  101976. * @returns the new fallback rank.
  101977. */
  101978. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101979. /**
  101980. * Add the required uniforms to the current list.
  101981. * @param uniforms defines the current uniform list.
  101982. */
  101983. static AddUniforms(uniforms: string[]): void;
  101984. /**
  101985. * Add the required samplers to the current list.
  101986. * @param samplers defines the current sampler list.
  101987. */
  101988. static AddSamplers(samplers: string[]): void;
  101989. /**
  101990. * Add the required uniforms to the current buffer.
  101991. * @param uniformBuffer defines the current uniform buffer.
  101992. */
  101993. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101994. /**
  101995. * Makes a duplicate of the current configuration into another one.
  101996. * @param clearCoatConfiguration define the config where to copy the info
  101997. */
  101998. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101999. /**
  102000. * Serializes this clear coat configuration.
  102001. * @returns - An object with the serialized config.
  102002. */
  102003. serialize(): any;
  102004. /**
  102005. * Parses a Clear Coat Configuration from a serialized object.
  102006. * @param source - Serialized object.
  102007. */
  102008. parse(source: any): void;
  102009. }
  102010. }
  102011. declare module BABYLON {
  102012. /**
  102013. * @hidden
  102014. */
  102015. export interface IMaterialAnisotropicDefines {
  102016. ANISOTROPIC: boolean;
  102017. ANISOTROPIC_TEXTURE: boolean;
  102018. ANISOTROPIC_TEXTUREDIRECTUV: number;
  102019. MAINUV1: boolean;
  102020. _areTexturesDirty: boolean;
  102021. _needUVs: boolean;
  102022. }
  102023. /**
  102024. * Define the code related to the anisotropic parameters of the pbr material.
  102025. */
  102026. export class PBRAnisotropicConfiguration {
  102027. private _isEnabled;
  102028. /**
  102029. * Defines if the anisotropy is enabled in the material.
  102030. */
  102031. isEnabled: boolean;
  102032. /**
  102033. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  102034. */
  102035. intensity: number;
  102036. /**
  102037. * Defines if the effect is along the tangents, bitangents or in between.
  102038. * By default, the effect is "strectching" the highlights along the tangents.
  102039. */
  102040. direction: Vector2;
  102041. private _texture;
  102042. /**
  102043. * Stores the anisotropy values in a texture.
  102044. * rg is direction (like normal from -1 to 1)
  102045. * b is a intensity
  102046. */
  102047. texture: Nullable<BaseTexture>;
  102048. /** @hidden */
  102049. private _internalMarkAllSubMeshesAsTexturesDirty;
  102050. /** @hidden */
  102051. _markAllSubMeshesAsTexturesDirty(): void;
  102052. /**
  102053. * Instantiate a new istance of anisotropy configuration.
  102054. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102055. */
  102056. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102057. /**
  102058. * Specifies that the submesh is ready to be used.
  102059. * @param defines the list of "defines" to update.
  102060. * @param scene defines the scene the material belongs to.
  102061. * @returns - boolean indicating that the submesh is ready or not.
  102062. */
  102063. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  102064. /**
  102065. * Checks to see if a texture is used in the material.
  102066. * @param defines the list of "defines" to update.
  102067. * @param mesh the mesh we are preparing the defines for.
  102068. * @param scene defines the scene the material belongs to.
  102069. */
  102070. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  102071. /**
  102072. * Binds the material data.
  102073. * @param uniformBuffer defines the Uniform buffer to fill in.
  102074. * @param scene defines the scene the material belongs to.
  102075. * @param isFrozen defines wether the material is frozen or not.
  102076. */
  102077. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  102078. /**
  102079. * Checks to see if a texture is used in the material.
  102080. * @param texture - Base texture to use.
  102081. * @returns - Boolean specifying if a texture is used in the material.
  102082. */
  102083. hasTexture(texture: BaseTexture): boolean;
  102084. /**
  102085. * Returns an array of the actively used textures.
  102086. * @param activeTextures Array of BaseTextures
  102087. */
  102088. getActiveTextures(activeTextures: BaseTexture[]): void;
  102089. /**
  102090. * Returns the animatable textures.
  102091. * @param animatables Array of animatable textures.
  102092. */
  102093. getAnimatables(animatables: IAnimatable[]): void;
  102094. /**
  102095. * Disposes the resources of the material.
  102096. * @param forceDisposeTextures - Forces the disposal of all textures.
  102097. */
  102098. dispose(forceDisposeTextures?: boolean): void;
  102099. /**
  102100. * Get the current class name of the texture useful for serialization or dynamic coding.
  102101. * @returns "PBRAnisotropicConfiguration"
  102102. */
  102103. getClassName(): string;
  102104. /**
  102105. * Add fallbacks to the effect fallbacks list.
  102106. * @param defines defines the Base texture to use.
  102107. * @param fallbacks defines the current fallback list.
  102108. * @param currentRank defines the current fallback rank.
  102109. * @returns the new fallback rank.
  102110. */
  102111. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102112. /**
  102113. * Add the required uniforms to the current list.
  102114. * @param uniforms defines the current uniform list.
  102115. */
  102116. static AddUniforms(uniforms: string[]): void;
  102117. /**
  102118. * Add the required uniforms to the current buffer.
  102119. * @param uniformBuffer defines the current uniform buffer.
  102120. */
  102121. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102122. /**
  102123. * Add the required samplers to the current list.
  102124. * @param samplers defines the current sampler list.
  102125. */
  102126. static AddSamplers(samplers: string[]): void;
  102127. /**
  102128. * Makes a duplicate of the current configuration into another one.
  102129. * @param anisotropicConfiguration define the config where to copy the info
  102130. */
  102131. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  102132. /**
  102133. * Serializes this anisotropy configuration.
  102134. * @returns - An object with the serialized config.
  102135. */
  102136. serialize(): any;
  102137. /**
  102138. * Parses a anisotropy Configuration from a serialized object.
  102139. * @param source - Serialized object.
  102140. */
  102141. parse(source: any): void;
  102142. }
  102143. }
  102144. declare module BABYLON {
  102145. /**
  102146. * @hidden
  102147. */
  102148. export interface IMaterialBRDFDefines {
  102149. BRDF_V_HEIGHT_CORRELATED: boolean;
  102150. MS_BRDF_ENERGY_CONSERVATION: boolean;
  102151. /** @hidden */
  102152. _areMiscDirty: boolean;
  102153. }
  102154. /**
  102155. * Define the code related to the BRDF parameters of the pbr material.
  102156. */
  102157. export class PBRBRDFConfiguration {
  102158. /**
  102159. * Default value used for the energy conservation.
  102160. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  102161. */
  102162. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  102163. /**
  102164. * Default value used for the Smith Visibility Height Correlated mode.
  102165. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  102166. */
  102167. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  102168. private _useEnergyConservation;
  102169. /**
  102170. * Defines if the material uses energy conservation.
  102171. */
  102172. useEnergyConservation: boolean;
  102173. private _useSmithVisibilityHeightCorrelated;
  102174. /**
  102175. * LEGACY Mode set to false
  102176. * Defines if the material uses height smith correlated visibility term.
  102177. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  102178. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  102179. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  102180. * Not relying on height correlated will also disable energy conservation.
  102181. */
  102182. useSmithVisibilityHeightCorrelated: boolean;
  102183. /** @hidden */
  102184. private _internalMarkAllSubMeshesAsMiscDirty;
  102185. /** @hidden */
  102186. _markAllSubMeshesAsMiscDirty(): void;
  102187. /**
  102188. * Instantiate a new istance of clear coat configuration.
  102189. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  102190. */
  102191. constructor(markAllSubMeshesAsMiscDirty: () => void);
  102192. /**
  102193. * Checks to see if a texture is used in the material.
  102194. * @param defines the list of "defines" to update.
  102195. */
  102196. prepareDefines(defines: IMaterialBRDFDefines): void;
  102197. /**
  102198. * Get the current class name of the texture useful for serialization or dynamic coding.
  102199. * @returns "PBRClearCoatConfiguration"
  102200. */
  102201. getClassName(): string;
  102202. /**
  102203. * Makes a duplicate of the current configuration into another one.
  102204. * @param brdfConfiguration define the config where to copy the info
  102205. */
  102206. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  102207. /**
  102208. * Serializes this BRDF configuration.
  102209. * @returns - An object with the serialized config.
  102210. */
  102211. serialize(): any;
  102212. /**
  102213. * Parses a BRDF Configuration from a serialized object.
  102214. * @param source - Serialized object.
  102215. */
  102216. parse(source: any): void;
  102217. }
  102218. }
  102219. declare module BABYLON {
  102220. /**
  102221. * @hidden
  102222. */
  102223. export interface IMaterialSheenDefines {
  102224. SHEEN: boolean;
  102225. SHEEN_TEXTURE: boolean;
  102226. SHEEN_TEXTUREDIRECTUV: number;
  102227. SHEEN_LINKWITHALBEDO: boolean;
  102228. /** @hidden */
  102229. _areTexturesDirty: boolean;
  102230. }
  102231. /**
  102232. * Define the code related to the Sheen parameters of the pbr material.
  102233. */
  102234. export class PBRSheenConfiguration {
  102235. private _isEnabled;
  102236. /**
  102237. * Defines if the material uses sheen.
  102238. */
  102239. isEnabled: boolean;
  102240. private _linkSheenWithAlbedo;
  102241. /**
  102242. * Defines if the sheen is linked to the sheen color.
  102243. */
  102244. linkSheenWithAlbedo: boolean;
  102245. /**
  102246. * Defines the sheen intensity.
  102247. */
  102248. intensity: number;
  102249. /**
  102250. * Defines the sheen color.
  102251. */
  102252. color: Color3;
  102253. private _texture;
  102254. /**
  102255. * Stores the sheen tint values in a texture.
  102256. * rgb is tint
  102257. * a is a intensity
  102258. */
  102259. texture: Nullable<BaseTexture>;
  102260. /** @hidden */
  102261. private _internalMarkAllSubMeshesAsTexturesDirty;
  102262. /** @hidden */
  102263. _markAllSubMeshesAsTexturesDirty(): void;
  102264. /**
  102265. * Instantiate a new istance of clear coat configuration.
  102266. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102267. */
  102268. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102269. /**
  102270. * Specifies that the submesh is ready to be used.
  102271. * @param defines the list of "defines" to update.
  102272. * @param scene defines the scene the material belongs to.
  102273. * @returns - boolean indicating that the submesh is ready or not.
  102274. */
  102275. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  102276. /**
  102277. * Checks to see if a texture is used in the material.
  102278. * @param defines the list of "defines" to update.
  102279. * @param scene defines the scene the material belongs to.
  102280. */
  102281. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  102282. /**
  102283. * Binds the material data.
  102284. * @param uniformBuffer defines the Uniform buffer to fill in.
  102285. * @param scene defines the scene the material belongs to.
  102286. * @param isFrozen defines wether the material is frozen or not.
  102287. */
  102288. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  102289. /**
  102290. * Checks to see if a texture is used in the material.
  102291. * @param texture - Base texture to use.
  102292. * @returns - Boolean specifying if a texture is used in the material.
  102293. */
  102294. hasTexture(texture: BaseTexture): boolean;
  102295. /**
  102296. * Returns an array of the actively used textures.
  102297. * @param activeTextures Array of BaseTextures
  102298. */
  102299. getActiveTextures(activeTextures: BaseTexture[]): void;
  102300. /**
  102301. * Returns the animatable textures.
  102302. * @param animatables Array of animatable textures.
  102303. */
  102304. getAnimatables(animatables: IAnimatable[]): void;
  102305. /**
  102306. * Disposes the resources of the material.
  102307. * @param forceDisposeTextures - Forces the disposal of all textures.
  102308. */
  102309. dispose(forceDisposeTextures?: boolean): void;
  102310. /**
  102311. * Get the current class name of the texture useful for serialization or dynamic coding.
  102312. * @returns "PBRSheenConfiguration"
  102313. */
  102314. getClassName(): string;
  102315. /**
  102316. * Add fallbacks to the effect fallbacks list.
  102317. * @param defines defines the Base texture to use.
  102318. * @param fallbacks defines the current fallback list.
  102319. * @param currentRank defines the current fallback rank.
  102320. * @returns the new fallback rank.
  102321. */
  102322. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102323. /**
  102324. * Add the required uniforms to the current list.
  102325. * @param uniforms defines the current uniform list.
  102326. */
  102327. static AddUniforms(uniforms: string[]): void;
  102328. /**
  102329. * Add the required uniforms to the current buffer.
  102330. * @param uniformBuffer defines the current uniform buffer.
  102331. */
  102332. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102333. /**
  102334. * Add the required samplers to the current list.
  102335. * @param samplers defines the current sampler list.
  102336. */
  102337. static AddSamplers(samplers: string[]): void;
  102338. /**
  102339. * Makes a duplicate of the current configuration into another one.
  102340. * @param sheenConfiguration define the config where to copy the info
  102341. */
  102342. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  102343. /**
  102344. * Serializes this BRDF configuration.
  102345. * @returns - An object with the serialized config.
  102346. */
  102347. serialize(): any;
  102348. /**
  102349. * Parses a Sheen Configuration from a serialized object.
  102350. * @param source - Serialized object.
  102351. */
  102352. parse(source: any): void;
  102353. }
  102354. }
  102355. declare module BABYLON {
  102356. /** @hidden */
  102357. export var pbrFragmentDeclaration: {
  102358. name: string;
  102359. shader: string;
  102360. };
  102361. }
  102362. declare module BABYLON {
  102363. /** @hidden */
  102364. export var pbrUboDeclaration: {
  102365. name: string;
  102366. shader: string;
  102367. };
  102368. }
  102369. declare module BABYLON {
  102370. /** @hidden */
  102371. export var pbrFragmentExtraDeclaration: {
  102372. name: string;
  102373. shader: string;
  102374. };
  102375. }
  102376. declare module BABYLON {
  102377. /** @hidden */
  102378. export var pbrFragmentSamplersDeclaration: {
  102379. name: string;
  102380. shader: string;
  102381. };
  102382. }
  102383. declare module BABYLON {
  102384. /** @hidden */
  102385. export var pbrHelperFunctions: {
  102386. name: string;
  102387. shader: string;
  102388. };
  102389. }
  102390. declare module BABYLON {
  102391. /** @hidden */
  102392. export var harmonicsFunctions: {
  102393. name: string;
  102394. shader: string;
  102395. };
  102396. }
  102397. declare module BABYLON {
  102398. /** @hidden */
  102399. export var pbrDirectLightingSetupFunctions: {
  102400. name: string;
  102401. shader: string;
  102402. };
  102403. }
  102404. declare module BABYLON {
  102405. /** @hidden */
  102406. export var pbrDirectLightingFalloffFunctions: {
  102407. name: string;
  102408. shader: string;
  102409. };
  102410. }
  102411. declare module BABYLON {
  102412. /** @hidden */
  102413. export var pbrBRDFFunctions: {
  102414. name: string;
  102415. shader: string;
  102416. };
  102417. }
  102418. declare module BABYLON {
  102419. /** @hidden */
  102420. export var pbrDirectLightingFunctions: {
  102421. name: string;
  102422. shader: string;
  102423. };
  102424. }
  102425. declare module BABYLON {
  102426. /** @hidden */
  102427. export var pbrIBLFunctions: {
  102428. name: string;
  102429. shader: string;
  102430. };
  102431. }
  102432. declare module BABYLON {
  102433. /** @hidden */
  102434. export var pbrDebug: {
  102435. name: string;
  102436. shader: string;
  102437. };
  102438. }
  102439. declare module BABYLON {
  102440. /** @hidden */
  102441. export var pbrPixelShader: {
  102442. name: string;
  102443. shader: string;
  102444. };
  102445. }
  102446. declare module BABYLON {
  102447. /** @hidden */
  102448. export var pbrVertexDeclaration: {
  102449. name: string;
  102450. shader: string;
  102451. };
  102452. }
  102453. declare module BABYLON {
  102454. /** @hidden */
  102455. export var pbrVertexShader: {
  102456. name: string;
  102457. shader: string;
  102458. };
  102459. }
  102460. declare module BABYLON {
  102461. /**
  102462. * The Physically based material base class of BJS.
  102463. *
  102464. * This offers the main features of a standard PBR material.
  102465. * For more information, please refer to the documentation :
  102466. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102467. */
  102468. export abstract class PBRBaseMaterial extends PushMaterial {
  102469. /**
  102470. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102471. */
  102472. static readonly PBRMATERIAL_OPAQUE: number;
  102473. /**
  102474. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102475. */
  102476. static readonly PBRMATERIAL_ALPHATEST: number;
  102477. /**
  102478. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102479. */
  102480. static readonly PBRMATERIAL_ALPHABLEND: number;
  102481. /**
  102482. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102483. * They are also discarded below the alpha cutoff threshold to improve performances.
  102484. */
  102485. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102486. /**
  102487. * Defines the default value of how much AO map is occluding the analytical lights
  102488. * (point spot...).
  102489. */
  102490. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102491. /**
  102492. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102493. */
  102494. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102495. /**
  102496. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102497. * to enhance interoperability with other engines.
  102498. */
  102499. static readonly LIGHTFALLOFF_GLTF: number;
  102500. /**
  102501. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102502. * to enhance interoperability with other materials.
  102503. */
  102504. static readonly LIGHTFALLOFF_STANDARD: number;
  102505. /**
  102506. * Intensity of the direct lights e.g. the four lights available in your scene.
  102507. * This impacts both the direct diffuse and specular highlights.
  102508. */
  102509. protected _directIntensity: number;
  102510. /**
  102511. * Intensity of the emissive part of the material.
  102512. * This helps controlling the emissive effect without modifying the emissive color.
  102513. */
  102514. protected _emissiveIntensity: number;
  102515. /**
  102516. * Intensity of the environment e.g. how much the environment will light the object
  102517. * either through harmonics for rough material or through the refelction for shiny ones.
  102518. */
  102519. protected _environmentIntensity: number;
  102520. /**
  102521. * This is a special control allowing the reduction of the specular highlights coming from the
  102522. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102523. */
  102524. protected _specularIntensity: number;
  102525. /**
  102526. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102527. */
  102528. private _lightingInfos;
  102529. /**
  102530. * Debug Control allowing disabling the bump map on this material.
  102531. */
  102532. protected _disableBumpMap: boolean;
  102533. /**
  102534. * AKA Diffuse Texture in standard nomenclature.
  102535. */
  102536. protected _albedoTexture: BaseTexture;
  102537. /**
  102538. * AKA Occlusion Texture in other nomenclature.
  102539. */
  102540. protected _ambientTexture: BaseTexture;
  102541. /**
  102542. * AKA Occlusion Texture Intensity in other nomenclature.
  102543. */
  102544. protected _ambientTextureStrength: number;
  102545. /**
  102546. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102547. * 1 means it completely occludes it
  102548. * 0 mean it has no impact
  102549. */
  102550. protected _ambientTextureImpactOnAnalyticalLights: number;
  102551. /**
  102552. * Stores the alpha values in a texture.
  102553. */
  102554. protected _opacityTexture: BaseTexture;
  102555. /**
  102556. * Stores the reflection values in a texture.
  102557. */
  102558. protected _reflectionTexture: BaseTexture;
  102559. /**
  102560. * Stores the refraction values in a texture.
  102561. */
  102562. protected _refractionTexture: BaseTexture;
  102563. /**
  102564. * Stores the emissive values in a texture.
  102565. */
  102566. protected _emissiveTexture: BaseTexture;
  102567. /**
  102568. * AKA Specular texture in other nomenclature.
  102569. */
  102570. protected _reflectivityTexture: BaseTexture;
  102571. /**
  102572. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102573. */
  102574. protected _metallicTexture: BaseTexture;
  102575. /**
  102576. * Specifies the metallic scalar of the metallic/roughness workflow.
  102577. * Can also be used to scale the metalness values of the metallic texture.
  102578. */
  102579. protected _metallic: Nullable<number>;
  102580. /**
  102581. * Specifies the roughness scalar of the metallic/roughness workflow.
  102582. * Can also be used to scale the roughness values of the metallic texture.
  102583. */
  102584. protected _roughness: Nullable<number>;
  102585. /**
  102586. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102587. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102588. */
  102589. protected _microSurfaceTexture: BaseTexture;
  102590. /**
  102591. * Stores surface normal data used to displace a mesh in a texture.
  102592. */
  102593. protected _bumpTexture: BaseTexture;
  102594. /**
  102595. * Stores the pre-calculated light information of a mesh in a texture.
  102596. */
  102597. protected _lightmapTexture: BaseTexture;
  102598. /**
  102599. * The color of a material in ambient lighting.
  102600. */
  102601. protected _ambientColor: Color3;
  102602. /**
  102603. * AKA Diffuse Color in other nomenclature.
  102604. */
  102605. protected _albedoColor: Color3;
  102606. /**
  102607. * AKA Specular Color in other nomenclature.
  102608. */
  102609. protected _reflectivityColor: Color3;
  102610. /**
  102611. * The color applied when light is reflected from a material.
  102612. */
  102613. protected _reflectionColor: Color3;
  102614. /**
  102615. * The color applied when light is emitted from a material.
  102616. */
  102617. protected _emissiveColor: Color3;
  102618. /**
  102619. * AKA Glossiness in other nomenclature.
  102620. */
  102621. protected _microSurface: number;
  102622. /**
  102623. * source material index of refraction (IOR)' / 'destination material IOR.
  102624. */
  102625. protected _indexOfRefraction: number;
  102626. /**
  102627. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102628. */
  102629. protected _invertRefractionY: boolean;
  102630. /**
  102631. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102632. * Materials half opaque for instance using refraction could benefit from this control.
  102633. */
  102634. protected _linkRefractionWithTransparency: boolean;
  102635. /**
  102636. * Specifies that the material will use the light map as a show map.
  102637. */
  102638. protected _useLightmapAsShadowmap: boolean;
  102639. /**
  102640. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102641. * makes the reflect vector face the model (under horizon).
  102642. */
  102643. protected _useHorizonOcclusion: boolean;
  102644. /**
  102645. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102646. * too much the area relying on ambient texture to define their ambient occlusion.
  102647. */
  102648. protected _useRadianceOcclusion: boolean;
  102649. /**
  102650. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102651. */
  102652. protected _useAlphaFromAlbedoTexture: boolean;
  102653. /**
  102654. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102655. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102656. */
  102657. protected _useSpecularOverAlpha: boolean;
  102658. /**
  102659. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102660. */
  102661. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102662. /**
  102663. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102664. */
  102665. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102666. /**
  102667. * Specifies if the metallic texture contains the roughness information in its green channel.
  102668. */
  102669. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102670. /**
  102671. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102672. */
  102673. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102674. /**
  102675. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102676. */
  102677. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102678. /**
  102679. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102680. */
  102681. protected _useAmbientInGrayScale: boolean;
  102682. /**
  102683. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102684. * The material will try to infer what glossiness each pixel should be.
  102685. */
  102686. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102687. /**
  102688. * Defines the falloff type used in this material.
  102689. * It by default is Physical.
  102690. */
  102691. protected _lightFalloff: number;
  102692. /**
  102693. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102694. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102695. */
  102696. protected _useRadianceOverAlpha: boolean;
  102697. /**
  102698. * Allows using an object space normal map (instead of tangent space).
  102699. */
  102700. protected _useObjectSpaceNormalMap: boolean;
  102701. /**
  102702. * Allows using the bump map in parallax mode.
  102703. */
  102704. protected _useParallax: boolean;
  102705. /**
  102706. * Allows using the bump map in parallax occlusion mode.
  102707. */
  102708. protected _useParallaxOcclusion: boolean;
  102709. /**
  102710. * Controls the scale bias of the parallax mode.
  102711. */
  102712. protected _parallaxScaleBias: number;
  102713. /**
  102714. * If sets to true, disables all the lights affecting the material.
  102715. */
  102716. protected _disableLighting: boolean;
  102717. /**
  102718. * Number of Simultaneous lights allowed on the material.
  102719. */
  102720. protected _maxSimultaneousLights: number;
  102721. /**
  102722. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102723. */
  102724. protected _invertNormalMapX: boolean;
  102725. /**
  102726. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102727. */
  102728. protected _invertNormalMapY: boolean;
  102729. /**
  102730. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102731. */
  102732. protected _twoSidedLighting: boolean;
  102733. /**
  102734. * Defines the alpha limits in alpha test mode.
  102735. */
  102736. protected _alphaCutOff: number;
  102737. /**
  102738. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102739. */
  102740. protected _forceAlphaTest: boolean;
  102741. /**
  102742. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102743. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102744. */
  102745. protected _useAlphaFresnel: boolean;
  102746. /**
  102747. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102748. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102749. */
  102750. protected _useLinearAlphaFresnel: boolean;
  102751. /**
  102752. * The transparency mode of the material.
  102753. */
  102754. protected _transparencyMode: Nullable<number>;
  102755. /**
  102756. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102757. * from cos thetav and roughness:
  102758. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102759. */
  102760. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102761. /**
  102762. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102763. */
  102764. protected _forceIrradianceInFragment: boolean;
  102765. /**
  102766. * Force normal to face away from face.
  102767. */
  102768. protected _forceNormalForward: boolean;
  102769. /**
  102770. * Enables specular anti aliasing in the PBR shader.
  102771. * It will both interacts on the Geometry for analytical and IBL lighting.
  102772. * It also prefilter the roughness map based on the bump values.
  102773. */
  102774. protected _enableSpecularAntiAliasing: boolean;
  102775. /**
  102776. * Default configuration related to image processing available in the PBR Material.
  102777. */
  102778. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102779. /**
  102780. * Keep track of the image processing observer to allow dispose and replace.
  102781. */
  102782. private _imageProcessingObserver;
  102783. /**
  102784. * Attaches a new image processing configuration to the PBR Material.
  102785. * @param configuration
  102786. */
  102787. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102788. /**
  102789. * Stores the available render targets.
  102790. */
  102791. private _renderTargets;
  102792. /**
  102793. * Sets the global ambient color for the material used in lighting calculations.
  102794. */
  102795. private _globalAmbientColor;
  102796. /**
  102797. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102798. */
  102799. private _useLogarithmicDepth;
  102800. /**
  102801. * If set to true, no lighting calculations will be applied.
  102802. */
  102803. private _unlit;
  102804. private _debugMode;
  102805. /**
  102806. * @hidden
  102807. * This is reserved for the inspector.
  102808. * Defines the material debug mode.
  102809. * It helps seeing only some components of the material while troubleshooting.
  102810. */
  102811. debugMode: number;
  102812. /**
  102813. * @hidden
  102814. * This is reserved for the inspector.
  102815. * Specify from where on screen the debug mode should start.
  102816. * The value goes from -1 (full screen) to 1 (not visible)
  102817. * It helps with side by side comparison against the final render
  102818. * This defaults to -1
  102819. */
  102820. private debugLimit;
  102821. /**
  102822. * @hidden
  102823. * This is reserved for the inspector.
  102824. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102825. * You can use the factor to better multiply the final value.
  102826. */
  102827. private debugFactor;
  102828. /**
  102829. * Defines the clear coat layer parameters for the material.
  102830. */
  102831. readonly clearCoat: PBRClearCoatConfiguration;
  102832. /**
  102833. * Defines the anisotropic parameters for the material.
  102834. */
  102835. readonly anisotropy: PBRAnisotropicConfiguration;
  102836. /**
  102837. * Defines the BRDF parameters for the material.
  102838. */
  102839. readonly brdf: PBRBRDFConfiguration;
  102840. /**
  102841. * Defines the Sheen parameters for the material.
  102842. */
  102843. readonly sheen: PBRSheenConfiguration;
  102844. /**
  102845. * Instantiates a new PBRMaterial instance.
  102846. *
  102847. * @param name The material name
  102848. * @param scene The scene the material will be use in.
  102849. */
  102850. constructor(name: string, scene: Scene);
  102851. /**
  102852. * Gets a boolean indicating that current material needs to register RTT
  102853. */
  102854. readonly hasRenderTargetTextures: boolean;
  102855. /**
  102856. * Gets the name of the material class.
  102857. */
  102858. getClassName(): string;
  102859. /**
  102860. * Gets the name of the material shader.
  102861. * @returns - string that specifies the shader program of the material.
  102862. */
  102863. getShaderName(): string;
  102864. /**
  102865. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102866. */
  102867. /**
  102868. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102869. */
  102870. useLogarithmicDepth: boolean;
  102871. /**
  102872. * Gets the current transparency mode.
  102873. */
  102874. /**
  102875. * Sets the transparency mode of the material.
  102876. *
  102877. * | Value | Type | Description |
  102878. * | ----- | ----------------------------------- | ----------- |
  102879. * | 0 | OPAQUE | |
  102880. * | 1 | ALPHATEST | |
  102881. * | 2 | ALPHABLEND | |
  102882. * | 3 | ALPHATESTANDBLEND | |
  102883. *
  102884. */
  102885. transparencyMode: Nullable<number>;
  102886. /**
  102887. * Returns true if alpha blending should be disabled.
  102888. */
  102889. private readonly _disableAlphaBlending;
  102890. /**
  102891. * Specifies whether or not this material should be rendered in alpha blend mode.
  102892. */
  102893. needAlphaBlending(): boolean;
  102894. /**
  102895. * Specifies if the mesh will require alpha blending.
  102896. * @param mesh - BJS mesh.
  102897. */
  102898. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102899. /**
  102900. * Specifies whether or not this material should be rendered in alpha test mode.
  102901. */
  102902. needAlphaTesting(): boolean;
  102903. /**
  102904. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  102905. */
  102906. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  102907. /**
  102908. * Gets the texture used for the alpha test.
  102909. */
  102910. getAlphaTestTexture(): BaseTexture;
  102911. /**
  102912. * Specifies that the submesh is ready to be used.
  102913. * @param mesh - BJS mesh.
  102914. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  102915. * @param useInstances - Specifies that instances should be used.
  102916. * @returns - boolean indicating that the submesh is ready or not.
  102917. */
  102918. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102919. /**
  102920. * Specifies if the material uses metallic roughness workflow.
  102921. * @returns boolean specifiying if the material uses metallic roughness workflow.
  102922. */
  102923. isMetallicWorkflow(): boolean;
  102924. private _prepareEffect;
  102925. private _prepareDefines;
  102926. /**
  102927. * Force shader compilation
  102928. */
  102929. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  102930. clipPlane: boolean;
  102931. }>): void;
  102932. /**
  102933. * Initializes the uniform buffer layout for the shader.
  102934. */
  102935. buildUniformLayout(): void;
  102936. /**
  102937. * Unbinds the textures.
  102938. */
  102939. unbind(): void;
  102940. /**
  102941. * Binds the submesh data.
  102942. * @param world - The world matrix.
  102943. * @param mesh - The BJS mesh.
  102944. * @param subMesh - A submesh of the BJS mesh.
  102945. */
  102946. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102947. /**
  102948. * Returns the animatable textures.
  102949. * @returns - Array of animatable textures.
  102950. */
  102951. getAnimatables(): IAnimatable[];
  102952. /**
  102953. * Returns the texture used for reflections.
  102954. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  102955. */
  102956. private _getReflectionTexture;
  102957. /**
  102958. * Returns the texture used for refraction or null if none is used.
  102959. * @returns - Refection texture if present. If no refraction texture and refraction
  102960. * is linked with transparency, returns environment texture. Otherwise, returns null.
  102961. */
  102962. private _getRefractionTexture;
  102963. /**
  102964. * Returns an array of the actively used textures.
  102965. * @returns - Array of BaseTextures
  102966. */
  102967. getActiveTextures(): BaseTexture[];
  102968. /**
  102969. * Checks to see if a texture is used in the material.
  102970. * @param texture - Base texture to use.
  102971. * @returns - Boolean specifying if a texture is used in the material.
  102972. */
  102973. hasTexture(texture: BaseTexture): boolean;
  102974. /**
  102975. * Disposes the resources of the material.
  102976. * @param forceDisposeEffect - Forces the disposal of effects.
  102977. * @param forceDisposeTextures - Forces the disposal of all textures.
  102978. */
  102979. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102980. }
  102981. }
  102982. declare module BABYLON {
  102983. /**
  102984. * The Physically based material of BJS.
  102985. *
  102986. * This offers the main features of a standard PBR material.
  102987. * For more information, please refer to the documentation :
  102988. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102989. */
  102990. export class PBRMaterial extends PBRBaseMaterial {
  102991. /**
  102992. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102993. */
  102994. static readonly PBRMATERIAL_OPAQUE: number;
  102995. /**
  102996. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102997. */
  102998. static readonly PBRMATERIAL_ALPHATEST: number;
  102999. /**
  103000. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103001. */
  103002. static readonly PBRMATERIAL_ALPHABLEND: number;
  103003. /**
  103004. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103005. * They are also discarded below the alpha cutoff threshold to improve performances.
  103006. */
  103007. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  103008. /**
  103009. * Defines the default value of how much AO map is occluding the analytical lights
  103010. * (point spot...).
  103011. */
  103012. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  103013. /**
  103014. * Intensity of the direct lights e.g. the four lights available in your scene.
  103015. * This impacts both the direct diffuse and specular highlights.
  103016. */
  103017. directIntensity: number;
  103018. /**
  103019. * Intensity of the emissive part of the material.
  103020. * This helps controlling the emissive effect without modifying the emissive color.
  103021. */
  103022. emissiveIntensity: number;
  103023. /**
  103024. * Intensity of the environment e.g. how much the environment will light the object
  103025. * either through harmonics for rough material or through the refelction for shiny ones.
  103026. */
  103027. environmentIntensity: number;
  103028. /**
  103029. * This is a special control allowing the reduction of the specular highlights coming from the
  103030. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  103031. */
  103032. specularIntensity: number;
  103033. /**
  103034. * Debug Control allowing disabling the bump map on this material.
  103035. */
  103036. disableBumpMap: boolean;
  103037. /**
  103038. * AKA Diffuse Texture in standard nomenclature.
  103039. */
  103040. albedoTexture: BaseTexture;
  103041. /**
  103042. * AKA Occlusion Texture in other nomenclature.
  103043. */
  103044. ambientTexture: BaseTexture;
  103045. /**
  103046. * AKA Occlusion Texture Intensity in other nomenclature.
  103047. */
  103048. ambientTextureStrength: number;
  103049. /**
  103050. * Defines how much the AO map is occluding the analytical lights (point spot...).
  103051. * 1 means it completely occludes it
  103052. * 0 mean it has no impact
  103053. */
  103054. ambientTextureImpactOnAnalyticalLights: number;
  103055. /**
  103056. * Stores the alpha values in a texture.
  103057. */
  103058. opacityTexture: BaseTexture;
  103059. /**
  103060. * Stores the reflection values in a texture.
  103061. */
  103062. reflectionTexture: Nullable<BaseTexture>;
  103063. /**
  103064. * Stores the emissive values in a texture.
  103065. */
  103066. emissiveTexture: BaseTexture;
  103067. /**
  103068. * AKA Specular texture in other nomenclature.
  103069. */
  103070. reflectivityTexture: BaseTexture;
  103071. /**
  103072. * Used to switch from specular/glossiness to metallic/roughness workflow.
  103073. */
  103074. metallicTexture: BaseTexture;
  103075. /**
  103076. * Specifies the metallic scalar of the metallic/roughness workflow.
  103077. * Can also be used to scale the metalness values of the metallic texture.
  103078. */
  103079. metallic: Nullable<number>;
  103080. /**
  103081. * Specifies the roughness scalar of the metallic/roughness workflow.
  103082. * Can also be used to scale the roughness values of the metallic texture.
  103083. */
  103084. roughness: Nullable<number>;
  103085. /**
  103086. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  103087. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  103088. */
  103089. microSurfaceTexture: BaseTexture;
  103090. /**
  103091. * Stores surface normal data used to displace a mesh in a texture.
  103092. */
  103093. bumpTexture: BaseTexture;
  103094. /**
  103095. * Stores the pre-calculated light information of a mesh in a texture.
  103096. */
  103097. lightmapTexture: BaseTexture;
  103098. /**
  103099. * Stores the refracted light information in a texture.
  103100. */
  103101. refractionTexture: BaseTexture;
  103102. /**
  103103. * The color of a material in ambient lighting.
  103104. */
  103105. ambientColor: Color3;
  103106. /**
  103107. * AKA Diffuse Color in other nomenclature.
  103108. */
  103109. albedoColor: Color3;
  103110. /**
  103111. * AKA Specular Color in other nomenclature.
  103112. */
  103113. reflectivityColor: Color3;
  103114. /**
  103115. * The color reflected from the material.
  103116. */
  103117. reflectionColor: Color3;
  103118. /**
  103119. * The color emitted from the material.
  103120. */
  103121. emissiveColor: Color3;
  103122. /**
  103123. * AKA Glossiness in other nomenclature.
  103124. */
  103125. microSurface: number;
  103126. /**
  103127. * source material index of refraction (IOR)' / 'destination material IOR.
  103128. */
  103129. indexOfRefraction: number;
  103130. /**
  103131. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103132. */
  103133. invertRefractionY: boolean;
  103134. /**
  103135. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103136. * Materials half opaque for instance using refraction could benefit from this control.
  103137. */
  103138. linkRefractionWithTransparency: boolean;
  103139. /**
  103140. * If true, the light map contains occlusion information instead of lighting info.
  103141. */
  103142. useLightmapAsShadowmap: boolean;
  103143. /**
  103144. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  103145. */
  103146. useAlphaFromAlbedoTexture: boolean;
  103147. /**
  103148. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103149. */
  103150. forceAlphaTest: boolean;
  103151. /**
  103152. * Defines the alpha limits in alpha test mode.
  103153. */
  103154. alphaCutOff: number;
  103155. /**
  103156. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103157. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103158. */
  103159. useSpecularOverAlpha: boolean;
  103160. /**
  103161. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  103162. */
  103163. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  103164. /**
  103165. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  103166. */
  103167. useRoughnessFromMetallicTextureAlpha: boolean;
  103168. /**
  103169. * Specifies if the metallic texture contains the roughness information in its green channel.
  103170. */
  103171. useRoughnessFromMetallicTextureGreen: boolean;
  103172. /**
  103173. * Specifies if the metallic texture contains the metallness information in its blue channel.
  103174. */
  103175. useMetallnessFromMetallicTextureBlue: boolean;
  103176. /**
  103177. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  103178. */
  103179. useAmbientOcclusionFromMetallicTextureRed: boolean;
  103180. /**
  103181. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  103182. */
  103183. useAmbientInGrayScale: boolean;
  103184. /**
  103185. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  103186. * The material will try to infer what glossiness each pixel should be.
  103187. */
  103188. useAutoMicroSurfaceFromReflectivityMap: boolean;
  103189. /**
  103190. * BJS is using an harcoded light falloff based on a manually sets up range.
  103191. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103192. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103193. */
  103194. /**
  103195. * BJS is using an harcoded light falloff based on a manually sets up range.
  103196. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103197. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103198. */
  103199. usePhysicalLightFalloff: boolean;
  103200. /**
  103201. * In order to support the falloff compatibility with gltf, a special mode has been added
  103202. * to reproduce the gltf light falloff.
  103203. */
  103204. /**
  103205. * In order to support the falloff compatibility with gltf, a special mode has been added
  103206. * to reproduce the gltf light falloff.
  103207. */
  103208. useGLTFLightFalloff: boolean;
  103209. /**
  103210. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103211. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103212. */
  103213. useRadianceOverAlpha: boolean;
  103214. /**
  103215. * Allows using an object space normal map (instead of tangent space).
  103216. */
  103217. useObjectSpaceNormalMap: boolean;
  103218. /**
  103219. * Allows using the bump map in parallax mode.
  103220. */
  103221. useParallax: boolean;
  103222. /**
  103223. * Allows using the bump map in parallax occlusion mode.
  103224. */
  103225. useParallaxOcclusion: boolean;
  103226. /**
  103227. * Controls the scale bias of the parallax mode.
  103228. */
  103229. parallaxScaleBias: number;
  103230. /**
  103231. * If sets to true, disables all the lights affecting the material.
  103232. */
  103233. disableLighting: boolean;
  103234. /**
  103235. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  103236. */
  103237. forceIrradianceInFragment: boolean;
  103238. /**
  103239. * Number of Simultaneous lights allowed on the material.
  103240. */
  103241. maxSimultaneousLights: number;
  103242. /**
  103243. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103244. */
  103245. invertNormalMapX: boolean;
  103246. /**
  103247. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103248. */
  103249. invertNormalMapY: boolean;
  103250. /**
  103251. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103252. */
  103253. twoSidedLighting: boolean;
  103254. /**
  103255. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103256. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103257. */
  103258. useAlphaFresnel: boolean;
  103259. /**
  103260. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103261. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103262. */
  103263. useLinearAlphaFresnel: boolean;
  103264. /**
  103265. * Let user defines the brdf lookup texture used for IBL.
  103266. * A default 8bit version is embedded but you could point at :
  103267. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  103268. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103269. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103270. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103271. */
  103272. environmentBRDFTexture: Nullable<BaseTexture>;
  103273. /**
  103274. * Force normal to face away from face.
  103275. */
  103276. forceNormalForward: boolean;
  103277. /**
  103278. * Enables specular anti aliasing in the PBR shader.
  103279. * It will both interacts on the Geometry for analytical and IBL lighting.
  103280. * It also prefilter the roughness map based on the bump values.
  103281. */
  103282. enableSpecularAntiAliasing: boolean;
  103283. /**
  103284. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103285. * makes the reflect vector face the model (under horizon).
  103286. */
  103287. useHorizonOcclusion: boolean;
  103288. /**
  103289. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103290. * too much the area relying on ambient texture to define their ambient occlusion.
  103291. */
  103292. useRadianceOcclusion: boolean;
  103293. /**
  103294. * If set to true, no lighting calculations will be applied.
  103295. */
  103296. unlit: boolean;
  103297. /**
  103298. * Gets the image processing configuration used either in this material.
  103299. */
  103300. /**
  103301. * Sets the Default image processing configuration used either in the this material.
  103302. *
  103303. * If sets to null, the scene one is in use.
  103304. */
  103305. imageProcessingConfiguration: ImageProcessingConfiguration;
  103306. /**
  103307. * Gets wether the color curves effect is enabled.
  103308. */
  103309. /**
  103310. * Sets wether the color curves effect is enabled.
  103311. */
  103312. cameraColorCurvesEnabled: boolean;
  103313. /**
  103314. * Gets wether the color grading effect is enabled.
  103315. */
  103316. /**
  103317. * Gets wether the color grading effect is enabled.
  103318. */
  103319. cameraColorGradingEnabled: boolean;
  103320. /**
  103321. * Gets wether tonemapping is enabled or not.
  103322. */
  103323. /**
  103324. * Sets wether tonemapping is enabled or not
  103325. */
  103326. cameraToneMappingEnabled: boolean;
  103327. /**
  103328. * The camera exposure used on this material.
  103329. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103330. * This corresponds to a photographic exposure.
  103331. */
  103332. /**
  103333. * The camera exposure used on this material.
  103334. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103335. * This corresponds to a photographic exposure.
  103336. */
  103337. cameraExposure: number;
  103338. /**
  103339. * Gets The camera contrast used on this material.
  103340. */
  103341. /**
  103342. * Sets The camera contrast used on this material.
  103343. */
  103344. cameraContrast: number;
  103345. /**
  103346. * Gets the Color Grading 2D Lookup Texture.
  103347. */
  103348. /**
  103349. * Sets the Color Grading 2D Lookup Texture.
  103350. */
  103351. cameraColorGradingTexture: Nullable<BaseTexture>;
  103352. /**
  103353. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103354. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103355. * 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;
  103356. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103357. */
  103358. /**
  103359. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103360. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103361. * 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;
  103362. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103363. */
  103364. cameraColorCurves: Nullable<ColorCurves>;
  103365. /**
  103366. * Instantiates a new PBRMaterial instance.
  103367. *
  103368. * @param name The material name
  103369. * @param scene The scene the material will be use in.
  103370. */
  103371. constructor(name: string, scene: Scene);
  103372. /**
  103373. * Returns the name of this material class.
  103374. */
  103375. getClassName(): string;
  103376. /**
  103377. * Makes a duplicate of the current material.
  103378. * @param name - name to use for the new material.
  103379. */
  103380. clone(name: string): PBRMaterial;
  103381. /**
  103382. * Serializes this PBR Material.
  103383. * @returns - An object with the serialized material.
  103384. */
  103385. serialize(): any;
  103386. /**
  103387. * Parses a PBR Material from a serialized object.
  103388. * @param source - Serialized object.
  103389. * @param scene - BJS scene instance.
  103390. * @param rootUrl - url for the scene object
  103391. * @returns - PBRMaterial
  103392. */
  103393. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  103394. }
  103395. }
  103396. declare module BABYLON {
  103397. /**
  103398. * Direct draw surface info
  103399. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103400. */
  103401. export interface DDSInfo {
  103402. /**
  103403. * Width of the texture
  103404. */
  103405. width: number;
  103406. /**
  103407. * Width of the texture
  103408. */
  103409. height: number;
  103410. /**
  103411. * Number of Mipmaps for the texture
  103412. * @see https://en.wikipedia.org/wiki/Mipmap
  103413. */
  103414. mipmapCount: number;
  103415. /**
  103416. * If the textures format is a known fourCC format
  103417. * @see https://www.fourcc.org/
  103418. */
  103419. isFourCC: boolean;
  103420. /**
  103421. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103422. */
  103423. isRGB: boolean;
  103424. /**
  103425. * If the texture is a lumincance format
  103426. */
  103427. isLuminance: boolean;
  103428. /**
  103429. * If this is a cube texture
  103430. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103431. */
  103432. isCube: boolean;
  103433. /**
  103434. * If the texture is a compressed format eg. FOURCC_DXT1
  103435. */
  103436. isCompressed: boolean;
  103437. /**
  103438. * The dxgiFormat of the texture
  103439. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  103440. */
  103441. dxgiFormat: number;
  103442. /**
  103443. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  103444. */
  103445. textureType: number;
  103446. /**
  103447. * Sphericle polynomial created for the dds texture
  103448. */
  103449. sphericalPolynomial?: SphericalPolynomial;
  103450. }
  103451. /**
  103452. * Class used to provide DDS decompression tools
  103453. */
  103454. export class DDSTools {
  103455. /**
  103456. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  103457. */
  103458. static StoreLODInAlphaChannel: boolean;
  103459. /**
  103460. * Gets DDS information from an array buffer
  103461. * @param arrayBuffer defines the array buffer to read data from
  103462. * @returns the DDS information
  103463. */
  103464. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  103465. private static _FloatView;
  103466. private static _Int32View;
  103467. private static _ToHalfFloat;
  103468. private static _FromHalfFloat;
  103469. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  103470. private static _GetHalfFloatRGBAArrayBuffer;
  103471. private static _GetFloatRGBAArrayBuffer;
  103472. private static _GetFloatAsUIntRGBAArrayBuffer;
  103473. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  103474. private static _GetRGBAArrayBuffer;
  103475. private static _ExtractLongWordOrder;
  103476. private static _GetRGBArrayBuffer;
  103477. private static _GetLuminanceArrayBuffer;
  103478. /**
  103479. * Uploads DDS Levels to a Babylon Texture
  103480. * @hidden
  103481. */
  103482. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  103483. }
  103484. interface Engine {
  103485. /**
  103486. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  103487. * @param rootUrl defines the url where the file to load is located
  103488. * @param scene defines the current scene
  103489. * @param lodScale defines scale to apply to the mip map selection
  103490. * @param lodOffset defines offset to apply to the mip map selection
  103491. * @param onLoad defines an optional callback raised when the texture is loaded
  103492. * @param onError defines an optional callback raised if there is an issue to load the texture
  103493. * @param format defines the format of the data
  103494. * @param forcedExtension defines the extension to use to pick the right loader
  103495. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  103496. * @returns the cube texture as an InternalTexture
  103497. */
  103498. 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;
  103499. }
  103500. }
  103501. declare module BABYLON {
  103502. /**
  103503. * Implementation of the DDS Texture Loader.
  103504. * @hidden
  103505. */
  103506. export class _DDSTextureLoader implements IInternalTextureLoader {
  103507. /**
  103508. * Defines wether the loader supports cascade loading the different faces.
  103509. */
  103510. readonly supportCascades: boolean;
  103511. /**
  103512. * This returns if the loader support the current file information.
  103513. * @param extension defines the file extension of the file being loaded
  103514. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103515. * @param fallback defines the fallback internal texture if any
  103516. * @param isBase64 defines whether the texture is encoded as a base64
  103517. * @param isBuffer defines whether the texture data are stored as a buffer
  103518. * @returns true if the loader can load the specified file
  103519. */
  103520. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103521. /**
  103522. * Transform the url before loading if required.
  103523. * @param rootUrl the url of the texture
  103524. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103525. * @returns the transformed texture
  103526. */
  103527. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103528. /**
  103529. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103530. * @param rootUrl the url of the texture
  103531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103532. * @returns the fallback texture
  103533. */
  103534. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103535. /**
  103536. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103537. * @param data contains the texture data
  103538. * @param texture defines the BabylonJS internal texture
  103539. * @param createPolynomials will be true if polynomials have been requested
  103540. * @param onLoad defines the callback to trigger once the texture is ready
  103541. * @param onError defines the callback to trigger in case of error
  103542. */
  103543. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103544. /**
  103545. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103546. * @param data contains the texture data
  103547. * @param texture defines the BabylonJS internal texture
  103548. * @param callback defines the method to call once ready to upload
  103549. */
  103550. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103551. }
  103552. }
  103553. declare module BABYLON {
  103554. /** @hidden */
  103555. export var rgbdEncodePixelShader: {
  103556. name: string;
  103557. shader: string;
  103558. };
  103559. }
  103560. declare module BABYLON {
  103561. /** @hidden */
  103562. export var rgbdDecodePixelShader: {
  103563. name: string;
  103564. shader: string;
  103565. };
  103566. }
  103567. declare module BABYLON {
  103568. /**
  103569. * Raw texture data and descriptor sufficient for WebGL texture upload
  103570. */
  103571. export interface EnvironmentTextureInfo {
  103572. /**
  103573. * Version of the environment map
  103574. */
  103575. version: number;
  103576. /**
  103577. * Width of image
  103578. */
  103579. width: number;
  103580. /**
  103581. * Irradiance information stored in the file.
  103582. */
  103583. irradiance: any;
  103584. /**
  103585. * Specular information stored in the file.
  103586. */
  103587. specular: any;
  103588. }
  103589. /**
  103590. * Sets of helpers addressing the serialization and deserialization of environment texture
  103591. * stored in a BabylonJS env file.
  103592. * Those files are usually stored as .env files.
  103593. */
  103594. export class EnvironmentTextureTools {
  103595. /**
  103596. * Magic number identifying the env file.
  103597. */
  103598. private static _MagicBytes;
  103599. /**
  103600. * Gets the environment info from an env file.
  103601. * @param data The array buffer containing the .env bytes.
  103602. * @returns the environment file info (the json header) if successfully parsed.
  103603. */
  103604. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  103605. /**
  103606. * Creates an environment texture from a loaded cube texture.
  103607. * @param texture defines the cube texture to convert in env file
  103608. * @return a promise containing the environment data if succesfull.
  103609. */
  103610. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  103611. /**
  103612. * Creates a JSON representation of the spherical data.
  103613. * @param texture defines the texture containing the polynomials
  103614. * @return the JSON representation of the spherical info
  103615. */
  103616. private static _CreateEnvTextureIrradiance;
  103617. /**
  103618. * Uploads the texture info contained in the env file to the GPU.
  103619. * @param texture defines the internal texture to upload to
  103620. * @param arrayBuffer defines the buffer cotaining the data to load
  103621. * @param info defines the texture info retrieved through the GetEnvInfo method
  103622. * @returns a promise
  103623. */
  103624. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  103625. /**
  103626. * Uploads the levels of image data to the GPU.
  103627. * @param texture defines the internal texture to upload to
  103628. * @param imageData defines the array buffer views of image data [mipmap][face]
  103629. * @returns a promise
  103630. */
  103631. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  103632. /**
  103633. * Uploads spherical polynomials information to the texture.
  103634. * @param texture defines the texture we are trying to upload the information to
  103635. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  103636. */
  103637. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  103638. /** @hidden */
  103639. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103640. }
  103641. }
  103642. declare module BABYLON {
  103643. /**
  103644. * Implementation of the ENV Texture Loader.
  103645. * @hidden
  103646. */
  103647. export class _ENVTextureLoader implements IInternalTextureLoader {
  103648. /**
  103649. * Defines wether the loader supports cascade loading the different faces.
  103650. */
  103651. readonly supportCascades: boolean;
  103652. /**
  103653. * This returns if the loader support the current file information.
  103654. * @param extension defines the file extension of the file being loaded
  103655. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103656. * @param fallback defines the fallback internal texture if any
  103657. * @param isBase64 defines whether the texture is encoded as a base64
  103658. * @param isBuffer defines whether the texture data are stored as a buffer
  103659. * @returns true if the loader can load the specified file
  103660. */
  103661. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103662. /**
  103663. * Transform the url before loading if required.
  103664. * @param rootUrl the url of the texture
  103665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103666. * @returns the transformed texture
  103667. */
  103668. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103669. /**
  103670. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103671. * @param rootUrl the url of the texture
  103672. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103673. * @returns the fallback texture
  103674. */
  103675. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103676. /**
  103677. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103678. * @param data contains the texture data
  103679. * @param texture defines the BabylonJS internal texture
  103680. * @param createPolynomials will be true if polynomials have been requested
  103681. * @param onLoad defines the callback to trigger once the texture is ready
  103682. * @param onError defines the callback to trigger in case of error
  103683. */
  103684. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103685. /**
  103686. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103687. * @param data contains the texture data
  103688. * @param texture defines the BabylonJS internal texture
  103689. * @param callback defines the method to call once ready to upload
  103690. */
  103691. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103692. }
  103693. }
  103694. declare module BABYLON {
  103695. /**
  103696. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103697. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103698. */
  103699. export class KhronosTextureContainer {
  103700. /** contents of the KTX container file */
  103701. arrayBuffer: any;
  103702. private static HEADER_LEN;
  103703. private static COMPRESSED_2D;
  103704. private static COMPRESSED_3D;
  103705. private static TEX_2D;
  103706. private static TEX_3D;
  103707. /**
  103708. * Gets the openGL type
  103709. */
  103710. glType: number;
  103711. /**
  103712. * Gets the openGL type size
  103713. */
  103714. glTypeSize: number;
  103715. /**
  103716. * Gets the openGL format
  103717. */
  103718. glFormat: number;
  103719. /**
  103720. * Gets the openGL internal format
  103721. */
  103722. glInternalFormat: number;
  103723. /**
  103724. * Gets the base internal format
  103725. */
  103726. glBaseInternalFormat: number;
  103727. /**
  103728. * Gets image width in pixel
  103729. */
  103730. pixelWidth: number;
  103731. /**
  103732. * Gets image height in pixel
  103733. */
  103734. pixelHeight: number;
  103735. /**
  103736. * Gets image depth in pixels
  103737. */
  103738. pixelDepth: number;
  103739. /**
  103740. * Gets the number of array elements
  103741. */
  103742. numberOfArrayElements: number;
  103743. /**
  103744. * Gets the number of faces
  103745. */
  103746. numberOfFaces: number;
  103747. /**
  103748. * Gets the number of mipmap levels
  103749. */
  103750. numberOfMipmapLevels: number;
  103751. /**
  103752. * Gets the bytes of key value data
  103753. */
  103754. bytesOfKeyValueData: number;
  103755. /**
  103756. * Gets the load type
  103757. */
  103758. loadType: number;
  103759. /**
  103760. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  103761. */
  103762. isInvalid: boolean;
  103763. /**
  103764. * Creates a new KhronosTextureContainer
  103765. * @param arrayBuffer contents of the KTX container file
  103766. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  103767. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  103768. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  103769. */
  103770. constructor(
  103771. /** contents of the KTX container file */
  103772. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  103773. /**
  103774. * Uploads KTX content to a Babylon Texture.
  103775. * It is assumed that the texture has already been created & is currently bound
  103776. * @hidden
  103777. */
  103778. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  103779. private _upload2DCompressedLevels;
  103780. }
  103781. }
  103782. declare module BABYLON {
  103783. /**
  103784. * Implementation of the KTX Texture Loader.
  103785. * @hidden
  103786. */
  103787. export class _KTXTextureLoader implements IInternalTextureLoader {
  103788. /**
  103789. * Defines wether the loader supports cascade loading the different faces.
  103790. */
  103791. readonly supportCascades: boolean;
  103792. /**
  103793. * This returns if the loader support the current file information.
  103794. * @param extension defines the file extension of the file being loaded
  103795. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103796. * @param fallback defines the fallback internal texture if any
  103797. * @param isBase64 defines whether the texture is encoded as a base64
  103798. * @param isBuffer defines whether the texture data are stored as a buffer
  103799. * @returns true if the loader can load the specified file
  103800. */
  103801. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103802. /**
  103803. * Transform the url before loading if required.
  103804. * @param rootUrl the url of the texture
  103805. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103806. * @returns the transformed texture
  103807. */
  103808. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103809. /**
  103810. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103811. * @param rootUrl the url of the texture
  103812. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103813. * @returns the fallback texture
  103814. */
  103815. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103816. /**
  103817. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103818. * @param data contains the texture data
  103819. * @param texture defines the BabylonJS internal texture
  103820. * @param createPolynomials will be true if polynomials have been requested
  103821. * @param onLoad defines the callback to trigger once the texture is ready
  103822. * @param onError defines the callback to trigger in case of error
  103823. */
  103824. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103825. /**
  103826. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103827. * @param data contains the texture data
  103828. * @param texture defines the BabylonJS internal texture
  103829. * @param callback defines the method to call once ready to upload
  103830. */
  103831. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  103832. }
  103833. }
  103834. declare module BABYLON {
  103835. /** @hidden */
  103836. export var _forceSceneHelpersToBundle: boolean;
  103837. interface Scene {
  103838. /**
  103839. * Creates a default light for the scene.
  103840. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  103841. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  103842. */
  103843. createDefaultLight(replace?: boolean): void;
  103844. /**
  103845. * Creates a default camera for the scene.
  103846. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  103847. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103848. * @param replace has default false, when true replaces the active camera in the scene
  103849. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  103850. */
  103851. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103852. /**
  103853. * Creates a default camera and a default light.
  103854. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  103855. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103856. * @param replace has the default false, when true replaces the active camera/light in the scene
  103857. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  103858. */
  103859. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103860. /**
  103861. * Creates a new sky box
  103862. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  103863. * @param environmentTexture defines the texture to use as environment texture
  103864. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  103865. * @param scale defines the overall scale of the skybox
  103866. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  103867. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  103868. * @returns a new mesh holding the sky box
  103869. */
  103870. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  103871. /**
  103872. * Creates a new environment
  103873. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  103874. * @param options defines the options you can use to configure the environment
  103875. * @returns the new EnvironmentHelper
  103876. */
  103877. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  103878. /**
  103879. * Creates a new VREXperienceHelper
  103880. * @see http://doc.babylonjs.com/how_to/webvr_helper
  103881. * @param webVROptions defines the options used to create the new VREXperienceHelper
  103882. * @returns a new VREXperienceHelper
  103883. */
  103884. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  103885. /**
  103886. * Creates a new XREXperienceHelper
  103887. * @see http://doc.babylonjs.com/how_to/webxr
  103888. * @returns a promise for a new XREXperienceHelper
  103889. */
  103890. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  103891. }
  103892. }
  103893. declare module BABYLON {
  103894. /**
  103895. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  103896. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  103897. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  103898. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103899. */
  103900. export class VideoDome extends TransformNode {
  103901. /**
  103902. * Define the video source as a Monoscopic panoramic 360 video.
  103903. */
  103904. static readonly MODE_MONOSCOPIC: number;
  103905. /**
  103906. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103907. */
  103908. static readonly MODE_TOPBOTTOM: number;
  103909. /**
  103910. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103911. */
  103912. static readonly MODE_SIDEBYSIDE: number;
  103913. private _useDirectMapping;
  103914. /**
  103915. * The video texture being displayed on the sphere
  103916. */
  103917. protected _videoTexture: VideoTexture;
  103918. /**
  103919. * Gets the video texture being displayed on the sphere
  103920. */
  103921. readonly videoTexture: VideoTexture;
  103922. /**
  103923. * The skybox material
  103924. */
  103925. protected _material: BackgroundMaterial;
  103926. /**
  103927. * The surface used for the skybox
  103928. */
  103929. protected _mesh: Mesh;
  103930. /**
  103931. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103932. * Also see the options.resolution property.
  103933. */
  103934. fovMultiplier: number;
  103935. private _videoMode;
  103936. /**
  103937. * Gets or set the current video mode for the video. It can be:
  103938. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  103939. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103940. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103941. */
  103942. videoMode: number;
  103943. /**
  103944. * Oberserver used in Stereoscopic VR Mode.
  103945. */
  103946. private _onBeforeCameraRenderObserver;
  103947. /**
  103948. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  103949. * @param name Element's name, child elements will append suffixes for their own names.
  103950. * @param urlsOrVideo defines the url(s) or the video element to use
  103951. * @param options An object containing optional or exposed sub element properties
  103952. */
  103953. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  103954. resolution?: number;
  103955. clickToPlay?: boolean;
  103956. autoPlay?: boolean;
  103957. loop?: boolean;
  103958. size?: number;
  103959. poster?: string;
  103960. faceForward?: boolean;
  103961. useDirectMapping?: boolean;
  103962. }, scene: Scene);
  103963. private _changeVideoMode;
  103964. /**
  103965. * Releases resources associated with this node.
  103966. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103967. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103968. */
  103969. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103970. }
  103971. }
  103972. declare module BABYLON {
  103973. /**
  103974. * This class can be used to get instrumentation data from a Babylon engine
  103975. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103976. */
  103977. export class EngineInstrumentation implements IDisposable {
  103978. /**
  103979. * Define the instrumented engine.
  103980. */
  103981. engine: Engine;
  103982. private _captureGPUFrameTime;
  103983. private _gpuFrameTimeToken;
  103984. private _gpuFrameTime;
  103985. private _captureShaderCompilationTime;
  103986. private _shaderCompilationTime;
  103987. private _onBeginFrameObserver;
  103988. private _onEndFrameObserver;
  103989. private _onBeforeShaderCompilationObserver;
  103990. private _onAfterShaderCompilationObserver;
  103991. /**
  103992. * Gets the perf counter used for GPU frame time
  103993. */
  103994. readonly gpuFrameTimeCounter: PerfCounter;
  103995. /**
  103996. * Gets the GPU frame time capture status
  103997. */
  103998. /**
  103999. * Enable or disable the GPU frame time capture
  104000. */
  104001. captureGPUFrameTime: boolean;
  104002. /**
  104003. * Gets the perf counter used for shader compilation time
  104004. */
  104005. readonly shaderCompilationTimeCounter: PerfCounter;
  104006. /**
  104007. * Gets the shader compilation time capture status
  104008. */
  104009. /**
  104010. * Enable or disable the shader compilation time capture
  104011. */
  104012. captureShaderCompilationTime: boolean;
  104013. /**
  104014. * Instantiates a new engine instrumentation.
  104015. * This class can be used to get instrumentation data from a Babylon engine
  104016. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  104017. * @param engine Defines the engine to instrument
  104018. */
  104019. constructor(
  104020. /**
  104021. * Define the instrumented engine.
  104022. */
  104023. engine: Engine);
  104024. /**
  104025. * Dispose and release associated resources.
  104026. */
  104027. dispose(): void;
  104028. }
  104029. }
  104030. declare module BABYLON {
  104031. /**
  104032. * This class can be used to get instrumentation data from a Babylon engine
  104033. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  104034. */
  104035. export class SceneInstrumentation implements IDisposable {
  104036. /**
  104037. * Defines the scene to instrument
  104038. */
  104039. scene: Scene;
  104040. private _captureActiveMeshesEvaluationTime;
  104041. private _activeMeshesEvaluationTime;
  104042. private _captureRenderTargetsRenderTime;
  104043. private _renderTargetsRenderTime;
  104044. private _captureFrameTime;
  104045. private _frameTime;
  104046. private _captureRenderTime;
  104047. private _renderTime;
  104048. private _captureInterFrameTime;
  104049. private _interFrameTime;
  104050. private _captureParticlesRenderTime;
  104051. private _particlesRenderTime;
  104052. private _captureSpritesRenderTime;
  104053. private _spritesRenderTime;
  104054. private _capturePhysicsTime;
  104055. private _physicsTime;
  104056. private _captureAnimationsTime;
  104057. private _animationsTime;
  104058. private _captureCameraRenderTime;
  104059. private _cameraRenderTime;
  104060. private _onBeforeActiveMeshesEvaluationObserver;
  104061. private _onAfterActiveMeshesEvaluationObserver;
  104062. private _onBeforeRenderTargetsRenderObserver;
  104063. private _onAfterRenderTargetsRenderObserver;
  104064. private _onAfterRenderObserver;
  104065. private _onBeforeDrawPhaseObserver;
  104066. private _onAfterDrawPhaseObserver;
  104067. private _onBeforeAnimationsObserver;
  104068. private _onBeforeParticlesRenderingObserver;
  104069. private _onAfterParticlesRenderingObserver;
  104070. private _onBeforeSpritesRenderingObserver;
  104071. private _onAfterSpritesRenderingObserver;
  104072. private _onBeforePhysicsObserver;
  104073. private _onAfterPhysicsObserver;
  104074. private _onAfterAnimationsObserver;
  104075. private _onBeforeCameraRenderObserver;
  104076. private _onAfterCameraRenderObserver;
  104077. /**
  104078. * Gets the perf counter used for active meshes evaluation time
  104079. */
  104080. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  104081. /**
  104082. * Gets the active meshes evaluation time capture status
  104083. */
  104084. /**
  104085. * Enable or disable the active meshes evaluation time capture
  104086. */
  104087. captureActiveMeshesEvaluationTime: boolean;
  104088. /**
  104089. * Gets the perf counter used for render targets render time
  104090. */
  104091. readonly renderTargetsRenderTimeCounter: PerfCounter;
  104092. /**
  104093. * Gets the render targets render time capture status
  104094. */
  104095. /**
  104096. * Enable or disable the render targets render time capture
  104097. */
  104098. captureRenderTargetsRenderTime: boolean;
  104099. /**
  104100. * Gets the perf counter used for particles render time
  104101. */
  104102. readonly particlesRenderTimeCounter: PerfCounter;
  104103. /**
  104104. * Gets the particles render time capture status
  104105. */
  104106. /**
  104107. * Enable or disable the particles render time capture
  104108. */
  104109. captureParticlesRenderTime: boolean;
  104110. /**
  104111. * Gets the perf counter used for sprites render time
  104112. */
  104113. readonly spritesRenderTimeCounter: PerfCounter;
  104114. /**
  104115. * Gets the sprites render time capture status
  104116. */
  104117. /**
  104118. * Enable or disable the sprites render time capture
  104119. */
  104120. captureSpritesRenderTime: boolean;
  104121. /**
  104122. * Gets the perf counter used for physics time
  104123. */
  104124. readonly physicsTimeCounter: PerfCounter;
  104125. /**
  104126. * Gets the physics time capture status
  104127. */
  104128. /**
  104129. * Enable or disable the physics time capture
  104130. */
  104131. capturePhysicsTime: boolean;
  104132. /**
  104133. * Gets the perf counter used for animations time
  104134. */
  104135. readonly animationsTimeCounter: PerfCounter;
  104136. /**
  104137. * Gets the animations time capture status
  104138. */
  104139. /**
  104140. * Enable or disable the animations time capture
  104141. */
  104142. captureAnimationsTime: boolean;
  104143. /**
  104144. * Gets the perf counter used for frame time capture
  104145. */
  104146. readonly frameTimeCounter: PerfCounter;
  104147. /**
  104148. * Gets the frame time capture status
  104149. */
  104150. /**
  104151. * Enable or disable the frame time capture
  104152. */
  104153. captureFrameTime: boolean;
  104154. /**
  104155. * Gets the perf counter used for inter-frames time capture
  104156. */
  104157. readonly interFrameTimeCounter: PerfCounter;
  104158. /**
  104159. * Gets the inter-frames time capture status
  104160. */
  104161. /**
  104162. * Enable or disable the inter-frames time capture
  104163. */
  104164. captureInterFrameTime: boolean;
  104165. /**
  104166. * Gets the perf counter used for render time capture
  104167. */
  104168. readonly renderTimeCounter: PerfCounter;
  104169. /**
  104170. * Gets the render time capture status
  104171. */
  104172. /**
  104173. * Enable or disable the render time capture
  104174. */
  104175. captureRenderTime: boolean;
  104176. /**
  104177. * Gets the perf counter used for camera render time capture
  104178. */
  104179. readonly cameraRenderTimeCounter: PerfCounter;
  104180. /**
  104181. * Gets the camera render time capture status
  104182. */
  104183. /**
  104184. * Enable or disable the camera render time capture
  104185. */
  104186. captureCameraRenderTime: boolean;
  104187. /**
  104188. * Gets the perf counter used for draw calls
  104189. */
  104190. readonly drawCallsCounter: PerfCounter;
  104191. /**
  104192. * Gets the perf counter used for texture collisions
  104193. */
  104194. readonly textureCollisionsCounter: PerfCounter;
  104195. /**
  104196. * Instantiates a new scene instrumentation.
  104197. * This class can be used to get instrumentation data from a Babylon engine
  104198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  104199. * @param scene Defines the scene to instrument
  104200. */
  104201. constructor(
  104202. /**
  104203. * Defines the scene to instrument
  104204. */
  104205. scene: Scene);
  104206. /**
  104207. * Dispose and release associated resources.
  104208. */
  104209. dispose(): void;
  104210. }
  104211. }
  104212. declare module BABYLON {
  104213. /** @hidden */
  104214. export var glowMapGenerationPixelShader: {
  104215. name: string;
  104216. shader: string;
  104217. };
  104218. }
  104219. declare module BABYLON {
  104220. /** @hidden */
  104221. export var glowMapGenerationVertexShader: {
  104222. name: string;
  104223. shader: string;
  104224. };
  104225. }
  104226. declare module BABYLON {
  104227. /**
  104228. * Effect layer options. This helps customizing the behaviour
  104229. * of the effect layer.
  104230. */
  104231. export interface IEffectLayerOptions {
  104232. /**
  104233. * Multiplication factor apply to the canvas size to compute the render target size
  104234. * used to generated the objects (the smaller the faster).
  104235. */
  104236. mainTextureRatio: number;
  104237. /**
  104238. * Enforces a fixed size texture to ensure effect stability across devices.
  104239. */
  104240. mainTextureFixedSize?: number;
  104241. /**
  104242. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  104243. */
  104244. alphaBlendingMode: number;
  104245. /**
  104246. * The camera attached to the layer.
  104247. */
  104248. camera: Nullable<Camera>;
  104249. /**
  104250. * The rendering group to draw the layer in.
  104251. */
  104252. renderingGroupId: number;
  104253. }
  104254. /**
  104255. * The effect layer Helps adding post process effect blended with the main pass.
  104256. *
  104257. * This can be for instance use to generate glow or higlight effects on the scene.
  104258. *
  104259. * The effect layer class can not be used directly and is intented to inherited from to be
  104260. * customized per effects.
  104261. */
  104262. export abstract class EffectLayer {
  104263. private _vertexBuffers;
  104264. private _indexBuffer;
  104265. private _cachedDefines;
  104266. private _effectLayerMapGenerationEffect;
  104267. private _effectLayerOptions;
  104268. private _mergeEffect;
  104269. protected _scene: Scene;
  104270. protected _engine: Engine;
  104271. protected _maxSize: number;
  104272. protected _mainTextureDesiredSize: ISize;
  104273. protected _mainTexture: RenderTargetTexture;
  104274. protected _shouldRender: boolean;
  104275. protected _postProcesses: PostProcess[];
  104276. protected _textures: BaseTexture[];
  104277. protected _emissiveTextureAndColor: {
  104278. texture: Nullable<BaseTexture>;
  104279. color: Color4;
  104280. };
  104281. /**
  104282. * The name of the layer
  104283. */
  104284. name: string;
  104285. /**
  104286. * The clear color of the texture used to generate the glow map.
  104287. */
  104288. neutralColor: Color4;
  104289. /**
  104290. * Specifies wether the highlight layer is enabled or not.
  104291. */
  104292. isEnabled: boolean;
  104293. /**
  104294. * Gets the camera attached to the layer.
  104295. */
  104296. readonly camera: Nullable<Camera>;
  104297. /**
  104298. * Gets the rendering group id the layer should render in.
  104299. */
  104300. readonly renderingGroupId: number;
  104301. /**
  104302. * An event triggered when the effect layer has been disposed.
  104303. */
  104304. onDisposeObservable: Observable<EffectLayer>;
  104305. /**
  104306. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  104307. */
  104308. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  104309. /**
  104310. * An event triggered when the generated texture is being merged in the scene.
  104311. */
  104312. onBeforeComposeObservable: Observable<EffectLayer>;
  104313. /**
  104314. * An event triggered when the generated texture has been merged in the scene.
  104315. */
  104316. onAfterComposeObservable: Observable<EffectLayer>;
  104317. /**
  104318. * An event triggered when the efffect layer changes its size.
  104319. */
  104320. onSizeChangedObservable: Observable<EffectLayer>;
  104321. /** @hidden */
  104322. static _SceneComponentInitialization: (scene: Scene) => void;
  104323. /**
  104324. * Instantiates a new effect Layer and references it in the scene.
  104325. * @param name The name of the layer
  104326. * @param scene The scene to use the layer in
  104327. */
  104328. constructor(
  104329. /** The Friendly of the effect in the scene */
  104330. name: string, scene: Scene);
  104331. /**
  104332. * Get the effect name of the layer.
  104333. * @return The effect name
  104334. */
  104335. abstract getEffectName(): string;
  104336. /**
  104337. * Checks for the readiness of the element composing the layer.
  104338. * @param subMesh the mesh to check for
  104339. * @param useInstances specify wether or not to use instances to render the mesh
  104340. * @return true if ready otherwise, false
  104341. */
  104342. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104343. /**
  104344. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104345. * @returns true if the effect requires stencil during the main canvas render pass.
  104346. */
  104347. abstract needStencil(): boolean;
  104348. /**
  104349. * Create the merge effect. This is the shader use to blit the information back
  104350. * to the main canvas at the end of the scene rendering.
  104351. * @returns The effect containing the shader used to merge the effect on the main canvas
  104352. */
  104353. protected abstract _createMergeEffect(): Effect;
  104354. /**
  104355. * Creates the render target textures and post processes used in the effect layer.
  104356. */
  104357. protected abstract _createTextureAndPostProcesses(): void;
  104358. /**
  104359. * Implementation specific of rendering the generating effect on the main canvas.
  104360. * @param effect The effect used to render through
  104361. */
  104362. protected abstract _internalRender(effect: Effect): void;
  104363. /**
  104364. * Sets the required values for both the emissive texture and and the main color.
  104365. */
  104366. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104367. /**
  104368. * Free any resources and references associated to a mesh.
  104369. * Internal use
  104370. * @param mesh The mesh to free.
  104371. */
  104372. abstract _disposeMesh(mesh: Mesh): void;
  104373. /**
  104374. * Serializes this layer (Glow or Highlight for example)
  104375. * @returns a serialized layer object
  104376. */
  104377. abstract serialize?(): any;
  104378. /**
  104379. * Initializes the effect layer with the required options.
  104380. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  104381. */
  104382. protected _init(options: Partial<IEffectLayerOptions>): void;
  104383. /**
  104384. * Generates the index buffer of the full screen quad blending to the main canvas.
  104385. */
  104386. private _generateIndexBuffer;
  104387. /**
  104388. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  104389. */
  104390. private _genrateVertexBuffer;
  104391. /**
  104392. * Sets the main texture desired size which is the closest power of two
  104393. * of the engine canvas size.
  104394. */
  104395. private _setMainTextureSize;
  104396. /**
  104397. * Creates the main texture for the effect layer.
  104398. */
  104399. protected _createMainTexture(): void;
  104400. /**
  104401. * Adds specific effects defines.
  104402. * @param defines The defines to add specifics to.
  104403. */
  104404. protected _addCustomEffectDefines(defines: string[]): void;
  104405. /**
  104406. * Checks for the readiness of the element composing the layer.
  104407. * @param subMesh the mesh to check for
  104408. * @param useInstances specify wether or not to use instances to render the mesh
  104409. * @param emissiveTexture the associated emissive texture used to generate the glow
  104410. * @return true if ready otherwise, false
  104411. */
  104412. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  104413. /**
  104414. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  104415. */
  104416. render(): void;
  104417. /**
  104418. * Determine if a given mesh will be used in the current effect.
  104419. * @param mesh mesh to test
  104420. * @returns true if the mesh will be used
  104421. */
  104422. hasMesh(mesh: AbstractMesh): boolean;
  104423. /**
  104424. * Returns true if the layer contains information to display, otherwise false.
  104425. * @returns true if the glow layer should be rendered
  104426. */
  104427. shouldRender(): boolean;
  104428. /**
  104429. * Returns true if the mesh should render, otherwise false.
  104430. * @param mesh The mesh to render
  104431. * @returns true if it should render otherwise false
  104432. */
  104433. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  104434. /**
  104435. * Returns true if the mesh can be rendered, otherwise false.
  104436. * @param mesh The mesh to render
  104437. * @param material The material used on the mesh
  104438. * @returns true if it can be rendered otherwise false
  104439. */
  104440. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104441. /**
  104442. * Returns true if the mesh should render, otherwise false.
  104443. * @param mesh The mesh to render
  104444. * @returns true if it should render otherwise false
  104445. */
  104446. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  104447. /**
  104448. * Renders the submesh passed in parameter to the generation map.
  104449. */
  104450. protected _renderSubMesh(subMesh: SubMesh): void;
  104451. /**
  104452. * Rebuild the required buffers.
  104453. * @hidden Internal use only.
  104454. */
  104455. _rebuild(): void;
  104456. /**
  104457. * Dispose only the render target textures and post process.
  104458. */
  104459. private _disposeTextureAndPostProcesses;
  104460. /**
  104461. * Dispose the highlight layer and free resources.
  104462. */
  104463. dispose(): void;
  104464. /**
  104465. * Gets the class name of the effect layer
  104466. * @returns the string with the class name of the effect layer
  104467. */
  104468. getClassName(): string;
  104469. /**
  104470. * Creates an effect layer from parsed effect layer data
  104471. * @param parsedEffectLayer defines effect layer data
  104472. * @param scene defines the current scene
  104473. * @param rootUrl defines the root URL containing the effect layer information
  104474. * @returns a parsed effect Layer
  104475. */
  104476. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  104477. }
  104478. }
  104479. declare module BABYLON {
  104480. interface AbstractScene {
  104481. /**
  104482. * The list of effect layers (highlights/glow) added to the scene
  104483. * @see http://doc.babylonjs.com/how_to/highlight_layer
  104484. * @see http://doc.babylonjs.com/how_to/glow_layer
  104485. */
  104486. effectLayers: Array<EffectLayer>;
  104487. /**
  104488. * Removes the given effect layer from this scene.
  104489. * @param toRemove defines the effect layer to remove
  104490. * @returns the index of the removed effect layer
  104491. */
  104492. removeEffectLayer(toRemove: EffectLayer): number;
  104493. /**
  104494. * Adds the given effect layer to this scene
  104495. * @param newEffectLayer defines the effect layer to add
  104496. */
  104497. addEffectLayer(newEffectLayer: EffectLayer): void;
  104498. }
  104499. /**
  104500. * Defines the layer scene component responsible to manage any effect layers
  104501. * in a given scene.
  104502. */
  104503. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  104504. /**
  104505. * The component name helpfull to identify the component in the list of scene components.
  104506. */
  104507. readonly name: string;
  104508. /**
  104509. * The scene the component belongs to.
  104510. */
  104511. scene: Scene;
  104512. private _engine;
  104513. private _renderEffects;
  104514. private _needStencil;
  104515. private _previousStencilState;
  104516. /**
  104517. * Creates a new instance of the component for the given scene
  104518. * @param scene Defines the scene to register the component in
  104519. */
  104520. constructor(scene: Scene);
  104521. /**
  104522. * Registers the component in a given scene
  104523. */
  104524. register(): void;
  104525. /**
  104526. * Rebuilds the elements related to this component in case of
  104527. * context lost for instance.
  104528. */
  104529. rebuild(): void;
  104530. /**
  104531. * Serializes the component data to the specified json object
  104532. * @param serializationObject The object to serialize to
  104533. */
  104534. serialize(serializationObject: any): void;
  104535. /**
  104536. * Adds all the element from the container to the scene
  104537. * @param container the container holding the elements
  104538. */
  104539. addFromContainer(container: AbstractScene): void;
  104540. /**
  104541. * Removes all the elements in the container from the scene
  104542. * @param container contains the elements to remove
  104543. * @param dispose if the removed element should be disposed (default: false)
  104544. */
  104545. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104546. /**
  104547. * Disposes the component and the associated ressources.
  104548. */
  104549. dispose(): void;
  104550. private _isReadyForMesh;
  104551. private _renderMainTexture;
  104552. private _setStencil;
  104553. private _setStencilBack;
  104554. private _draw;
  104555. private _drawCamera;
  104556. private _drawRenderingGroup;
  104557. }
  104558. }
  104559. declare module BABYLON {
  104560. /** @hidden */
  104561. export var glowMapMergePixelShader: {
  104562. name: string;
  104563. shader: string;
  104564. };
  104565. }
  104566. declare module BABYLON {
  104567. /** @hidden */
  104568. export var glowMapMergeVertexShader: {
  104569. name: string;
  104570. shader: string;
  104571. };
  104572. }
  104573. declare module BABYLON {
  104574. interface AbstractScene {
  104575. /**
  104576. * Return a the first highlight layer of the scene with a given name.
  104577. * @param name The name of the highlight layer to look for.
  104578. * @return The highlight layer if found otherwise null.
  104579. */
  104580. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  104581. }
  104582. /**
  104583. * Glow layer options. This helps customizing the behaviour
  104584. * of the glow layer.
  104585. */
  104586. export interface IGlowLayerOptions {
  104587. /**
  104588. * Multiplication factor apply to the canvas size to compute the render target size
  104589. * used to generated the glowing objects (the smaller the faster).
  104590. */
  104591. mainTextureRatio: number;
  104592. /**
  104593. * Enforces a fixed size texture to ensure resize independant blur.
  104594. */
  104595. mainTextureFixedSize?: number;
  104596. /**
  104597. * How big is the kernel of the blur texture.
  104598. */
  104599. blurKernelSize: number;
  104600. /**
  104601. * The camera attached to the layer.
  104602. */
  104603. camera: Nullable<Camera>;
  104604. /**
  104605. * Enable MSAA by chosing the number of samples.
  104606. */
  104607. mainTextureSamples?: number;
  104608. /**
  104609. * The rendering group to draw the layer in.
  104610. */
  104611. renderingGroupId: number;
  104612. }
  104613. /**
  104614. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  104615. *
  104616. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104617. * glowy meshes to your scene.
  104618. *
  104619. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  104620. */
  104621. export class GlowLayer extends EffectLayer {
  104622. /**
  104623. * Effect Name of the layer.
  104624. */
  104625. static readonly EffectName: string;
  104626. /**
  104627. * The default blur kernel size used for the glow.
  104628. */
  104629. static DefaultBlurKernelSize: number;
  104630. /**
  104631. * The default texture size ratio used for the glow.
  104632. */
  104633. static DefaultTextureRatio: number;
  104634. /**
  104635. * Sets the kernel size of the blur.
  104636. */
  104637. /**
  104638. * Gets the kernel size of the blur.
  104639. */
  104640. blurKernelSize: number;
  104641. /**
  104642. * Sets the glow intensity.
  104643. */
  104644. /**
  104645. * Gets the glow intensity.
  104646. */
  104647. intensity: number;
  104648. private _options;
  104649. private _intensity;
  104650. private _horizontalBlurPostprocess1;
  104651. private _verticalBlurPostprocess1;
  104652. private _horizontalBlurPostprocess2;
  104653. private _verticalBlurPostprocess2;
  104654. private _blurTexture1;
  104655. private _blurTexture2;
  104656. private _postProcesses1;
  104657. private _postProcesses2;
  104658. private _includedOnlyMeshes;
  104659. private _excludedMeshes;
  104660. /**
  104661. * Callback used to let the user override the color selection on a per mesh basis
  104662. */
  104663. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  104664. /**
  104665. * Callback used to let the user override the texture selection on a per mesh basis
  104666. */
  104667. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  104668. /**
  104669. * Instantiates a new glow Layer and references it to the scene.
  104670. * @param name The name of the layer
  104671. * @param scene The scene to use the layer in
  104672. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  104673. */
  104674. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  104675. /**
  104676. * Get the effect name of the layer.
  104677. * @return The effect name
  104678. */
  104679. getEffectName(): string;
  104680. /**
  104681. * Create the merge effect. This is the shader use to blit the information back
  104682. * to the main canvas at the end of the scene rendering.
  104683. */
  104684. protected _createMergeEffect(): Effect;
  104685. /**
  104686. * Creates the render target textures and post processes used in the glow layer.
  104687. */
  104688. protected _createTextureAndPostProcesses(): void;
  104689. /**
  104690. * Checks for the readiness of the element composing the layer.
  104691. * @param subMesh the mesh to check for
  104692. * @param useInstances specify wether or not to use instances to render the mesh
  104693. * @param emissiveTexture the associated emissive texture used to generate the glow
  104694. * @return true if ready otherwise, false
  104695. */
  104696. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104697. /**
  104698. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104699. */
  104700. needStencil(): boolean;
  104701. /**
  104702. * Returns true if the mesh can be rendered, otherwise false.
  104703. * @param mesh The mesh to render
  104704. * @param material The material used on the mesh
  104705. * @returns true if it can be rendered otherwise false
  104706. */
  104707. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104708. /**
  104709. * Implementation specific of rendering the generating effect on the main canvas.
  104710. * @param effect The effect used to render through
  104711. */
  104712. protected _internalRender(effect: Effect): void;
  104713. /**
  104714. * Sets the required values for both the emissive texture and and the main color.
  104715. */
  104716. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104717. /**
  104718. * Returns true if the mesh should render, otherwise false.
  104719. * @param mesh The mesh to render
  104720. * @returns true if it should render otherwise false
  104721. */
  104722. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104723. /**
  104724. * Adds specific effects defines.
  104725. * @param defines The defines to add specifics to.
  104726. */
  104727. protected _addCustomEffectDefines(defines: string[]): void;
  104728. /**
  104729. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  104730. * @param mesh The mesh to exclude from the glow layer
  104731. */
  104732. addExcludedMesh(mesh: Mesh): void;
  104733. /**
  104734. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  104735. * @param mesh The mesh to remove
  104736. */
  104737. removeExcludedMesh(mesh: Mesh): void;
  104738. /**
  104739. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  104740. * @param mesh The mesh to include in the glow layer
  104741. */
  104742. addIncludedOnlyMesh(mesh: Mesh): void;
  104743. /**
  104744. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  104745. * @param mesh The mesh to remove
  104746. */
  104747. removeIncludedOnlyMesh(mesh: Mesh): void;
  104748. /**
  104749. * Determine if a given mesh will be used in the glow layer
  104750. * @param mesh The mesh to test
  104751. * @returns true if the mesh will be highlighted by the current glow layer
  104752. */
  104753. hasMesh(mesh: AbstractMesh): boolean;
  104754. /**
  104755. * Free any resources and references associated to a mesh.
  104756. * Internal use
  104757. * @param mesh The mesh to free.
  104758. * @hidden
  104759. */
  104760. _disposeMesh(mesh: Mesh): void;
  104761. /**
  104762. * Gets the class name of the effect layer
  104763. * @returns the string with the class name of the effect layer
  104764. */
  104765. getClassName(): string;
  104766. /**
  104767. * Serializes this glow layer
  104768. * @returns a serialized glow layer object
  104769. */
  104770. serialize(): any;
  104771. /**
  104772. * Creates a Glow Layer from parsed glow layer data
  104773. * @param parsedGlowLayer defines glow layer data
  104774. * @param scene defines the current scene
  104775. * @param rootUrl defines the root URL containing the glow layer information
  104776. * @returns a parsed Glow Layer
  104777. */
  104778. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  104779. }
  104780. }
  104781. declare module BABYLON {
  104782. /** @hidden */
  104783. export var glowBlurPostProcessPixelShader: {
  104784. name: string;
  104785. shader: string;
  104786. };
  104787. }
  104788. declare module BABYLON {
  104789. interface AbstractScene {
  104790. /**
  104791. * Return a the first highlight layer of the scene with a given name.
  104792. * @param name The name of the highlight layer to look for.
  104793. * @return The highlight layer if found otherwise null.
  104794. */
  104795. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  104796. }
  104797. /**
  104798. * Highlight layer options. This helps customizing the behaviour
  104799. * of the highlight layer.
  104800. */
  104801. export interface IHighlightLayerOptions {
  104802. /**
  104803. * Multiplication factor apply to the canvas size to compute the render target size
  104804. * used to generated the glowing objects (the smaller the faster).
  104805. */
  104806. mainTextureRatio: number;
  104807. /**
  104808. * Enforces a fixed size texture to ensure resize independant blur.
  104809. */
  104810. mainTextureFixedSize?: number;
  104811. /**
  104812. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  104813. * of the picture to blur (the smaller the faster).
  104814. */
  104815. blurTextureSizeRatio: number;
  104816. /**
  104817. * How big in texel of the blur texture is the vertical blur.
  104818. */
  104819. blurVerticalSize: number;
  104820. /**
  104821. * How big in texel of the blur texture is the horizontal blur.
  104822. */
  104823. blurHorizontalSize: number;
  104824. /**
  104825. * Alpha blending mode used to apply the blur. Default is combine.
  104826. */
  104827. alphaBlendingMode: number;
  104828. /**
  104829. * The camera attached to the layer.
  104830. */
  104831. camera: Nullable<Camera>;
  104832. /**
  104833. * Should we display highlight as a solid stroke?
  104834. */
  104835. isStroke?: boolean;
  104836. /**
  104837. * The rendering group to draw the layer in.
  104838. */
  104839. renderingGroupId: number;
  104840. }
  104841. /**
  104842. * The highlight layer Helps adding a glow effect around a mesh.
  104843. *
  104844. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104845. * glowy meshes to your scene.
  104846. *
  104847. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  104848. */
  104849. export class HighlightLayer extends EffectLayer {
  104850. name: string;
  104851. /**
  104852. * Effect Name of the highlight layer.
  104853. */
  104854. static readonly EffectName: string;
  104855. /**
  104856. * The neutral color used during the preparation of the glow effect.
  104857. * This is black by default as the blend operation is a blend operation.
  104858. */
  104859. static NeutralColor: Color4;
  104860. /**
  104861. * Stencil value used for glowing meshes.
  104862. */
  104863. static GlowingMeshStencilReference: number;
  104864. /**
  104865. * Stencil value used for the other meshes in the scene.
  104866. */
  104867. static NormalMeshStencilReference: number;
  104868. /**
  104869. * Specifies whether or not the inner glow is ACTIVE in the layer.
  104870. */
  104871. innerGlow: boolean;
  104872. /**
  104873. * Specifies whether or not the outer glow is ACTIVE in the layer.
  104874. */
  104875. outerGlow: boolean;
  104876. /**
  104877. * Specifies the horizontal size of the blur.
  104878. */
  104879. /**
  104880. * Gets the horizontal size of the blur.
  104881. */
  104882. blurHorizontalSize: number;
  104883. /**
  104884. * Specifies the vertical size of the blur.
  104885. */
  104886. /**
  104887. * Gets the vertical size of the blur.
  104888. */
  104889. blurVerticalSize: number;
  104890. /**
  104891. * An event triggered when the highlight layer is being blurred.
  104892. */
  104893. onBeforeBlurObservable: Observable<HighlightLayer>;
  104894. /**
  104895. * An event triggered when the highlight layer has been blurred.
  104896. */
  104897. onAfterBlurObservable: Observable<HighlightLayer>;
  104898. private _instanceGlowingMeshStencilReference;
  104899. private _options;
  104900. private _downSamplePostprocess;
  104901. private _horizontalBlurPostprocess;
  104902. private _verticalBlurPostprocess;
  104903. private _blurTexture;
  104904. private _meshes;
  104905. private _excludedMeshes;
  104906. /**
  104907. * Instantiates a new highlight Layer and references it to the scene..
  104908. * @param name The name of the layer
  104909. * @param scene The scene to use the layer in
  104910. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  104911. */
  104912. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  104913. /**
  104914. * Get the effect name of the layer.
  104915. * @return The effect name
  104916. */
  104917. getEffectName(): string;
  104918. /**
  104919. * Create the merge effect. This is the shader use to blit the information back
  104920. * to the main canvas at the end of the scene rendering.
  104921. */
  104922. protected _createMergeEffect(): Effect;
  104923. /**
  104924. * Creates the render target textures and post processes used in the highlight layer.
  104925. */
  104926. protected _createTextureAndPostProcesses(): void;
  104927. /**
  104928. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104929. */
  104930. needStencil(): boolean;
  104931. /**
  104932. * Checks for the readiness of the element composing the layer.
  104933. * @param subMesh the mesh to check for
  104934. * @param useInstances specify wether or not to use instances to render the mesh
  104935. * @param emissiveTexture the associated emissive texture used to generate the glow
  104936. * @return true if ready otherwise, false
  104937. */
  104938. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104939. /**
  104940. * Implementation specific of rendering the generating effect on the main canvas.
  104941. * @param effect The effect used to render through
  104942. */
  104943. protected _internalRender(effect: Effect): void;
  104944. /**
  104945. * Returns true if the layer contains information to display, otherwise false.
  104946. */
  104947. shouldRender(): boolean;
  104948. /**
  104949. * Returns true if the mesh should render, otherwise false.
  104950. * @param mesh The mesh to render
  104951. * @returns true if it should render otherwise false
  104952. */
  104953. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104954. /**
  104955. * Sets the required values for both the emissive texture and and the main color.
  104956. */
  104957. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104958. /**
  104959. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  104960. * @param mesh The mesh to exclude from the highlight layer
  104961. */
  104962. addExcludedMesh(mesh: Mesh): void;
  104963. /**
  104964. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  104965. * @param mesh The mesh to highlight
  104966. */
  104967. removeExcludedMesh(mesh: Mesh): void;
  104968. /**
  104969. * Determine if a given mesh will be highlighted by the current HighlightLayer
  104970. * @param mesh mesh to test
  104971. * @returns true if the mesh will be highlighted by the current HighlightLayer
  104972. */
  104973. hasMesh(mesh: AbstractMesh): boolean;
  104974. /**
  104975. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  104976. * @param mesh The mesh to highlight
  104977. * @param color The color of the highlight
  104978. * @param glowEmissiveOnly Extract the glow from the emissive texture
  104979. */
  104980. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  104981. /**
  104982. * Remove a mesh from the highlight layer in order to make it stop glowing.
  104983. * @param mesh The mesh to highlight
  104984. */
  104985. removeMesh(mesh: Mesh): void;
  104986. /**
  104987. * Force the stencil to the normal expected value for none glowing parts
  104988. */
  104989. private _defaultStencilReference;
  104990. /**
  104991. * Free any resources and references associated to a mesh.
  104992. * Internal use
  104993. * @param mesh The mesh to free.
  104994. * @hidden
  104995. */
  104996. _disposeMesh(mesh: Mesh): void;
  104997. /**
  104998. * Dispose the highlight layer and free resources.
  104999. */
  105000. dispose(): void;
  105001. /**
  105002. * Gets the class name of the effect layer
  105003. * @returns the string with the class name of the effect layer
  105004. */
  105005. getClassName(): string;
  105006. /**
  105007. * Serializes this Highlight layer
  105008. * @returns a serialized Highlight layer object
  105009. */
  105010. serialize(): any;
  105011. /**
  105012. * Creates a Highlight layer from parsed Highlight layer data
  105013. * @param parsedHightlightLayer defines the Highlight layer data
  105014. * @param scene defines the current scene
  105015. * @param rootUrl defines the root URL containing the Highlight layer information
  105016. * @returns a parsed Highlight layer
  105017. */
  105018. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  105019. }
  105020. }
  105021. declare module BABYLON {
  105022. /** @hidden */
  105023. export var lensFlarePixelShader: {
  105024. name: string;
  105025. shader: string;
  105026. };
  105027. }
  105028. declare module BABYLON {
  105029. /** @hidden */
  105030. export var lensFlareVertexShader: {
  105031. name: string;
  105032. shader: string;
  105033. };
  105034. }
  105035. declare module BABYLON {
  105036. /**
  105037. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  105038. * It is usually composed of several `lensFlare`.
  105039. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105040. */
  105041. export class LensFlareSystem {
  105042. /**
  105043. * Define the name of the lens flare system
  105044. */
  105045. name: string;
  105046. /**
  105047. * List of lens flares used in this system.
  105048. */
  105049. lensFlares: LensFlare[];
  105050. /**
  105051. * Define a limit from the border the lens flare can be visible.
  105052. */
  105053. borderLimit: number;
  105054. /**
  105055. * Define a viewport border we do not want to see the lens flare in.
  105056. */
  105057. viewportBorder: number;
  105058. /**
  105059. * Define a predicate which could limit the list of meshes able to occlude the effect.
  105060. */
  105061. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  105062. /**
  105063. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  105064. */
  105065. layerMask: number;
  105066. /**
  105067. * Define the id of the lens flare system in the scene.
  105068. * (equal to name by default)
  105069. */
  105070. id: string;
  105071. private _scene;
  105072. private _emitter;
  105073. private _vertexBuffers;
  105074. private _indexBuffer;
  105075. private _effect;
  105076. private _positionX;
  105077. private _positionY;
  105078. private _isEnabled;
  105079. /** @hidden */
  105080. static _SceneComponentInitialization: (scene: Scene) => void;
  105081. /**
  105082. * Instantiates a lens flare system.
  105083. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  105084. * It is usually composed of several `lensFlare`.
  105085. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105086. * @param name Define the name of the lens flare system in the scene
  105087. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  105088. * @param scene Define the scene the lens flare system belongs to
  105089. */
  105090. constructor(
  105091. /**
  105092. * Define the name of the lens flare system
  105093. */
  105094. name: string, emitter: any, scene: Scene);
  105095. /**
  105096. * Define if the lens flare system is enabled.
  105097. */
  105098. isEnabled: boolean;
  105099. /**
  105100. * Get the scene the effects belongs to.
  105101. * @returns the scene holding the lens flare system
  105102. */
  105103. getScene(): Scene;
  105104. /**
  105105. * Get the emitter of the lens flare system.
  105106. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  105107. * @returns the emitter of the lens flare system
  105108. */
  105109. getEmitter(): any;
  105110. /**
  105111. * Set the emitter of the lens flare system.
  105112. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  105113. * @param newEmitter Define the new emitter of the system
  105114. */
  105115. setEmitter(newEmitter: any): void;
  105116. /**
  105117. * Get the lens flare system emitter position.
  105118. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  105119. * @returns the position
  105120. */
  105121. getEmitterPosition(): Vector3;
  105122. /**
  105123. * @hidden
  105124. */
  105125. computeEffectivePosition(globalViewport: Viewport): boolean;
  105126. /** @hidden */
  105127. _isVisible(): boolean;
  105128. /**
  105129. * @hidden
  105130. */
  105131. render(): boolean;
  105132. /**
  105133. * Dispose and release the lens flare with its associated resources.
  105134. */
  105135. dispose(): void;
  105136. /**
  105137. * Parse a lens flare system from a JSON repressentation
  105138. * @param parsedLensFlareSystem Define the JSON to parse
  105139. * @param scene Define the scene the parsed system should be instantiated in
  105140. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  105141. * @returns the parsed system
  105142. */
  105143. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  105144. /**
  105145. * Serialize the current Lens Flare System into a JSON representation.
  105146. * @returns the serialized JSON
  105147. */
  105148. serialize(): any;
  105149. }
  105150. }
  105151. declare module BABYLON {
  105152. /**
  105153. * This represents one of the lens effect in a `lensFlareSystem`.
  105154. * It controls one of the indiviual texture used in the effect.
  105155. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105156. */
  105157. export class LensFlare {
  105158. /**
  105159. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  105160. */
  105161. size: number;
  105162. /**
  105163. * 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.
  105164. */
  105165. position: number;
  105166. /**
  105167. * Define the lens color.
  105168. */
  105169. color: Color3;
  105170. /**
  105171. * Define the lens texture.
  105172. */
  105173. texture: Nullable<Texture>;
  105174. /**
  105175. * Define the alpha mode to render this particular lens.
  105176. */
  105177. alphaMode: number;
  105178. private _system;
  105179. /**
  105180. * Creates a new Lens Flare.
  105181. * This represents one of the lens effect in a `lensFlareSystem`.
  105182. * It controls one of the indiviual texture used in the effect.
  105183. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105184. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  105185. * @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.
  105186. * @param color Define the lens color
  105187. * @param imgUrl Define the lens texture url
  105188. * @param system Define the `lensFlareSystem` this flare is part of
  105189. * @returns The newly created Lens Flare
  105190. */
  105191. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  105192. /**
  105193. * Instantiates a new Lens Flare.
  105194. * This represents one of the lens effect in a `lensFlareSystem`.
  105195. * It controls one of the indiviual texture used in the effect.
  105196. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105197. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  105198. * @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.
  105199. * @param color Define the lens color
  105200. * @param imgUrl Define the lens texture url
  105201. * @param system Define the `lensFlareSystem` this flare is part of
  105202. */
  105203. constructor(
  105204. /**
  105205. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  105206. */
  105207. size: number,
  105208. /**
  105209. * 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.
  105210. */
  105211. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  105212. /**
  105213. * Dispose and release the lens flare with its associated resources.
  105214. */
  105215. dispose(): void;
  105216. }
  105217. }
  105218. declare module BABYLON {
  105219. interface AbstractScene {
  105220. /**
  105221. * The list of lens flare system added to the scene
  105222. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105223. */
  105224. lensFlareSystems: Array<LensFlareSystem>;
  105225. /**
  105226. * Removes the given lens flare system from this scene.
  105227. * @param toRemove The lens flare system to remove
  105228. * @returns The index of the removed lens flare system
  105229. */
  105230. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  105231. /**
  105232. * Adds the given lens flare system to this scene
  105233. * @param newLensFlareSystem The lens flare system to add
  105234. */
  105235. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  105236. /**
  105237. * Gets a lens flare system using its name
  105238. * @param name defines the name to look for
  105239. * @returns the lens flare system or null if not found
  105240. */
  105241. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  105242. /**
  105243. * Gets a lens flare system using its id
  105244. * @param id defines the id to look for
  105245. * @returns the lens flare system or null if not found
  105246. */
  105247. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  105248. }
  105249. /**
  105250. * Defines the lens flare scene component responsible to manage any lens flares
  105251. * in a given scene.
  105252. */
  105253. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  105254. /**
  105255. * The component name helpfull to identify the component in the list of scene components.
  105256. */
  105257. readonly name: string;
  105258. /**
  105259. * The scene the component belongs to.
  105260. */
  105261. scene: Scene;
  105262. /**
  105263. * Creates a new instance of the component for the given scene
  105264. * @param scene Defines the scene to register the component in
  105265. */
  105266. constructor(scene: Scene);
  105267. /**
  105268. * Registers the component in a given scene
  105269. */
  105270. register(): void;
  105271. /**
  105272. * Rebuilds the elements related to this component in case of
  105273. * context lost for instance.
  105274. */
  105275. rebuild(): void;
  105276. /**
  105277. * Adds all the element from the container to the scene
  105278. * @param container the container holding the elements
  105279. */
  105280. addFromContainer(container: AbstractScene): void;
  105281. /**
  105282. * Removes all the elements in the container from the scene
  105283. * @param container contains the elements to remove
  105284. * @param dispose if the removed element should be disposed (default: false)
  105285. */
  105286. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  105287. /**
  105288. * Serializes the component data to the specified json object
  105289. * @param serializationObject The object to serialize to
  105290. */
  105291. serialize(serializationObject: any): void;
  105292. /**
  105293. * Disposes the component and the associated ressources.
  105294. */
  105295. dispose(): void;
  105296. private _draw;
  105297. }
  105298. }
  105299. declare module BABYLON {
  105300. /**
  105301. * Defines the shadow generator component responsible to manage any shadow generators
  105302. * in a given scene.
  105303. */
  105304. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  105305. /**
  105306. * The component name helpfull to identify the component in the list of scene components.
  105307. */
  105308. readonly name: string;
  105309. /**
  105310. * The scene the component belongs to.
  105311. */
  105312. scene: Scene;
  105313. /**
  105314. * Creates a new instance of the component for the given scene
  105315. * @param scene Defines the scene to register the component in
  105316. */
  105317. constructor(scene: Scene);
  105318. /**
  105319. * Registers the component in a given scene
  105320. */
  105321. register(): void;
  105322. /**
  105323. * Rebuilds the elements related to this component in case of
  105324. * context lost for instance.
  105325. */
  105326. rebuild(): void;
  105327. /**
  105328. * Serializes the component data to the specified json object
  105329. * @param serializationObject The object to serialize to
  105330. */
  105331. serialize(serializationObject: any): void;
  105332. /**
  105333. * Adds all the element from the container to the scene
  105334. * @param container the container holding the elements
  105335. */
  105336. addFromContainer(container: AbstractScene): void;
  105337. /**
  105338. * Removes all the elements in the container from the scene
  105339. * @param container contains the elements to remove
  105340. * @param dispose if the removed element should be disposed (default: false)
  105341. */
  105342. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  105343. /**
  105344. * Rebuilds the elements related to this component in case of
  105345. * context lost for instance.
  105346. */
  105347. dispose(): void;
  105348. private _gatherRenderTargets;
  105349. }
  105350. }
  105351. declare module BABYLON {
  105352. /**
  105353. * A directional light is defined by a direction (what a surprise!).
  105354. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105355. * 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.
  105356. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105357. */
  105358. export class DirectionalLight extends ShadowLight {
  105359. private _shadowFrustumSize;
  105360. /**
  105361. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105362. */
  105363. /**
  105364. * Specifies a fix frustum size for the shadow generation.
  105365. */
  105366. shadowFrustumSize: number;
  105367. private _shadowOrthoScale;
  105368. /**
  105369. * Gets the shadow projection scale against the optimal computed one.
  105370. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105371. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105372. */
  105373. /**
  105374. * Sets the shadow projection scale against the optimal computed one.
  105375. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105376. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105377. */
  105378. shadowOrthoScale: number;
  105379. /**
  105380. * Automatically compute the projection matrix to best fit (including all the casters)
  105381. * on each frame.
  105382. */
  105383. autoUpdateExtends: boolean;
  105384. private _orthoLeft;
  105385. private _orthoRight;
  105386. private _orthoTop;
  105387. private _orthoBottom;
  105388. /**
  105389. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105390. * The directional light is emitted from everywhere in the given direction.
  105391. * It can cast shadows.
  105392. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105393. * @param name The friendly name of the light
  105394. * @param direction The direction of the light
  105395. * @param scene The scene the light belongs to
  105396. */
  105397. constructor(name: string, direction: Vector3, scene: Scene);
  105398. /**
  105399. * Returns the string "DirectionalLight".
  105400. * @return The class name
  105401. */
  105402. getClassName(): string;
  105403. /**
  105404. * Returns the integer 1.
  105405. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105406. */
  105407. getTypeID(): number;
  105408. /**
  105409. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  105410. * Returns the DirectionalLight Shadow projection matrix.
  105411. */
  105412. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105413. /**
  105414. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105415. * Returns the DirectionalLight Shadow projection matrix.
  105416. */
  105417. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105418. /**
  105419. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105420. * Returns the DirectionalLight Shadow projection matrix.
  105421. */
  105422. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105423. protected _buildUniformLayout(): void;
  105424. /**
  105425. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105426. * @param effect The effect to update
  105427. * @param lightIndex The index of the light in the effect to update
  105428. * @returns The directional light
  105429. */
  105430. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105431. /**
  105432. * Gets the minZ used for shadow according to both the scene and the light.
  105433. *
  105434. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105435. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105436. * @param activeCamera The camera we are returning the min for
  105437. * @returns the depth min z
  105438. */
  105439. getDepthMinZ(activeCamera: Camera): number;
  105440. /**
  105441. * Gets the maxZ used for shadow according to both the scene and the light.
  105442. *
  105443. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105444. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105445. * @param activeCamera The camera we are returning the max for
  105446. * @returns the depth max z
  105447. */
  105448. getDepthMaxZ(activeCamera: Camera): number;
  105449. /**
  105450. * Prepares the list of defines specific to the light type.
  105451. * @param defines the list of defines
  105452. * @param lightIndex defines the index of the light for the effect
  105453. */
  105454. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105455. }
  105456. }
  105457. declare module BABYLON {
  105458. /**
  105459. * A point light is a light defined by an unique point in world space.
  105460. * The light is emitted in every direction from this point.
  105461. * A good example of a point light is a standard light bulb.
  105462. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105463. */
  105464. export class PointLight extends ShadowLight {
  105465. private _shadowAngle;
  105466. /**
  105467. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105468. * This specifies what angle the shadow will use to be created.
  105469. *
  105470. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105471. */
  105472. /**
  105473. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105474. * This specifies what angle the shadow will use to be created.
  105475. *
  105476. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105477. */
  105478. shadowAngle: number;
  105479. /**
  105480. * Gets the direction if it has been set.
  105481. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105482. */
  105483. /**
  105484. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105485. */
  105486. direction: Vector3;
  105487. /**
  105488. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  105489. * A PointLight emits the light in every direction.
  105490. * It can cast shadows.
  105491. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  105492. * ```javascript
  105493. * var pointLight = new PointLight("pl", camera.position, scene);
  105494. * ```
  105495. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105496. * @param name The light friendly name
  105497. * @param position The position of the point light in the scene
  105498. * @param scene The scene the lights belongs to
  105499. */
  105500. constructor(name: string, position: Vector3, scene: Scene);
  105501. /**
  105502. * Returns the string "PointLight"
  105503. * @returns the class name
  105504. */
  105505. getClassName(): string;
  105506. /**
  105507. * Returns the integer 0.
  105508. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105509. */
  105510. getTypeID(): number;
  105511. /**
  105512. * Specifies wether or not the shadowmap should be a cube texture.
  105513. * @returns true if the shadowmap needs to be a cube texture.
  105514. */
  105515. needCube(): boolean;
  105516. /**
  105517. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  105518. * @param faceIndex The index of the face we are computed the direction to generate shadow
  105519. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  105520. */
  105521. getShadowDirection(faceIndex?: number): Vector3;
  105522. /**
  105523. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  105524. * - fov = PI / 2
  105525. * - aspect ratio : 1.0
  105526. * - z-near and far equal to the active camera minZ and maxZ.
  105527. * Returns the PointLight.
  105528. */
  105529. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105530. protected _buildUniformLayout(): void;
  105531. /**
  105532. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  105533. * @param effect The effect to update
  105534. * @param lightIndex The index of the light in the effect to update
  105535. * @returns The point light
  105536. */
  105537. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  105538. /**
  105539. * Prepares the list of defines specific to the light type.
  105540. * @param defines the list of defines
  105541. * @param lightIndex defines the index of the light for the effect
  105542. */
  105543. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105544. }
  105545. }
  105546. declare module BABYLON {
  105547. /**
  105548. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105549. * These values define a cone of light starting from the position, emitting toward the direction.
  105550. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105551. * and the exponent defines the speed of the decay of the light with distance (reach).
  105552. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105553. */
  105554. export class SpotLight extends ShadowLight {
  105555. private _angle;
  105556. private _innerAngle;
  105557. private _cosHalfAngle;
  105558. private _lightAngleScale;
  105559. private _lightAngleOffset;
  105560. /**
  105561. * Gets the cone angle of the spot light in Radians.
  105562. */
  105563. /**
  105564. * Sets the cone angle of the spot light in Radians.
  105565. */
  105566. angle: number;
  105567. /**
  105568. * Only used in gltf falloff mode, this defines the angle where
  105569. * the directional falloff will start before cutting at angle which could be seen
  105570. * as outer angle.
  105571. */
  105572. /**
  105573. * Only used in gltf falloff mode, this defines the angle where
  105574. * the directional falloff will start before cutting at angle which could be seen
  105575. * as outer angle.
  105576. */
  105577. innerAngle: number;
  105578. private _shadowAngleScale;
  105579. /**
  105580. * Allows scaling the angle of the light for shadow generation only.
  105581. */
  105582. /**
  105583. * Allows scaling the angle of the light for shadow generation only.
  105584. */
  105585. shadowAngleScale: number;
  105586. /**
  105587. * The light decay speed with the distance from the emission spot.
  105588. */
  105589. exponent: number;
  105590. private _projectionTextureMatrix;
  105591. /**
  105592. * Allows reading the projecton texture
  105593. */
  105594. readonly projectionTextureMatrix: Matrix;
  105595. protected _projectionTextureLightNear: number;
  105596. /**
  105597. * Gets the near clip of the Spotlight for texture projection.
  105598. */
  105599. /**
  105600. * Sets the near clip of the Spotlight for texture projection.
  105601. */
  105602. projectionTextureLightNear: number;
  105603. protected _projectionTextureLightFar: number;
  105604. /**
  105605. * Gets the far clip of the Spotlight for texture projection.
  105606. */
  105607. /**
  105608. * Sets the far clip of the Spotlight for texture projection.
  105609. */
  105610. projectionTextureLightFar: number;
  105611. protected _projectionTextureUpDirection: Vector3;
  105612. /**
  105613. * Gets the Up vector of the Spotlight for texture projection.
  105614. */
  105615. /**
  105616. * Sets the Up vector of the Spotlight for texture projection.
  105617. */
  105618. projectionTextureUpDirection: Vector3;
  105619. private _projectionTexture;
  105620. /**
  105621. * Gets the projection texture of the light.
  105622. */
  105623. /**
  105624. * Sets the projection texture of the light.
  105625. */
  105626. projectionTexture: Nullable<BaseTexture>;
  105627. private _projectionTextureViewLightDirty;
  105628. private _projectionTextureProjectionLightDirty;
  105629. private _projectionTextureDirty;
  105630. private _projectionTextureViewTargetVector;
  105631. private _projectionTextureViewLightMatrix;
  105632. private _projectionTextureProjectionLightMatrix;
  105633. private _projectionTextureScalingMatrix;
  105634. /**
  105635. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105636. * It can cast shadows.
  105637. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105638. * @param name The light friendly name
  105639. * @param position The position of the spot light in the scene
  105640. * @param direction The direction of the light in the scene
  105641. * @param angle The cone angle of the light in Radians
  105642. * @param exponent The light decay speed with the distance from the emission spot
  105643. * @param scene The scene the lights belongs to
  105644. */
  105645. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105646. /**
  105647. * Returns the string "SpotLight".
  105648. * @returns the class name
  105649. */
  105650. getClassName(): string;
  105651. /**
  105652. * Returns the integer 2.
  105653. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105654. */
  105655. getTypeID(): number;
  105656. /**
  105657. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105658. */
  105659. protected _setDirection(value: Vector3): void;
  105660. /**
  105661. * Overrides the position setter to recompute the projection texture view light Matrix.
  105662. */
  105663. protected _setPosition(value: Vector3): void;
  105664. /**
  105665. * 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.
  105666. * Returns the SpotLight.
  105667. */
  105668. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105669. protected _computeProjectionTextureViewLightMatrix(): void;
  105670. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105671. /**
  105672. * Main function for light texture projection matrix computing.
  105673. */
  105674. protected _computeProjectionTextureMatrix(): void;
  105675. protected _buildUniformLayout(): void;
  105676. private _computeAngleValues;
  105677. /**
  105678. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105679. * @param effect The effect to update
  105680. * @param lightIndex The index of the light in the effect to update
  105681. * @returns The spot light
  105682. */
  105683. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105684. /**
  105685. * Disposes the light and the associated resources.
  105686. */
  105687. dispose(): void;
  105688. /**
  105689. * Prepares the list of defines specific to the light type.
  105690. * @param defines the list of defines
  105691. * @param lightIndex defines the index of the light for the effect
  105692. */
  105693. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105694. }
  105695. }
  105696. declare module BABYLON {
  105697. /**
  105698. * Header information of HDR texture files.
  105699. */
  105700. export interface HDRInfo {
  105701. /**
  105702. * The height of the texture in pixels.
  105703. */
  105704. height: number;
  105705. /**
  105706. * The width of the texture in pixels.
  105707. */
  105708. width: number;
  105709. /**
  105710. * The index of the beginning of the data in the binary file.
  105711. */
  105712. dataPosition: number;
  105713. }
  105714. /**
  105715. * This groups tools to convert HDR texture to native colors array.
  105716. */
  105717. export class HDRTools {
  105718. private static Ldexp;
  105719. private static Rgbe2float;
  105720. private static readStringLine;
  105721. /**
  105722. * Reads header information from an RGBE texture stored in a native array.
  105723. * More information on this format are available here:
  105724. * https://en.wikipedia.org/wiki/RGBE_image_format
  105725. *
  105726. * @param uint8array The binary file stored in native array.
  105727. * @return The header information.
  105728. */
  105729. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  105730. /**
  105731. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  105732. * This RGBE texture needs to store the information as a panorama.
  105733. *
  105734. * More information on this format are available here:
  105735. * https://en.wikipedia.org/wiki/RGBE_image_format
  105736. *
  105737. * @param buffer The binary file stored in an array buffer.
  105738. * @param size The expected size of the extracted cubemap.
  105739. * @return The Cube Map information.
  105740. */
  105741. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  105742. /**
  105743. * Returns the pixels data extracted from an RGBE texture.
  105744. * This pixels will be stored left to right up to down in the R G B order in one array.
  105745. *
  105746. * More information on this format are available here:
  105747. * https://en.wikipedia.org/wiki/RGBE_image_format
  105748. *
  105749. * @param uint8array The binary file stored in an array buffer.
  105750. * @param hdrInfo The header information of the file.
  105751. * @return The pixels data in RGB right to left up to down order.
  105752. */
  105753. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  105754. private static RGBE_ReadPixels_RLE;
  105755. }
  105756. }
  105757. declare module BABYLON {
  105758. /**
  105759. * This represents a texture coming from an HDR input.
  105760. *
  105761. * The only supported format is currently panorama picture stored in RGBE format.
  105762. * Example of such files can be found on HDRLib: http://hdrlib.com/
  105763. */
  105764. export class HDRCubeTexture extends BaseTexture {
  105765. private static _facesMapping;
  105766. private _generateHarmonics;
  105767. private _noMipmap;
  105768. private _textureMatrix;
  105769. private _size;
  105770. private _onLoad;
  105771. private _onError;
  105772. /**
  105773. * The texture URL.
  105774. */
  105775. url: string;
  105776. /**
  105777. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  105778. */
  105779. coordinatesMode: number;
  105780. protected _isBlocking: boolean;
  105781. /**
  105782. * Sets wether or not the texture is blocking during loading.
  105783. */
  105784. /**
  105785. * Gets wether or not the texture is blocking during loading.
  105786. */
  105787. isBlocking: boolean;
  105788. protected _rotationY: number;
  105789. /**
  105790. * Sets texture matrix rotation angle around Y axis in radians.
  105791. */
  105792. /**
  105793. * Gets texture matrix rotation angle around Y axis radians.
  105794. */
  105795. rotationY: number;
  105796. /**
  105797. * Gets or sets the center of the bounding box associated with the cube texture
  105798. * It must define where the camera used to render the texture was set
  105799. */
  105800. boundingBoxPosition: Vector3;
  105801. private _boundingBoxSize;
  105802. /**
  105803. * Gets or sets the size of the bounding box associated with the cube texture
  105804. * When defined, the cubemap will switch to local mode
  105805. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  105806. * @example https://www.babylonjs-playground.com/#RNASML
  105807. */
  105808. boundingBoxSize: Vector3;
  105809. /**
  105810. * Instantiates an HDRTexture from the following parameters.
  105811. *
  105812. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  105813. * @param scene The scene the texture will be used in
  105814. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105815. * @param noMipmap Forces to not generate the mipmap if true
  105816. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  105817. * @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)
  105818. * @param reserved Reserved flag for internal use.
  105819. */
  105820. 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>);
  105821. /**
  105822. * Get the current class name of the texture useful for serialization or dynamic coding.
  105823. * @returns "HDRCubeTexture"
  105824. */
  105825. getClassName(): string;
  105826. /**
  105827. * Occurs when the file is raw .hdr file.
  105828. */
  105829. private loadTexture;
  105830. clone(): HDRCubeTexture;
  105831. delayLoad(): void;
  105832. /**
  105833. * Get the texture reflection matrix used to rotate/transform the reflection.
  105834. * @returns the reflection matrix
  105835. */
  105836. getReflectionTextureMatrix(): Matrix;
  105837. /**
  105838. * Set the texture reflection matrix used to rotate/transform the reflection.
  105839. * @param value Define the reflection matrix to set
  105840. */
  105841. setReflectionTextureMatrix(value: Matrix): void;
  105842. /**
  105843. * Parses a JSON representation of an HDR Texture in order to create the texture
  105844. * @param parsedTexture Define the JSON representation
  105845. * @param scene Define the scene the texture should be created in
  105846. * @param rootUrl Define the root url in case we need to load relative dependencies
  105847. * @returns the newly created texture after parsing
  105848. */
  105849. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  105850. serialize(): any;
  105851. }
  105852. }
  105853. declare module BABYLON {
  105854. /**
  105855. * Class used to control physics engine
  105856. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105857. */
  105858. export class PhysicsEngine implements IPhysicsEngine {
  105859. private _physicsPlugin;
  105860. /**
  105861. * Global value used to control the smallest number supported by the simulation
  105862. */
  105863. static Epsilon: number;
  105864. private _impostors;
  105865. private _joints;
  105866. /**
  105867. * Gets the gravity vector used by the simulation
  105868. */
  105869. gravity: Vector3;
  105870. /**
  105871. * Factory used to create the default physics plugin.
  105872. * @returns The default physics plugin
  105873. */
  105874. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  105875. /**
  105876. * Creates a new Physics Engine
  105877. * @param gravity defines the gravity vector used by the simulation
  105878. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  105879. */
  105880. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  105881. /**
  105882. * Sets the gravity vector used by the simulation
  105883. * @param gravity defines the gravity vector to use
  105884. */
  105885. setGravity(gravity: Vector3): void;
  105886. /**
  105887. * Set the time step of the physics engine.
  105888. * Default is 1/60.
  105889. * To slow it down, enter 1/600 for example.
  105890. * To speed it up, 1/30
  105891. * @param newTimeStep defines the new timestep to apply to this world.
  105892. */
  105893. setTimeStep(newTimeStep?: number): void;
  105894. /**
  105895. * Get the time step of the physics engine.
  105896. * @returns the current time step
  105897. */
  105898. getTimeStep(): number;
  105899. /**
  105900. * Release all resources
  105901. */
  105902. dispose(): void;
  105903. /**
  105904. * Gets the name of the current physics plugin
  105905. * @returns the name of the plugin
  105906. */
  105907. getPhysicsPluginName(): string;
  105908. /**
  105909. * Adding a new impostor for the impostor tracking.
  105910. * This will be done by the impostor itself.
  105911. * @param impostor the impostor to add
  105912. */
  105913. addImpostor(impostor: PhysicsImpostor): void;
  105914. /**
  105915. * Remove an impostor from the engine.
  105916. * This impostor and its mesh will not longer be updated by the physics engine.
  105917. * @param impostor the impostor to remove
  105918. */
  105919. removeImpostor(impostor: PhysicsImpostor): void;
  105920. /**
  105921. * Add a joint to the physics engine
  105922. * @param mainImpostor defines the main impostor to which the joint is added.
  105923. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  105924. * @param joint defines the joint that will connect both impostors.
  105925. */
  105926. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105927. /**
  105928. * Removes a joint from the simulation
  105929. * @param mainImpostor defines the impostor used with the joint
  105930. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  105931. * @param joint defines the joint to remove
  105932. */
  105933. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105934. /**
  105935. * Called by the scene. No need to call it.
  105936. * @param delta defines the timespam between frames
  105937. */
  105938. _step(delta: number): void;
  105939. /**
  105940. * Gets the current plugin used to run the simulation
  105941. * @returns current plugin
  105942. */
  105943. getPhysicsPlugin(): IPhysicsEnginePlugin;
  105944. /**
  105945. * Gets the list of physic impostors
  105946. * @returns an array of PhysicsImpostor
  105947. */
  105948. getImpostors(): Array<PhysicsImpostor>;
  105949. /**
  105950. * Gets the impostor for a physics enabled object
  105951. * @param object defines the object impersonated by the impostor
  105952. * @returns the PhysicsImpostor or null if not found
  105953. */
  105954. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105955. /**
  105956. * Gets the impostor for a physics body object
  105957. * @param body defines physics body used by the impostor
  105958. * @returns the PhysicsImpostor or null if not found
  105959. */
  105960. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  105961. /**
  105962. * Does a raycast in the physics world
  105963. * @param from when should the ray start?
  105964. * @param to when should the ray end?
  105965. * @returns PhysicsRaycastResult
  105966. */
  105967. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105968. }
  105969. }
  105970. declare module BABYLON {
  105971. /** @hidden */
  105972. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  105973. private _useDeltaForWorldStep;
  105974. world: any;
  105975. name: string;
  105976. private _physicsMaterials;
  105977. private _fixedTimeStep;
  105978. private _cannonRaycastResult;
  105979. private _raycastResult;
  105980. BJSCANNON: any;
  105981. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  105982. setGravity(gravity: Vector3): void;
  105983. setTimeStep(timeStep: number): void;
  105984. getTimeStep(): number;
  105985. executeStep(delta: number): void;
  105986. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105987. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105988. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105989. private _processChildMeshes;
  105990. removePhysicsBody(impostor: PhysicsImpostor): void;
  105991. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105992. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105993. private _addMaterial;
  105994. private _checkWithEpsilon;
  105995. private _createShape;
  105996. private _createHeightmap;
  105997. private _minus90X;
  105998. private _plus90X;
  105999. private _tmpPosition;
  106000. private _tmpDeltaPosition;
  106001. private _tmpUnityRotation;
  106002. private _updatePhysicsBodyTransformation;
  106003. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106004. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106005. isSupported(): boolean;
  106006. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106007. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106008. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106009. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106010. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106011. getBodyMass(impostor: PhysicsImpostor): number;
  106012. getBodyFriction(impostor: PhysicsImpostor): number;
  106013. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106014. getBodyRestitution(impostor: PhysicsImpostor): number;
  106015. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106016. sleepBody(impostor: PhysicsImpostor): void;
  106017. wakeUpBody(impostor: PhysicsImpostor): void;
  106018. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  106019. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  106020. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  106021. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106022. getRadius(impostor: PhysicsImpostor): number;
  106023. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106024. dispose(): void;
  106025. private _extendNamespace;
  106026. /**
  106027. * Does a raycast in the physics world
  106028. * @param from when should the ray start?
  106029. * @param to when should the ray end?
  106030. * @returns PhysicsRaycastResult
  106031. */
  106032. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106033. }
  106034. }
  106035. declare module BABYLON {
  106036. /** @hidden */
  106037. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  106038. world: any;
  106039. name: string;
  106040. BJSOIMO: any;
  106041. private _raycastResult;
  106042. constructor(iterations?: number, oimoInjection?: any);
  106043. setGravity(gravity: Vector3): void;
  106044. setTimeStep(timeStep: number): void;
  106045. getTimeStep(): number;
  106046. private _tmpImpostorsArray;
  106047. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106048. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106049. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106050. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106051. private _tmpPositionVector;
  106052. removePhysicsBody(impostor: PhysicsImpostor): void;
  106053. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  106054. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  106055. isSupported(): boolean;
  106056. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106057. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106058. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106059. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106060. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106061. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106062. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106063. getBodyMass(impostor: PhysicsImpostor): number;
  106064. getBodyFriction(impostor: PhysicsImpostor): number;
  106065. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106066. getBodyRestitution(impostor: PhysicsImpostor): number;
  106067. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106068. sleepBody(impostor: PhysicsImpostor): void;
  106069. wakeUpBody(impostor: PhysicsImpostor): void;
  106070. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106071. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  106072. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106073. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106074. getRadius(impostor: PhysicsImpostor): number;
  106075. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106076. dispose(): void;
  106077. /**
  106078. * Does a raycast in the physics world
  106079. * @param from when should the ray start?
  106080. * @param to when should the ray end?
  106081. * @returns PhysicsRaycastResult
  106082. */
  106083. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106084. }
  106085. }
  106086. declare module BABYLON {
  106087. interface AbstractScene {
  106088. /**
  106089. * The list of reflection probes added to the scene
  106090. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  106091. */
  106092. reflectionProbes: Array<ReflectionProbe>;
  106093. /**
  106094. * Removes the given reflection probe from this scene.
  106095. * @param toRemove The reflection probe to remove
  106096. * @returns The index of the removed reflection probe
  106097. */
  106098. removeReflectionProbe(toRemove: ReflectionProbe): number;
  106099. /**
  106100. * Adds the given reflection probe to this scene.
  106101. * @param newReflectionProbe The reflection probe to add
  106102. */
  106103. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  106104. }
  106105. /**
  106106. * Class used to generate realtime reflection / refraction cube textures
  106107. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  106108. */
  106109. export class ReflectionProbe {
  106110. /** defines the name of the probe */
  106111. name: string;
  106112. private _scene;
  106113. private _renderTargetTexture;
  106114. private _projectionMatrix;
  106115. private _viewMatrix;
  106116. private _target;
  106117. private _add;
  106118. private _attachedMesh;
  106119. private _invertYAxis;
  106120. /** Gets or sets probe position (center of the cube map) */
  106121. position: Vector3;
  106122. /**
  106123. * Creates a new reflection probe
  106124. * @param name defines the name of the probe
  106125. * @param size defines the texture resolution (for each face)
  106126. * @param scene defines the hosting scene
  106127. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  106128. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  106129. */
  106130. constructor(
  106131. /** defines the name of the probe */
  106132. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  106133. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  106134. samples: number;
  106135. /** Gets or sets the refresh rate to use (on every frame by default) */
  106136. refreshRate: number;
  106137. /**
  106138. * Gets the hosting scene
  106139. * @returns a Scene
  106140. */
  106141. getScene(): Scene;
  106142. /** Gets the internal CubeTexture used to render to */
  106143. readonly cubeTexture: RenderTargetTexture;
  106144. /** Gets the list of meshes to render */
  106145. readonly renderList: Nullable<AbstractMesh[]>;
  106146. /**
  106147. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  106148. * @param mesh defines the mesh to attach to
  106149. */
  106150. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106151. /**
  106152. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  106153. * @param renderingGroupId The rendering group id corresponding to its index
  106154. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  106155. */
  106156. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  106157. /**
  106158. * Clean all associated resources
  106159. */
  106160. dispose(): void;
  106161. /**
  106162. * Converts the reflection probe information to a readable string for debug purpose.
  106163. * @param fullDetails Supports for multiple levels of logging within scene loading
  106164. * @returns the human readable reflection probe info
  106165. */
  106166. toString(fullDetails?: boolean): string;
  106167. /**
  106168. * Get the class name of the relfection probe.
  106169. * @returns "ReflectionProbe"
  106170. */
  106171. getClassName(): string;
  106172. /**
  106173. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  106174. * @returns The JSON representation of the texture
  106175. */
  106176. serialize(): any;
  106177. /**
  106178. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  106179. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  106180. * @param scene Define the scene the parsed reflection probe should be instantiated in
  106181. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  106182. * @returns The parsed reflection probe if successful
  106183. */
  106184. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  106185. }
  106186. }
  106187. declare module BABYLON {
  106188. /** @hidden */
  106189. export var _BabylonLoaderRegistered: boolean;
  106190. }
  106191. declare module BABYLON {
  106192. /**
  106193. * The Physically based simple base material of BJS.
  106194. *
  106195. * This enables better naming and convention enforcements on top of the pbrMaterial.
  106196. * It is used as the base class for both the specGloss and metalRough conventions.
  106197. */
  106198. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  106199. /**
  106200. * Number of Simultaneous lights allowed on the material.
  106201. */
  106202. maxSimultaneousLights: number;
  106203. /**
  106204. * If sets to true, disables all the lights affecting the material.
  106205. */
  106206. disableLighting: boolean;
  106207. /**
  106208. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  106209. */
  106210. environmentTexture: BaseTexture;
  106211. /**
  106212. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106213. */
  106214. invertNormalMapX: boolean;
  106215. /**
  106216. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106217. */
  106218. invertNormalMapY: boolean;
  106219. /**
  106220. * Normal map used in the model.
  106221. */
  106222. normalTexture: BaseTexture;
  106223. /**
  106224. * Emissivie color used to self-illuminate the model.
  106225. */
  106226. emissiveColor: Color3;
  106227. /**
  106228. * Emissivie texture used to self-illuminate the model.
  106229. */
  106230. emissiveTexture: BaseTexture;
  106231. /**
  106232. * Occlusion Channel Strenght.
  106233. */
  106234. occlusionStrength: number;
  106235. /**
  106236. * Occlusion Texture of the material (adding extra occlusion effects).
  106237. */
  106238. occlusionTexture: BaseTexture;
  106239. /**
  106240. * Defines the alpha limits in alpha test mode.
  106241. */
  106242. alphaCutOff: number;
  106243. /**
  106244. * Gets the current double sided mode.
  106245. */
  106246. /**
  106247. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106248. */
  106249. doubleSided: boolean;
  106250. /**
  106251. * Stores the pre-calculated light information of a mesh in a texture.
  106252. */
  106253. lightmapTexture: BaseTexture;
  106254. /**
  106255. * If true, the light map contains occlusion information instead of lighting info.
  106256. */
  106257. useLightmapAsShadowmap: boolean;
  106258. /**
  106259. * Instantiates a new PBRMaterial instance.
  106260. *
  106261. * @param name The material name
  106262. * @param scene The scene the material will be use in.
  106263. */
  106264. constructor(name: string, scene: Scene);
  106265. getClassName(): string;
  106266. }
  106267. }
  106268. declare module BABYLON {
  106269. /**
  106270. * The PBR material of BJS following the metal roughness convention.
  106271. *
  106272. * This fits to the PBR convention in the GLTF definition:
  106273. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  106274. */
  106275. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  106276. /**
  106277. * The base color has two different interpretations depending on the value of metalness.
  106278. * When the material is a metal, the base color is the specific measured reflectance value
  106279. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  106280. * of the material.
  106281. */
  106282. baseColor: Color3;
  106283. /**
  106284. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  106285. * well as opacity information in the alpha channel.
  106286. */
  106287. baseTexture: BaseTexture;
  106288. /**
  106289. * Specifies the metallic scalar value of the material.
  106290. * Can also be used to scale the metalness values of the metallic texture.
  106291. */
  106292. metallic: number;
  106293. /**
  106294. * Specifies the roughness scalar value of the material.
  106295. * Can also be used to scale the roughness values of the metallic texture.
  106296. */
  106297. roughness: number;
  106298. /**
  106299. * Texture containing both the metallic value in the B channel and the
  106300. * roughness value in the G channel to keep better precision.
  106301. */
  106302. metallicRoughnessTexture: BaseTexture;
  106303. /**
  106304. * Instantiates a new PBRMetalRoughnessMaterial instance.
  106305. *
  106306. * @param name The material name
  106307. * @param scene The scene the material will be use in.
  106308. */
  106309. constructor(name: string, scene: Scene);
  106310. /**
  106311. * Return the currrent class name of the material.
  106312. */
  106313. getClassName(): string;
  106314. /**
  106315. * Makes a duplicate of the current material.
  106316. * @param name - name to use for the new material.
  106317. */
  106318. clone(name: string): PBRMetallicRoughnessMaterial;
  106319. /**
  106320. * Serialize the material to a parsable JSON object.
  106321. */
  106322. serialize(): any;
  106323. /**
  106324. * Parses a JSON object correponding to the serialize function.
  106325. */
  106326. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  106327. }
  106328. }
  106329. declare module BABYLON {
  106330. /**
  106331. * The PBR material of BJS following the specular glossiness convention.
  106332. *
  106333. * This fits to the PBR convention in the GLTF definition:
  106334. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  106335. */
  106336. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  106337. /**
  106338. * Specifies the diffuse color of the material.
  106339. */
  106340. diffuseColor: Color3;
  106341. /**
  106342. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  106343. * channel.
  106344. */
  106345. diffuseTexture: BaseTexture;
  106346. /**
  106347. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  106348. */
  106349. specularColor: Color3;
  106350. /**
  106351. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  106352. */
  106353. glossiness: number;
  106354. /**
  106355. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  106356. */
  106357. specularGlossinessTexture: BaseTexture;
  106358. /**
  106359. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  106360. *
  106361. * @param name The material name
  106362. * @param scene The scene the material will be use in.
  106363. */
  106364. constructor(name: string, scene: Scene);
  106365. /**
  106366. * Return the currrent class name of the material.
  106367. */
  106368. getClassName(): string;
  106369. /**
  106370. * Makes a duplicate of the current material.
  106371. * @param name - name to use for the new material.
  106372. */
  106373. clone(name: string): PBRSpecularGlossinessMaterial;
  106374. /**
  106375. * Serialize the material to a parsable JSON object.
  106376. */
  106377. serialize(): any;
  106378. /**
  106379. * Parses a JSON object correponding to the serialize function.
  106380. */
  106381. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  106382. }
  106383. }
  106384. declare module BABYLON {
  106385. /**
  106386. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  106387. * It can help converting any input color in a desired output one. This can then be used to create effects
  106388. * from sepia, black and white to sixties or futuristic rendering...
  106389. *
  106390. * The only supported format is currently 3dl.
  106391. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  106392. */
  106393. export class ColorGradingTexture extends BaseTexture {
  106394. /**
  106395. * The current texture matrix. (will always be identity in color grading texture)
  106396. */
  106397. private _textureMatrix;
  106398. /**
  106399. * The texture URL.
  106400. */
  106401. url: string;
  106402. /**
  106403. * Empty line regex stored for GC.
  106404. */
  106405. private static _noneEmptyLineRegex;
  106406. private _engine;
  106407. /**
  106408. * Instantiates a ColorGradingTexture from the following parameters.
  106409. *
  106410. * @param url The location of the color gradind data (currently only supporting 3dl)
  106411. * @param scene The scene the texture will be used in
  106412. */
  106413. constructor(url: string, scene: Scene);
  106414. /**
  106415. * Returns the texture matrix used in most of the material.
  106416. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  106417. */
  106418. getTextureMatrix(): Matrix;
  106419. /**
  106420. * Occurs when the file being loaded is a .3dl LUT file.
  106421. */
  106422. private load3dlTexture;
  106423. /**
  106424. * Starts the loading process of the texture.
  106425. */
  106426. private loadTexture;
  106427. /**
  106428. * Clones the color gradind texture.
  106429. */
  106430. clone(): ColorGradingTexture;
  106431. /**
  106432. * Called during delayed load for textures.
  106433. */
  106434. delayLoad(): void;
  106435. /**
  106436. * Parses a color grading texture serialized by Babylon.
  106437. * @param parsedTexture The texture information being parsedTexture
  106438. * @param scene The scene to load the texture in
  106439. * @param rootUrl The root url of the data assets to load
  106440. * @return A color gradind texture
  106441. */
  106442. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  106443. /**
  106444. * Serializes the LUT texture to json format.
  106445. */
  106446. serialize(): any;
  106447. }
  106448. }
  106449. declare module BABYLON {
  106450. /**
  106451. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  106452. */
  106453. export class EquiRectangularCubeTexture extends BaseTexture {
  106454. /** The six faces of the cube. */
  106455. private static _FacesMapping;
  106456. private _noMipmap;
  106457. private _onLoad;
  106458. private _onError;
  106459. /** The size of the cubemap. */
  106460. private _size;
  106461. /** The buffer of the image. */
  106462. private _buffer;
  106463. /** The width of the input image. */
  106464. private _width;
  106465. /** The height of the input image. */
  106466. private _height;
  106467. /** The URL to the image. */
  106468. url: string;
  106469. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  106470. coordinatesMode: number;
  106471. /**
  106472. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  106473. * @param url The location of the image
  106474. * @param scene The scene the texture will be used in
  106475. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  106476. * @param noMipmap Forces to not generate the mipmap if true
  106477. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  106478. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  106479. * @param onLoad — defines a callback called when texture is loaded
  106480. * @param onError — defines a callback called if there is an error
  106481. */
  106482. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  106483. /**
  106484. * Load the image data, by putting the image on a canvas and extracting its buffer.
  106485. */
  106486. private loadImage;
  106487. /**
  106488. * Convert the image buffer into a cubemap and create a CubeTexture.
  106489. */
  106490. private loadTexture;
  106491. /**
  106492. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  106493. * @param buffer The ArrayBuffer that should be converted.
  106494. * @returns The buffer as Float32Array.
  106495. */
  106496. private getFloat32ArrayFromArrayBuffer;
  106497. /**
  106498. * Get the current class name of the texture useful for serialization or dynamic coding.
  106499. * @returns "EquiRectangularCubeTexture"
  106500. */
  106501. getClassName(): string;
  106502. /**
  106503. * Create a clone of the current EquiRectangularCubeTexture and return it.
  106504. * @returns A clone of the current EquiRectangularCubeTexture.
  106505. */
  106506. clone(): EquiRectangularCubeTexture;
  106507. }
  106508. }
  106509. declare module BABYLON {
  106510. /**
  106511. * Based on jsTGALoader - Javascript loader for TGA file
  106512. * By Vincent Thibault
  106513. * @see http://blog.robrowser.com/javascript-tga-loader.html
  106514. */
  106515. export class TGATools {
  106516. private static _TYPE_INDEXED;
  106517. private static _TYPE_RGB;
  106518. private static _TYPE_GREY;
  106519. private static _TYPE_RLE_INDEXED;
  106520. private static _TYPE_RLE_RGB;
  106521. private static _TYPE_RLE_GREY;
  106522. private static _ORIGIN_MASK;
  106523. private static _ORIGIN_SHIFT;
  106524. private static _ORIGIN_BL;
  106525. private static _ORIGIN_BR;
  106526. private static _ORIGIN_UL;
  106527. private static _ORIGIN_UR;
  106528. /**
  106529. * Gets the header of a TGA file
  106530. * @param data defines the TGA data
  106531. * @returns the header
  106532. */
  106533. static GetTGAHeader(data: Uint8Array): any;
  106534. /**
  106535. * Uploads TGA content to a Babylon Texture
  106536. * @hidden
  106537. */
  106538. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  106539. /** @hidden */
  106540. 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;
  106541. /** @hidden */
  106542. 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;
  106543. /** @hidden */
  106544. 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;
  106545. /** @hidden */
  106546. 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;
  106547. /** @hidden */
  106548. 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;
  106549. /** @hidden */
  106550. 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;
  106551. }
  106552. }
  106553. declare module BABYLON {
  106554. /**
  106555. * Implementation of the TGA Texture Loader.
  106556. * @hidden
  106557. */
  106558. export class _TGATextureLoader implements IInternalTextureLoader {
  106559. /**
  106560. * Defines wether the loader supports cascade loading the different faces.
  106561. */
  106562. readonly supportCascades: boolean;
  106563. /**
  106564. * This returns if the loader support the current file information.
  106565. * @param extension defines the file extension of the file being loaded
  106566. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106567. * @param fallback defines the fallback internal texture if any
  106568. * @param isBase64 defines whether the texture is encoded as a base64
  106569. * @param isBuffer defines whether the texture data are stored as a buffer
  106570. * @returns true if the loader can load the specified file
  106571. */
  106572. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106573. /**
  106574. * Transform the url before loading if required.
  106575. * @param rootUrl the url of the texture
  106576. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106577. * @returns the transformed texture
  106578. */
  106579. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106580. /**
  106581. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106582. * @param rootUrl the url of the texture
  106583. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106584. * @returns the fallback texture
  106585. */
  106586. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106587. /**
  106588. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106589. * @param data contains the texture data
  106590. * @param texture defines the BabylonJS internal texture
  106591. * @param createPolynomials will be true if polynomials have been requested
  106592. * @param onLoad defines the callback to trigger once the texture is ready
  106593. * @param onError defines the callback to trigger in case of error
  106594. */
  106595. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106596. /**
  106597. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106598. * @param data contains the texture data
  106599. * @param texture defines the BabylonJS internal texture
  106600. * @param callback defines the method to call once ready to upload
  106601. */
  106602. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106603. }
  106604. }
  106605. declare module BABYLON {
  106606. /**
  106607. * 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.
  106608. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106609. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106610. */
  106611. export class CustomProceduralTexture extends ProceduralTexture {
  106612. private _animate;
  106613. private _time;
  106614. private _config;
  106615. private _texturePath;
  106616. /**
  106617. * Instantiates a new Custom Procedural Texture.
  106618. * 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.
  106619. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106620. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106621. * @param name Define the name of the texture
  106622. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  106623. * @param size Define the size of the texture to create
  106624. * @param scene Define the scene the texture belongs to
  106625. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  106626. * @param generateMipMaps Define if the texture should creates mip maps or not
  106627. */
  106628. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106629. private _loadJson;
  106630. /**
  106631. * Is the texture ready to be used ? (rendered at least once)
  106632. * @returns true if ready, otherwise, false.
  106633. */
  106634. isReady(): boolean;
  106635. /**
  106636. * Render the texture to its associated render target.
  106637. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  106638. */
  106639. render(useCameraPostProcess?: boolean): void;
  106640. /**
  106641. * Update the list of dependant textures samplers in the shader.
  106642. */
  106643. updateTextures(): void;
  106644. /**
  106645. * Update the uniform values of the procedural texture in the shader.
  106646. */
  106647. updateShaderUniforms(): void;
  106648. /**
  106649. * Define if the texture animates or not.
  106650. */
  106651. animate: boolean;
  106652. }
  106653. }
  106654. declare module BABYLON {
  106655. /** @hidden */
  106656. export var noisePixelShader: {
  106657. name: string;
  106658. shader: string;
  106659. };
  106660. }
  106661. declare module BABYLON {
  106662. /**
  106663. * Class used to generate noise procedural textures
  106664. */
  106665. export class NoiseProceduralTexture extends ProceduralTexture {
  106666. private _time;
  106667. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  106668. brightness: number;
  106669. /** Defines the number of octaves to process */
  106670. octaves: number;
  106671. /** Defines the level of persistence (0.8 by default) */
  106672. persistence: number;
  106673. /** Gets or sets animation speed factor (default is 1) */
  106674. animationSpeedFactor: number;
  106675. /**
  106676. * Creates a new NoiseProceduralTexture
  106677. * @param name defines the name fo the texture
  106678. * @param size defines the size of the texture (default is 256)
  106679. * @param scene defines the hosting scene
  106680. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  106681. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  106682. */
  106683. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106684. private _updateShaderUniforms;
  106685. protected _getDefines(): string;
  106686. /** Generate the current state of the procedural texture */
  106687. render(useCameraPostProcess?: boolean): void;
  106688. /**
  106689. * Serializes this noise procedural texture
  106690. * @returns a serialized noise procedural texture object
  106691. */
  106692. serialize(): any;
  106693. /**
  106694. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  106695. * @param parsedTexture defines parsed texture data
  106696. * @param scene defines the current scene
  106697. * @param rootUrl defines the root URL containing noise procedural texture information
  106698. * @returns a parsed NoiseProceduralTexture
  106699. */
  106700. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  106701. }
  106702. }
  106703. declare module BABYLON {
  106704. /**
  106705. * Raw cube texture where the raw buffers are passed in
  106706. */
  106707. export class RawCubeTexture extends CubeTexture {
  106708. /**
  106709. * Creates a cube texture where the raw buffers are passed in.
  106710. * @param scene defines the scene the texture is attached to
  106711. * @param data defines the array of data to use to create each face
  106712. * @param size defines the size of the textures
  106713. * @param format defines the format of the data
  106714. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106715. * @param generateMipMaps defines if the engine should generate the mip levels
  106716. * @param invertY defines if data must be stored with Y axis inverted
  106717. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106718. * @param compression defines the compression used (null by default)
  106719. */
  106720. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  106721. /**
  106722. * Updates the raw cube texture.
  106723. * @param data defines the data to store
  106724. * @param format defines the data format
  106725. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106726. * @param invertY defines if data must be stored with Y axis inverted
  106727. * @param compression defines the compression used (null by default)
  106728. * @param level defines which level of the texture to update
  106729. */
  106730. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  106731. /**
  106732. * Updates a raw cube texture with RGBD encoded data.
  106733. * @param data defines the array of data [mipmap][face] to use to create each face
  106734. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  106735. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  106736. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  106737. * @returns a promsie that resolves when the operation is complete
  106738. */
  106739. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  106740. /**
  106741. * Clones the raw cube texture.
  106742. * @return a new cube texture
  106743. */
  106744. clone(): CubeTexture;
  106745. /** @hidden */
  106746. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106747. }
  106748. }
  106749. declare module BABYLON {
  106750. /**
  106751. * Class used to store 3D textures containing user data
  106752. */
  106753. export class RawTexture3D extends Texture {
  106754. /** Gets or sets the texture format to use */
  106755. format: number;
  106756. private _engine;
  106757. /**
  106758. * Create a new RawTexture3D
  106759. * @param data defines the data of the texture
  106760. * @param width defines the width of the texture
  106761. * @param height defines the height of the texture
  106762. * @param depth defines the depth of the texture
  106763. * @param format defines the texture format to use
  106764. * @param scene defines the hosting scene
  106765. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  106766. * @param invertY defines if texture must be stored with Y axis inverted
  106767. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  106768. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  106769. */
  106770. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  106771. /** Gets or sets the texture format to use */
  106772. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  106773. /**
  106774. * Update the texture with new data
  106775. * @param data defines the data to store in the texture
  106776. */
  106777. update(data: ArrayBufferView): void;
  106778. }
  106779. }
  106780. declare module BABYLON {
  106781. /**
  106782. * Creates a refraction texture used by refraction channel of the standard material.
  106783. * It is like a mirror but to see through a material.
  106784. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106785. */
  106786. export class RefractionTexture extends RenderTargetTexture {
  106787. /**
  106788. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  106789. * 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.
  106790. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106791. */
  106792. refractionPlane: Plane;
  106793. /**
  106794. * Define how deep under the surface we should see.
  106795. */
  106796. depth: number;
  106797. /**
  106798. * Creates a refraction texture used by refraction channel of the standard material.
  106799. * It is like a mirror but to see through a material.
  106800. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106801. * @param name Define the texture name
  106802. * @param size Define the size of the underlying texture
  106803. * @param scene Define the scene the refraction belongs to
  106804. * @param generateMipMaps Define if we need to generate mips level for the refraction
  106805. */
  106806. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  106807. /**
  106808. * Clone the refraction texture.
  106809. * @returns the cloned texture
  106810. */
  106811. clone(): RefractionTexture;
  106812. /**
  106813. * Serialize the texture to a JSON representation you could use in Parse later on
  106814. * @returns the serialized JSON representation
  106815. */
  106816. serialize(): any;
  106817. }
  106818. }
  106819. declare module BABYLON {
  106820. /**
  106821. * Configuration for Draco compression
  106822. */
  106823. export interface IDracoCompressionConfiguration {
  106824. /**
  106825. * Configuration for the decoder.
  106826. */
  106827. decoder?: {
  106828. /**
  106829. * The url to the WebAssembly module.
  106830. */
  106831. wasmUrl?: string;
  106832. /**
  106833. * The url to the WebAssembly binary.
  106834. */
  106835. wasmBinaryUrl?: string;
  106836. /**
  106837. * The url to the fallback JavaScript module.
  106838. */
  106839. fallbackUrl?: string;
  106840. };
  106841. }
  106842. /**
  106843. * Draco compression (https://google.github.io/draco/)
  106844. *
  106845. * This class wraps the Draco module.
  106846. *
  106847. * **Encoder**
  106848. *
  106849. * The encoder is not currently implemented.
  106850. *
  106851. * **Decoder**
  106852. *
  106853. * 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.
  106854. *
  106855. * To update the configuration, use the following code:
  106856. * ```javascript
  106857. * DracoCompression.Configuration = {
  106858. * decoder: {
  106859. * wasmUrl: "<url to the WebAssembly library>",
  106860. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  106861. * fallbackUrl: "<url to the fallback JavaScript library>",
  106862. * }
  106863. * };
  106864. * ```
  106865. *
  106866. * 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.
  106867. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  106868. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  106869. *
  106870. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  106871. * ```javascript
  106872. * var dracoCompression = new DracoCompression();
  106873. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  106874. * [VertexBuffer.PositionKind]: 0
  106875. * });
  106876. * ```
  106877. *
  106878. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  106879. */
  106880. export class DracoCompression implements IDisposable {
  106881. private static _DecoderModulePromise;
  106882. /**
  106883. * The configuration. Defaults to the following urls:
  106884. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  106885. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  106886. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  106887. */
  106888. static Configuration: IDracoCompressionConfiguration;
  106889. /**
  106890. * Returns true if the decoder is available.
  106891. */
  106892. static readonly DecoderAvailable: boolean;
  106893. /**
  106894. * Constructor
  106895. */
  106896. constructor();
  106897. /**
  106898. * Stop all async operations and release resources.
  106899. */
  106900. dispose(): void;
  106901. /**
  106902. * Decode Draco compressed mesh data to vertex data.
  106903. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  106904. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  106905. * @returns A promise that resolves with the decoded vertex data
  106906. */
  106907. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  106908. [kind: string]: number;
  106909. }): Promise<VertexData>;
  106910. private static _GetDecoderModule;
  106911. private static _LoadScriptAsync;
  106912. private static _LoadFileAsync;
  106913. }
  106914. }
  106915. declare module BABYLON {
  106916. /**
  106917. * Class for building Constructive Solid Geometry
  106918. */
  106919. export class CSG {
  106920. private polygons;
  106921. /**
  106922. * The world matrix
  106923. */
  106924. matrix: Matrix;
  106925. /**
  106926. * Stores the position
  106927. */
  106928. position: Vector3;
  106929. /**
  106930. * Stores the rotation
  106931. */
  106932. rotation: Vector3;
  106933. /**
  106934. * Stores the rotation quaternion
  106935. */
  106936. rotationQuaternion: Nullable<Quaternion>;
  106937. /**
  106938. * Stores the scaling vector
  106939. */
  106940. scaling: Vector3;
  106941. /**
  106942. * Convert the Mesh to CSG
  106943. * @param mesh The Mesh to convert to CSG
  106944. * @returns A new CSG from the Mesh
  106945. */
  106946. static FromMesh(mesh: Mesh): CSG;
  106947. /**
  106948. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  106949. * @param polygons Polygons used to construct a CSG solid
  106950. */
  106951. private static FromPolygons;
  106952. /**
  106953. * Clones, or makes a deep copy, of the CSG
  106954. * @returns A new CSG
  106955. */
  106956. clone(): CSG;
  106957. /**
  106958. * Unions this CSG with another CSG
  106959. * @param csg The CSG to union against this CSG
  106960. * @returns The unioned CSG
  106961. */
  106962. union(csg: CSG): CSG;
  106963. /**
  106964. * Unions this CSG with another CSG in place
  106965. * @param csg The CSG to union against this CSG
  106966. */
  106967. unionInPlace(csg: CSG): void;
  106968. /**
  106969. * Subtracts this CSG with another CSG
  106970. * @param csg The CSG to subtract against this CSG
  106971. * @returns A new CSG
  106972. */
  106973. subtract(csg: CSG): CSG;
  106974. /**
  106975. * Subtracts this CSG with another CSG in place
  106976. * @param csg The CSG to subtact against this CSG
  106977. */
  106978. subtractInPlace(csg: CSG): void;
  106979. /**
  106980. * Intersect this CSG with another CSG
  106981. * @param csg The CSG to intersect against this CSG
  106982. * @returns A new CSG
  106983. */
  106984. intersect(csg: CSG): CSG;
  106985. /**
  106986. * Intersects this CSG with another CSG in place
  106987. * @param csg The CSG to intersect against this CSG
  106988. */
  106989. intersectInPlace(csg: CSG): void;
  106990. /**
  106991. * Return a new CSG solid with solid and empty space switched. This solid is
  106992. * not modified.
  106993. * @returns A new CSG solid with solid and empty space switched
  106994. */
  106995. inverse(): CSG;
  106996. /**
  106997. * Inverses the CSG in place
  106998. */
  106999. inverseInPlace(): void;
  107000. /**
  107001. * This is used to keep meshes transformations so they can be restored
  107002. * when we build back a Babylon Mesh
  107003. * NB : All CSG operations are performed in world coordinates
  107004. * @param csg The CSG to copy the transform attributes from
  107005. * @returns This CSG
  107006. */
  107007. copyTransformAttributes(csg: CSG): CSG;
  107008. /**
  107009. * Build Raw mesh from CSG
  107010. * Coordinates here are in world space
  107011. * @param name The name of the mesh geometry
  107012. * @param scene The Scene
  107013. * @param keepSubMeshes Specifies if the submeshes should be kept
  107014. * @returns A new Mesh
  107015. */
  107016. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  107017. /**
  107018. * Build Mesh from CSG taking material and transforms into account
  107019. * @param name The name of the Mesh
  107020. * @param material The material of the Mesh
  107021. * @param scene The Scene
  107022. * @param keepSubMeshes Specifies if submeshes should be kept
  107023. * @returns The new Mesh
  107024. */
  107025. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  107026. }
  107027. }
  107028. declare module BABYLON {
  107029. /**
  107030. * Class used to create a trail following a mesh
  107031. */
  107032. export class TrailMesh extends Mesh {
  107033. private _generator;
  107034. private _autoStart;
  107035. private _running;
  107036. private _diameter;
  107037. private _length;
  107038. private _sectionPolygonPointsCount;
  107039. private _sectionVectors;
  107040. private _sectionNormalVectors;
  107041. private _beforeRenderObserver;
  107042. /**
  107043. * @constructor
  107044. * @param name The value used by scene.getMeshByName() to do a lookup.
  107045. * @param generator The mesh to generate a trail.
  107046. * @param scene The scene to add this mesh to.
  107047. * @param diameter Diameter of trailing mesh. Default is 1.
  107048. * @param length Length of trailing mesh. Default is 60.
  107049. * @param autoStart Automatically start trailing mesh. Default true.
  107050. */
  107051. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  107052. /**
  107053. * "TrailMesh"
  107054. * @returns "TrailMesh"
  107055. */
  107056. getClassName(): string;
  107057. private _createMesh;
  107058. /**
  107059. * Start trailing mesh.
  107060. */
  107061. start(): void;
  107062. /**
  107063. * Stop trailing mesh.
  107064. */
  107065. stop(): void;
  107066. /**
  107067. * Update trailing mesh geometry.
  107068. */
  107069. update(): void;
  107070. /**
  107071. * Returns a new TrailMesh object.
  107072. * @param name is a string, the name given to the new mesh
  107073. * @param newGenerator use new generator object for cloned trail mesh
  107074. * @returns a new mesh
  107075. */
  107076. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  107077. /**
  107078. * Serializes this trail mesh
  107079. * @param serializationObject object to write serialization to
  107080. */
  107081. serialize(serializationObject: any): void;
  107082. /**
  107083. * Parses a serialized trail mesh
  107084. * @param parsedMesh the serialized mesh
  107085. * @param scene the scene to create the trail mesh in
  107086. * @returns the created trail mesh
  107087. */
  107088. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  107089. }
  107090. }
  107091. declare module BABYLON {
  107092. /**
  107093. * Class containing static functions to help procedurally build meshes
  107094. */
  107095. export class RibbonBuilder {
  107096. /**
  107097. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107098. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107099. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107100. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107101. * * 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
  107102. * * 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
  107103. * * 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
  107104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107106. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107107. * * 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
  107108. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107109. * * 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
  107110. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107112. * @param name defines the name of the mesh
  107113. * @param options defines the options used to create the mesh
  107114. * @param scene defines the hosting scene
  107115. * @returns the ribbon mesh
  107116. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107117. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107118. */
  107119. static CreateRibbon(name: string, options: {
  107120. pathArray: Vector3[][];
  107121. closeArray?: boolean;
  107122. closePath?: boolean;
  107123. offset?: number;
  107124. updatable?: boolean;
  107125. sideOrientation?: number;
  107126. frontUVs?: Vector4;
  107127. backUVs?: Vector4;
  107128. instance?: Mesh;
  107129. invertUV?: boolean;
  107130. uvs?: Vector2[];
  107131. colors?: Color4[];
  107132. }, scene?: Nullable<Scene>): Mesh;
  107133. }
  107134. }
  107135. declare module BABYLON {
  107136. /**
  107137. * Class containing static functions to help procedurally build meshes
  107138. */
  107139. export class TorusKnotBuilder {
  107140. /**
  107141. * Creates a torus knot mesh
  107142. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  107143. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  107144. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  107145. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  107146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107149. * @param name defines the name of the mesh
  107150. * @param options defines the options used to create the mesh
  107151. * @param scene defines the hosting scene
  107152. * @returns the torus knot mesh
  107153. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  107154. */
  107155. static CreateTorusKnot(name: string, options: {
  107156. radius?: number;
  107157. tube?: number;
  107158. radialSegments?: number;
  107159. tubularSegments?: number;
  107160. p?: number;
  107161. q?: number;
  107162. updatable?: boolean;
  107163. sideOrientation?: number;
  107164. frontUVs?: Vector4;
  107165. backUVs?: Vector4;
  107166. }, scene: any): Mesh;
  107167. }
  107168. }
  107169. declare module BABYLON {
  107170. /**
  107171. * Polygon
  107172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  107173. */
  107174. export class Polygon {
  107175. /**
  107176. * Creates a rectangle
  107177. * @param xmin bottom X coord
  107178. * @param ymin bottom Y coord
  107179. * @param xmax top X coord
  107180. * @param ymax top Y coord
  107181. * @returns points that make the resulting rectation
  107182. */
  107183. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  107184. /**
  107185. * Creates a circle
  107186. * @param radius radius of circle
  107187. * @param cx scale in x
  107188. * @param cy scale in y
  107189. * @param numberOfSides number of sides that make up the circle
  107190. * @returns points that make the resulting circle
  107191. */
  107192. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  107193. /**
  107194. * Creates a polygon from input string
  107195. * @param input Input polygon data
  107196. * @returns the parsed points
  107197. */
  107198. static Parse(input: string): Vector2[];
  107199. /**
  107200. * Starts building a polygon from x and y coordinates
  107201. * @param x x coordinate
  107202. * @param y y coordinate
  107203. * @returns the started path2
  107204. */
  107205. static StartingAt(x: number, y: number): Path2;
  107206. }
  107207. /**
  107208. * Builds a polygon
  107209. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  107210. */
  107211. export class PolygonMeshBuilder {
  107212. private _points;
  107213. private _outlinepoints;
  107214. private _holes;
  107215. private _name;
  107216. private _scene;
  107217. private _epoints;
  107218. private _eholes;
  107219. private _addToepoint;
  107220. /**
  107221. * Babylon reference to the earcut plugin.
  107222. */
  107223. bjsEarcut: any;
  107224. /**
  107225. * Creates a PolygonMeshBuilder
  107226. * @param name name of the builder
  107227. * @param contours Path of the polygon
  107228. * @param scene scene to add to when creating the mesh
  107229. * @param earcutInjection can be used to inject your own earcut reference
  107230. */
  107231. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  107232. /**
  107233. * Adds a whole within the polygon
  107234. * @param hole Array of points defining the hole
  107235. * @returns this
  107236. */
  107237. addHole(hole: Vector2[]): PolygonMeshBuilder;
  107238. /**
  107239. * Creates the polygon
  107240. * @param updatable If the mesh should be updatable
  107241. * @param depth The depth of the mesh created
  107242. * @returns the created mesh
  107243. */
  107244. build(updatable?: boolean, depth?: number): Mesh;
  107245. /**
  107246. * Creates the polygon
  107247. * @param depth The depth of the mesh created
  107248. * @returns the created VertexData
  107249. */
  107250. buildVertexData(depth?: number): VertexData;
  107251. /**
  107252. * Adds a side to the polygon
  107253. * @param positions points that make the polygon
  107254. * @param normals normals of the polygon
  107255. * @param uvs uvs of the polygon
  107256. * @param indices indices of the polygon
  107257. * @param bounds bounds of the polygon
  107258. * @param points points of the polygon
  107259. * @param depth depth of the polygon
  107260. * @param flip flip of the polygon
  107261. */
  107262. private addSide;
  107263. }
  107264. }
  107265. declare module BABYLON {
  107266. /**
  107267. * Class containing static functions to help procedurally build meshes
  107268. */
  107269. export class PolygonBuilder {
  107270. /**
  107271. * Creates a polygon mesh
  107272. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  107273. * * 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
  107274. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  107277. * * Remember you can only change the shape positions, not their number when updating a polygon
  107278. * @param name defines the name of the mesh
  107279. * @param options defines the options used to create the mesh
  107280. * @param scene defines the hosting scene
  107281. * @param earcutInjection can be used to inject your own earcut reference
  107282. * @returns the polygon mesh
  107283. */
  107284. static CreatePolygon(name: string, options: {
  107285. shape: Vector3[];
  107286. holes?: Vector3[][];
  107287. depth?: number;
  107288. faceUV?: Vector4[];
  107289. faceColors?: Color4[];
  107290. updatable?: boolean;
  107291. sideOrientation?: number;
  107292. frontUVs?: Vector4;
  107293. backUVs?: Vector4;
  107294. }, scene: Scene, earcutInjection?: any): Mesh;
  107295. /**
  107296. * Creates an extruded polygon mesh, with depth in the Y direction.
  107297. * * 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)
  107298. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107299. * @param name defines the name of the mesh
  107300. * @param options defines the options used to create the mesh
  107301. * @param scene defines the hosting scene
  107302. * @param earcutInjection can be used to inject your own earcut reference
  107303. * @returns the polygon mesh
  107304. */
  107305. static ExtrudePolygon(name: string, options: {
  107306. shape: Vector3[];
  107307. holes?: Vector3[][];
  107308. depth?: number;
  107309. faceUV?: Vector4[];
  107310. faceColors?: Color4[];
  107311. updatable?: boolean;
  107312. sideOrientation?: number;
  107313. frontUVs?: Vector4;
  107314. backUVs?: Vector4;
  107315. }, scene: Scene, earcutInjection?: any): Mesh;
  107316. }
  107317. }
  107318. declare module BABYLON {
  107319. /**
  107320. * Class containing static functions to help procedurally build meshes
  107321. */
  107322. export class ShapeBuilder {
  107323. /**
  107324. * 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.
  107325. * * 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.
  107326. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107327. * * 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.
  107328. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107329. * * 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
  107330. * * 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
  107331. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107336. * @param name defines the name of the mesh
  107337. * @param options defines the options used to create the mesh
  107338. * @param scene defines the hosting scene
  107339. * @returns the extruded shape mesh
  107340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107342. */
  107343. static ExtrudeShape(name: string, options: {
  107344. shape: Vector3[];
  107345. path: Vector3[];
  107346. scale?: number;
  107347. rotation?: number;
  107348. cap?: number;
  107349. updatable?: boolean;
  107350. sideOrientation?: number;
  107351. frontUVs?: Vector4;
  107352. backUVs?: Vector4;
  107353. instance?: Mesh;
  107354. invertUV?: boolean;
  107355. }, scene?: Nullable<Scene>): Mesh;
  107356. /**
  107357. * Creates an custom extruded shape mesh.
  107358. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107359. * * 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.
  107360. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107361. * * 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
  107362. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107363. * * 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
  107364. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107365. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107366. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107367. * * 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
  107368. * * 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
  107369. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107374. * @param name defines the name of the mesh
  107375. * @param options defines the options used to create the mesh
  107376. * @param scene defines the hosting scene
  107377. * @returns the custom extruded shape mesh
  107378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107381. */
  107382. static ExtrudeShapeCustom(name: string, options: {
  107383. shape: Vector3[];
  107384. path: Vector3[];
  107385. scaleFunction?: any;
  107386. rotationFunction?: any;
  107387. ribbonCloseArray?: boolean;
  107388. ribbonClosePath?: boolean;
  107389. cap?: number;
  107390. updatable?: boolean;
  107391. sideOrientation?: number;
  107392. frontUVs?: Vector4;
  107393. backUVs?: Vector4;
  107394. instance?: Mesh;
  107395. invertUV?: boolean;
  107396. }, scene: Scene): Mesh;
  107397. private static _ExtrudeShapeGeneric;
  107398. }
  107399. }
  107400. declare module BABYLON {
  107401. /**
  107402. * Class containing static functions to help procedurally build meshes
  107403. */
  107404. export class LatheBuilder {
  107405. /**
  107406. * Creates lathe mesh.
  107407. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107408. * * 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
  107409. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107410. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107411. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107412. * * 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
  107413. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107414. * * 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
  107415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107417. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107419. * @param name defines the name of the mesh
  107420. * @param options defines the options used to create the mesh
  107421. * @param scene defines the hosting scene
  107422. * @returns the lathe mesh
  107423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107424. */
  107425. static CreateLathe(name: string, options: {
  107426. shape: Vector3[];
  107427. radius?: number;
  107428. tessellation?: number;
  107429. clip?: number;
  107430. arc?: number;
  107431. closed?: boolean;
  107432. updatable?: boolean;
  107433. sideOrientation?: number;
  107434. frontUVs?: Vector4;
  107435. backUVs?: Vector4;
  107436. cap?: number;
  107437. invertUV?: boolean;
  107438. }, scene: Scene): Mesh;
  107439. }
  107440. }
  107441. declare module BABYLON {
  107442. /**
  107443. * Class containing static functions to help procedurally build meshes
  107444. */
  107445. export class TubeBuilder {
  107446. /**
  107447. * Creates a tube mesh.
  107448. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107449. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107450. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107451. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107452. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107453. * * 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)
  107454. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107455. * * 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
  107456. * * 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
  107457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107461. * @param name defines the name of the mesh
  107462. * @param options defines the options used to create the mesh
  107463. * @param scene defines the hosting scene
  107464. * @returns the tube mesh
  107465. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107466. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107467. */
  107468. static CreateTube(name: string, options: {
  107469. path: Vector3[];
  107470. radius?: number;
  107471. tessellation?: number;
  107472. radiusFunction?: {
  107473. (i: number, distance: number): number;
  107474. };
  107475. cap?: number;
  107476. arc?: number;
  107477. updatable?: boolean;
  107478. sideOrientation?: number;
  107479. frontUVs?: Vector4;
  107480. backUVs?: Vector4;
  107481. instance?: Mesh;
  107482. invertUV?: boolean;
  107483. }, scene: Scene): Mesh;
  107484. }
  107485. }
  107486. declare module BABYLON {
  107487. /**
  107488. * Class containing static functions to help procedurally build meshes
  107489. */
  107490. export class IcoSphereBuilder {
  107491. /**
  107492. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107493. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107494. * * 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`)
  107495. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107496. * * 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
  107497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107500. * @param name defines the name of the mesh
  107501. * @param options defines the options used to create the mesh
  107502. * @param scene defines the hosting scene
  107503. * @returns the icosahedron mesh
  107504. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107505. */
  107506. static CreateIcoSphere(name: string, options: {
  107507. radius?: number;
  107508. radiusX?: number;
  107509. radiusY?: number;
  107510. radiusZ?: number;
  107511. flat?: boolean;
  107512. subdivisions?: number;
  107513. sideOrientation?: number;
  107514. frontUVs?: Vector4;
  107515. backUVs?: Vector4;
  107516. updatable?: boolean;
  107517. }, scene: Scene): Mesh;
  107518. }
  107519. }
  107520. declare module BABYLON {
  107521. /**
  107522. * Class containing static functions to help procedurally build meshes
  107523. */
  107524. export class DecalBuilder {
  107525. /**
  107526. * Creates a decal mesh.
  107527. * 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
  107528. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107529. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107530. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107531. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107532. * @param name defines the name of the mesh
  107533. * @param sourceMesh defines the mesh where the decal must be applied
  107534. * @param options defines the options used to create the mesh
  107535. * @param scene defines the hosting scene
  107536. * @returns the decal mesh
  107537. * @see https://doc.babylonjs.com/how_to/decals
  107538. */
  107539. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107540. position?: Vector3;
  107541. normal?: Vector3;
  107542. size?: Vector3;
  107543. angle?: number;
  107544. }): Mesh;
  107545. }
  107546. }
  107547. declare module BABYLON {
  107548. /**
  107549. * Class containing static functions to help procedurally build meshes
  107550. */
  107551. export class MeshBuilder {
  107552. /**
  107553. * Creates a box mesh
  107554. * * The parameter `size` sets the size (float) of each box side (default 1)
  107555. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107556. * * 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)
  107557. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107561. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107562. * @param name defines the name of the mesh
  107563. * @param options defines the options used to create the mesh
  107564. * @param scene defines the hosting scene
  107565. * @returns the box mesh
  107566. */
  107567. static CreateBox(name: string, options: {
  107568. size?: number;
  107569. width?: number;
  107570. height?: number;
  107571. depth?: number;
  107572. faceUV?: Vector4[];
  107573. faceColors?: Color4[];
  107574. sideOrientation?: number;
  107575. frontUVs?: Vector4;
  107576. backUVs?: Vector4;
  107577. updatable?: boolean;
  107578. }, scene?: Nullable<Scene>): Mesh;
  107579. /**
  107580. * Creates a sphere mesh
  107581. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107582. * * 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`)
  107583. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107584. * * 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
  107585. * * 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)
  107586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107589. * @param name defines the name of the mesh
  107590. * @param options defines the options used to create the mesh
  107591. * @param scene defines the hosting scene
  107592. * @returns the sphere mesh
  107593. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107594. */
  107595. static CreateSphere(name: string, options: {
  107596. segments?: number;
  107597. diameter?: number;
  107598. diameterX?: number;
  107599. diameterY?: number;
  107600. diameterZ?: number;
  107601. arc?: number;
  107602. slice?: number;
  107603. sideOrientation?: number;
  107604. frontUVs?: Vector4;
  107605. backUVs?: Vector4;
  107606. updatable?: boolean;
  107607. }, scene: any): Mesh;
  107608. /**
  107609. * Creates a plane polygonal mesh. By default, this is a disc
  107610. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107611. * * 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
  107612. * * 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
  107613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107616. * @param name defines the name of the mesh
  107617. * @param options defines the options used to create the mesh
  107618. * @param scene defines the hosting scene
  107619. * @returns the plane polygonal mesh
  107620. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107621. */
  107622. static CreateDisc(name: string, options: {
  107623. radius?: number;
  107624. tessellation?: number;
  107625. arc?: number;
  107626. updatable?: boolean;
  107627. sideOrientation?: number;
  107628. frontUVs?: Vector4;
  107629. backUVs?: Vector4;
  107630. }, scene?: Nullable<Scene>): Mesh;
  107631. /**
  107632. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107633. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107634. * * 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`)
  107635. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107636. * * 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
  107637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107640. * @param name defines the name of the mesh
  107641. * @param options defines the options used to create the mesh
  107642. * @param scene defines the hosting scene
  107643. * @returns the icosahedron mesh
  107644. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107645. */
  107646. static CreateIcoSphere(name: string, options: {
  107647. radius?: number;
  107648. radiusX?: number;
  107649. radiusY?: number;
  107650. radiusZ?: number;
  107651. flat?: boolean;
  107652. subdivisions?: number;
  107653. sideOrientation?: number;
  107654. frontUVs?: Vector4;
  107655. backUVs?: Vector4;
  107656. updatable?: boolean;
  107657. }, scene: Scene): Mesh;
  107658. /**
  107659. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107660. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107661. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107662. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107663. * * 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
  107664. * * 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
  107665. * * 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
  107666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107668. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107669. * * 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
  107670. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107671. * * 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
  107672. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107674. * @param name defines the name of the mesh
  107675. * @param options defines the options used to create the mesh
  107676. * @param scene defines the hosting scene
  107677. * @returns the ribbon mesh
  107678. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107679. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107680. */
  107681. static CreateRibbon(name: string, options: {
  107682. pathArray: Vector3[][];
  107683. closeArray?: boolean;
  107684. closePath?: boolean;
  107685. offset?: number;
  107686. updatable?: boolean;
  107687. sideOrientation?: number;
  107688. frontUVs?: Vector4;
  107689. backUVs?: Vector4;
  107690. instance?: Mesh;
  107691. invertUV?: boolean;
  107692. uvs?: Vector2[];
  107693. colors?: Color4[];
  107694. }, scene?: Nullable<Scene>): Mesh;
  107695. /**
  107696. * Creates a cylinder or a cone mesh
  107697. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107698. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107699. * * 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.
  107700. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107701. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107702. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107703. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107704. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107705. * * 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).
  107706. * * 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
  107707. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107708. * * 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
  107709. * * 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.
  107710. * * If `enclose` is false, a ring surface is one element.
  107711. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107712. * * 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
  107713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107716. * @param name defines the name of the mesh
  107717. * @param options defines the options used to create the mesh
  107718. * @param scene defines the hosting scene
  107719. * @returns the cylinder mesh
  107720. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107721. */
  107722. static CreateCylinder(name: string, options: {
  107723. height?: number;
  107724. diameterTop?: number;
  107725. diameterBottom?: number;
  107726. diameter?: number;
  107727. tessellation?: number;
  107728. subdivisions?: number;
  107729. arc?: number;
  107730. faceColors?: Color4[];
  107731. faceUV?: Vector4[];
  107732. updatable?: boolean;
  107733. hasRings?: boolean;
  107734. enclose?: boolean;
  107735. sideOrientation?: number;
  107736. frontUVs?: Vector4;
  107737. backUVs?: Vector4;
  107738. }, scene: any): Mesh;
  107739. /**
  107740. * Creates a torus mesh
  107741. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107742. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107743. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107747. * @param name defines the name of the mesh
  107748. * @param options defines the options used to create the mesh
  107749. * @param scene defines the hosting scene
  107750. * @returns the torus mesh
  107751. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107752. */
  107753. static CreateTorus(name: string, options: {
  107754. diameter?: number;
  107755. thickness?: number;
  107756. tessellation?: number;
  107757. updatable?: boolean;
  107758. sideOrientation?: number;
  107759. frontUVs?: Vector4;
  107760. backUVs?: Vector4;
  107761. }, scene: any): Mesh;
  107762. /**
  107763. * Creates a torus knot mesh
  107764. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  107765. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  107766. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  107767. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  107768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107771. * @param name defines the name of the mesh
  107772. * @param options defines the options used to create the mesh
  107773. * @param scene defines the hosting scene
  107774. * @returns the torus knot mesh
  107775. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  107776. */
  107777. static CreateTorusKnot(name: string, options: {
  107778. radius?: number;
  107779. tube?: number;
  107780. radialSegments?: number;
  107781. tubularSegments?: number;
  107782. p?: number;
  107783. q?: number;
  107784. updatable?: boolean;
  107785. sideOrientation?: number;
  107786. frontUVs?: Vector4;
  107787. backUVs?: Vector4;
  107788. }, scene: any): Mesh;
  107789. /**
  107790. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107791. * * 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
  107792. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107793. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107794. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107795. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107796. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107797. * * 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
  107798. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107801. * @param name defines the name of the new line system
  107802. * @param options defines the options used to create the line system
  107803. * @param scene defines the hosting scene
  107804. * @returns a new line system mesh
  107805. */
  107806. static CreateLineSystem(name: string, options: {
  107807. lines: Vector3[][];
  107808. updatable?: boolean;
  107809. instance?: Nullable<LinesMesh>;
  107810. colors?: Nullable<Color4[][]>;
  107811. useVertexAlpha?: boolean;
  107812. }, scene: Nullable<Scene>): LinesMesh;
  107813. /**
  107814. * Creates a line mesh
  107815. * 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
  107816. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107817. * * The parameter `points` is an array successive Vector3
  107818. * * 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
  107819. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107820. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107821. * * When updating an instance, remember that only point positions can change, not the number of points
  107822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107824. * @param name defines the name of the new line system
  107825. * @param options defines the options used to create the line system
  107826. * @param scene defines the hosting scene
  107827. * @returns a new line mesh
  107828. */
  107829. static CreateLines(name: string, options: {
  107830. points: Vector3[];
  107831. updatable?: boolean;
  107832. instance?: Nullable<LinesMesh>;
  107833. colors?: Color4[];
  107834. useVertexAlpha?: boolean;
  107835. }, scene?: Nullable<Scene>): LinesMesh;
  107836. /**
  107837. * Creates a dashed line mesh
  107838. * * 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
  107839. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107840. * * The parameter `points` is an array successive Vector3
  107841. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107842. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107843. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107844. * * 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
  107845. * * When updating an instance, remember that only point positions can change, not the number of points
  107846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107847. * @param name defines the name of the mesh
  107848. * @param options defines the options used to create the mesh
  107849. * @param scene defines the hosting scene
  107850. * @returns the dashed line mesh
  107851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107852. */
  107853. static CreateDashedLines(name: string, options: {
  107854. points: Vector3[];
  107855. dashSize?: number;
  107856. gapSize?: number;
  107857. dashNb?: number;
  107858. updatable?: boolean;
  107859. instance?: LinesMesh;
  107860. }, scene?: Nullable<Scene>): LinesMesh;
  107861. /**
  107862. * 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.
  107863. * * 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.
  107864. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107865. * * 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.
  107866. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107867. * * 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
  107868. * * 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
  107869. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107872. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107874. * @param name defines the name of the mesh
  107875. * @param options defines the options used to create the mesh
  107876. * @param scene defines the hosting scene
  107877. * @returns the extruded shape mesh
  107878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107880. */
  107881. static ExtrudeShape(name: string, options: {
  107882. shape: Vector3[];
  107883. path: Vector3[];
  107884. scale?: number;
  107885. rotation?: number;
  107886. cap?: number;
  107887. updatable?: boolean;
  107888. sideOrientation?: number;
  107889. frontUVs?: Vector4;
  107890. backUVs?: Vector4;
  107891. instance?: Mesh;
  107892. invertUV?: boolean;
  107893. }, scene?: Nullable<Scene>): Mesh;
  107894. /**
  107895. * Creates an custom extruded shape mesh.
  107896. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107897. * * 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.
  107898. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107899. * * 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
  107900. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107901. * * 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
  107902. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107903. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107904. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107905. * * 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
  107906. * * 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
  107907. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107912. * @param name defines the name of the mesh
  107913. * @param options defines the options used to create the mesh
  107914. * @param scene defines the hosting scene
  107915. * @returns the custom extruded shape mesh
  107916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107917. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107919. */
  107920. static ExtrudeShapeCustom(name: string, options: {
  107921. shape: Vector3[];
  107922. path: Vector3[];
  107923. scaleFunction?: any;
  107924. rotationFunction?: any;
  107925. ribbonCloseArray?: boolean;
  107926. ribbonClosePath?: boolean;
  107927. cap?: number;
  107928. updatable?: boolean;
  107929. sideOrientation?: number;
  107930. frontUVs?: Vector4;
  107931. backUVs?: Vector4;
  107932. instance?: Mesh;
  107933. invertUV?: boolean;
  107934. }, scene: Scene): Mesh;
  107935. /**
  107936. * Creates lathe mesh.
  107937. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107938. * * 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
  107939. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107940. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107941. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107942. * * 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
  107943. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107944. * * 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
  107945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107947. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107949. * @param name defines the name of the mesh
  107950. * @param options defines the options used to create the mesh
  107951. * @param scene defines the hosting scene
  107952. * @returns the lathe mesh
  107953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107954. */
  107955. static CreateLathe(name: string, options: {
  107956. shape: Vector3[];
  107957. radius?: number;
  107958. tessellation?: number;
  107959. clip?: number;
  107960. arc?: number;
  107961. closed?: boolean;
  107962. updatable?: boolean;
  107963. sideOrientation?: number;
  107964. frontUVs?: Vector4;
  107965. backUVs?: Vector4;
  107966. cap?: number;
  107967. invertUV?: boolean;
  107968. }, scene: Scene): Mesh;
  107969. /**
  107970. * Creates a plane mesh
  107971. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107972. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107973. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107977. * @param name defines the name of the mesh
  107978. * @param options defines the options used to create the mesh
  107979. * @param scene defines the hosting scene
  107980. * @returns the plane mesh
  107981. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107982. */
  107983. static CreatePlane(name: string, options: {
  107984. size?: number;
  107985. width?: number;
  107986. height?: number;
  107987. sideOrientation?: number;
  107988. frontUVs?: Vector4;
  107989. backUVs?: Vector4;
  107990. updatable?: boolean;
  107991. sourcePlane?: Plane;
  107992. }, scene: Scene): Mesh;
  107993. /**
  107994. * Creates a ground mesh
  107995. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107996. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107998. * @param name defines the name of the mesh
  107999. * @param options defines the options used to create the mesh
  108000. * @param scene defines the hosting scene
  108001. * @returns the ground mesh
  108002. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  108003. */
  108004. static CreateGround(name: string, options: {
  108005. width?: number;
  108006. height?: number;
  108007. subdivisions?: number;
  108008. subdivisionsX?: number;
  108009. subdivisionsY?: number;
  108010. updatable?: boolean;
  108011. }, scene: any): Mesh;
  108012. /**
  108013. * Creates a tiled ground mesh
  108014. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  108015. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  108016. * * 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
  108017. * * 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
  108018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108019. * @param name defines the name of the mesh
  108020. * @param options defines the options used to create the mesh
  108021. * @param scene defines the hosting scene
  108022. * @returns the tiled ground mesh
  108023. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  108024. */
  108025. static CreateTiledGround(name: string, options: {
  108026. xmin: number;
  108027. zmin: number;
  108028. xmax: number;
  108029. zmax: number;
  108030. subdivisions?: {
  108031. w: number;
  108032. h: number;
  108033. };
  108034. precision?: {
  108035. w: number;
  108036. h: number;
  108037. };
  108038. updatable?: boolean;
  108039. }, scene: Scene): Mesh;
  108040. /**
  108041. * Creates a ground mesh from a height map
  108042. * * The parameter `url` sets the URL of the height map image resource.
  108043. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  108044. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  108045. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  108046. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  108047. * * 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.
  108048. * * 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).
  108049. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108051. * @param name defines the name of the mesh
  108052. * @param url defines the url to the height map
  108053. * @param options defines the options used to create the mesh
  108054. * @param scene defines the hosting scene
  108055. * @returns the ground mesh
  108056. * @see https://doc.babylonjs.com/babylon101/height_map
  108057. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  108058. */
  108059. static CreateGroundFromHeightMap(name: string, url: string, options: {
  108060. width?: number;
  108061. height?: number;
  108062. subdivisions?: number;
  108063. minHeight?: number;
  108064. maxHeight?: number;
  108065. colorFilter?: Color3;
  108066. alphaFilter?: number;
  108067. updatable?: boolean;
  108068. onReady?: (mesh: GroundMesh) => void;
  108069. }, scene: Scene): GroundMesh;
  108070. /**
  108071. * Creates a polygon mesh
  108072. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  108073. * * 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
  108074. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  108077. * * Remember you can only change the shape positions, not their number when updating a polygon
  108078. * @param name defines the name of the mesh
  108079. * @param options defines the options used to create the mesh
  108080. * @param scene defines the hosting scene
  108081. * @param earcutInjection can be used to inject your own earcut reference
  108082. * @returns the polygon mesh
  108083. */
  108084. static CreatePolygon(name: string, options: {
  108085. shape: Vector3[];
  108086. holes?: Vector3[][];
  108087. depth?: number;
  108088. faceUV?: Vector4[];
  108089. faceColors?: Color4[];
  108090. updatable?: boolean;
  108091. sideOrientation?: number;
  108092. frontUVs?: Vector4;
  108093. backUVs?: Vector4;
  108094. }, scene: Scene, earcutInjection?: any): Mesh;
  108095. /**
  108096. * Creates an extruded polygon mesh, with depth in the Y direction.
  108097. * * 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)
  108098. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108099. * @param name defines the name of the mesh
  108100. * @param options defines the options used to create the mesh
  108101. * @param scene defines the hosting scene
  108102. * @param earcutInjection can be used to inject your own earcut reference
  108103. * @returns the polygon mesh
  108104. */
  108105. static ExtrudePolygon(name: string, options: {
  108106. shape: Vector3[];
  108107. holes?: Vector3[][];
  108108. depth?: number;
  108109. faceUV?: Vector4[];
  108110. faceColors?: Color4[];
  108111. updatable?: boolean;
  108112. sideOrientation?: number;
  108113. frontUVs?: Vector4;
  108114. backUVs?: Vector4;
  108115. }, scene: Scene, earcutInjection?: any): Mesh;
  108116. /**
  108117. * Creates a tube mesh.
  108118. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108119. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  108120. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  108121. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  108122. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  108123. * * 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)
  108124. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  108125. * * 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
  108126. * * 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
  108127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108131. * @param name defines the name of the mesh
  108132. * @param options defines the options used to create the mesh
  108133. * @param scene defines the hosting scene
  108134. * @returns the tube mesh
  108135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108136. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  108137. */
  108138. static CreateTube(name: string, options: {
  108139. path: Vector3[];
  108140. radius?: number;
  108141. tessellation?: number;
  108142. radiusFunction?: {
  108143. (i: number, distance: number): number;
  108144. };
  108145. cap?: number;
  108146. arc?: number;
  108147. updatable?: boolean;
  108148. sideOrientation?: number;
  108149. frontUVs?: Vector4;
  108150. backUVs?: Vector4;
  108151. instance?: Mesh;
  108152. invertUV?: boolean;
  108153. }, scene: Scene): Mesh;
  108154. /**
  108155. * Creates a polyhedron mesh
  108156. * * 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
  108157. * * The parameter `size` (positive float, default 1) sets the polygon size
  108158. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108159. * * 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`
  108160. * * 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
  108161. * * 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)`)
  108162. * * 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
  108163. * * 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
  108164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108167. * @param name defines the name of the mesh
  108168. * @param options defines the options used to create the mesh
  108169. * @param scene defines the hosting scene
  108170. * @returns the polyhedron mesh
  108171. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  108172. */
  108173. static CreatePolyhedron(name: string, options: {
  108174. type?: number;
  108175. size?: number;
  108176. sizeX?: number;
  108177. sizeY?: number;
  108178. sizeZ?: number;
  108179. custom?: any;
  108180. faceUV?: Vector4[];
  108181. faceColors?: Color4[];
  108182. flat?: boolean;
  108183. updatable?: boolean;
  108184. sideOrientation?: number;
  108185. frontUVs?: Vector4;
  108186. backUVs?: Vector4;
  108187. }, scene: Scene): Mesh;
  108188. /**
  108189. * Creates a decal mesh.
  108190. * 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
  108191. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  108192. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  108193. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  108194. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  108195. * @param name defines the name of the mesh
  108196. * @param sourceMesh defines the mesh where the decal must be applied
  108197. * @param options defines the options used to create the mesh
  108198. * @param scene defines the hosting scene
  108199. * @returns the decal mesh
  108200. * @see https://doc.babylonjs.com/how_to/decals
  108201. */
  108202. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  108203. position?: Vector3;
  108204. normal?: Vector3;
  108205. size?: Vector3;
  108206. angle?: number;
  108207. }): Mesh;
  108208. }
  108209. }
  108210. declare module BABYLON {
  108211. /**
  108212. * A simplifier interface for future simplification implementations
  108213. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108214. */
  108215. export interface ISimplifier {
  108216. /**
  108217. * Simplification of a given mesh according to the given settings.
  108218. * Since this requires computation, it is assumed that the function runs async.
  108219. * @param settings The settings of the simplification, including quality and distance
  108220. * @param successCallback A callback that will be called after the mesh was simplified.
  108221. * @param errorCallback in case of an error, this callback will be called. optional.
  108222. */
  108223. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  108224. }
  108225. /**
  108226. * Expected simplification settings.
  108227. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  108228. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108229. */
  108230. export interface ISimplificationSettings {
  108231. /**
  108232. * Gets or sets the expected quality
  108233. */
  108234. quality: number;
  108235. /**
  108236. * Gets or sets the distance when this optimized version should be used
  108237. */
  108238. distance: number;
  108239. /**
  108240. * Gets an already optimized mesh
  108241. */
  108242. optimizeMesh?: boolean;
  108243. }
  108244. /**
  108245. * Class used to specify simplification options
  108246. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108247. */
  108248. export class SimplificationSettings implements ISimplificationSettings {
  108249. /** expected quality */
  108250. quality: number;
  108251. /** distance when this optimized version should be used */
  108252. distance: number;
  108253. /** already optimized mesh */
  108254. optimizeMesh?: boolean | undefined;
  108255. /**
  108256. * Creates a SimplificationSettings
  108257. * @param quality expected quality
  108258. * @param distance distance when this optimized version should be used
  108259. * @param optimizeMesh already optimized mesh
  108260. */
  108261. constructor(
  108262. /** expected quality */
  108263. quality: number,
  108264. /** distance when this optimized version should be used */
  108265. distance: number,
  108266. /** already optimized mesh */
  108267. optimizeMesh?: boolean | undefined);
  108268. }
  108269. /**
  108270. * Interface used to define a simplification task
  108271. */
  108272. export interface ISimplificationTask {
  108273. /**
  108274. * Array of settings
  108275. */
  108276. settings: Array<ISimplificationSettings>;
  108277. /**
  108278. * Simplification type
  108279. */
  108280. simplificationType: SimplificationType;
  108281. /**
  108282. * Mesh to simplify
  108283. */
  108284. mesh: Mesh;
  108285. /**
  108286. * Callback called on success
  108287. */
  108288. successCallback?: () => void;
  108289. /**
  108290. * Defines if parallel processing can be used
  108291. */
  108292. parallelProcessing: boolean;
  108293. }
  108294. /**
  108295. * Queue used to order the simplification tasks
  108296. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108297. */
  108298. export class SimplificationQueue {
  108299. private _simplificationArray;
  108300. /**
  108301. * Gets a boolean indicating that the process is still running
  108302. */
  108303. running: boolean;
  108304. /**
  108305. * Creates a new queue
  108306. */
  108307. constructor();
  108308. /**
  108309. * Adds a new simplification task
  108310. * @param task defines a task to add
  108311. */
  108312. addTask(task: ISimplificationTask): void;
  108313. /**
  108314. * Execute next task
  108315. */
  108316. executeNext(): void;
  108317. /**
  108318. * Execute a simplification task
  108319. * @param task defines the task to run
  108320. */
  108321. runSimplification(task: ISimplificationTask): void;
  108322. private getSimplifier;
  108323. }
  108324. /**
  108325. * The implemented types of simplification
  108326. * At the moment only Quadratic Error Decimation is implemented
  108327. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108328. */
  108329. export enum SimplificationType {
  108330. /** Quadratic error decimation */
  108331. QUADRATIC = 0
  108332. }
  108333. }
  108334. declare module BABYLON {
  108335. interface Scene {
  108336. /** @hidden (Backing field) */
  108337. _simplificationQueue: SimplificationQueue;
  108338. /**
  108339. * Gets or sets the simplification queue attached to the scene
  108340. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108341. */
  108342. simplificationQueue: SimplificationQueue;
  108343. }
  108344. interface Mesh {
  108345. /**
  108346. * Simplify the mesh according to the given array of settings.
  108347. * Function will return immediately and will simplify async
  108348. * @param settings a collection of simplification settings
  108349. * @param parallelProcessing should all levels calculate parallel or one after the other
  108350. * @param simplificationType the type of simplification to run
  108351. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  108352. * @returns the current mesh
  108353. */
  108354. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  108355. }
  108356. /**
  108357. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  108358. * created in a scene
  108359. */
  108360. export class SimplicationQueueSceneComponent implements ISceneComponent {
  108361. /**
  108362. * The component name helpfull to identify the component in the list of scene components.
  108363. */
  108364. readonly name: string;
  108365. /**
  108366. * The scene the component belongs to.
  108367. */
  108368. scene: Scene;
  108369. /**
  108370. * Creates a new instance of the component for the given scene
  108371. * @param scene Defines the scene to register the component in
  108372. */
  108373. constructor(scene: Scene);
  108374. /**
  108375. * Registers the component in a given scene
  108376. */
  108377. register(): void;
  108378. /**
  108379. * Rebuilds the elements related to this component in case of
  108380. * context lost for instance.
  108381. */
  108382. rebuild(): void;
  108383. /**
  108384. * Disposes the component and the associated ressources
  108385. */
  108386. dispose(): void;
  108387. private _beforeCameraUpdate;
  108388. }
  108389. }
  108390. declare module BABYLON {
  108391. /**
  108392. * Class used to enable access to IndexedDB
  108393. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108394. */
  108395. export class Database implements IOfflineProvider {
  108396. private _callbackManifestChecked;
  108397. private _currentSceneUrl;
  108398. private _db;
  108399. private _enableSceneOffline;
  108400. private _enableTexturesOffline;
  108401. private _manifestVersionFound;
  108402. private _mustUpdateRessources;
  108403. private _hasReachedQuota;
  108404. private _isSupported;
  108405. private _idbFactory;
  108406. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  108407. private static IsUASupportingBlobStorage;
  108408. /**
  108409. * Gets a boolean indicating if Database storate is enabled (off by default)
  108410. */
  108411. static IDBStorageEnabled: boolean;
  108412. /**
  108413. * Gets a boolean indicating if scene must be saved in the database
  108414. */
  108415. readonly enableSceneOffline: boolean;
  108416. /**
  108417. * Gets a boolean indicating if textures must be saved in the database
  108418. */
  108419. readonly enableTexturesOffline: boolean;
  108420. /**
  108421. * Creates a new Database
  108422. * @param urlToScene defines the url to load the scene
  108423. * @param callbackManifestChecked defines the callback to use when manifest is checked
  108424. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  108425. */
  108426. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  108427. private static _ParseURL;
  108428. private static _ReturnFullUrlLocation;
  108429. private _checkManifestFile;
  108430. /**
  108431. * Open the database and make it available
  108432. * @param successCallback defines the callback to call on success
  108433. * @param errorCallback defines the callback to call on error
  108434. */
  108435. open(successCallback: () => void, errorCallback: () => void): void;
  108436. /**
  108437. * Loads an image from the database
  108438. * @param url defines the url to load from
  108439. * @param image defines the target DOM image
  108440. */
  108441. loadImage(url: string, image: HTMLImageElement): void;
  108442. private _loadImageFromDBAsync;
  108443. private _saveImageIntoDBAsync;
  108444. private _checkVersionFromDB;
  108445. private _loadVersionFromDBAsync;
  108446. private _saveVersionIntoDBAsync;
  108447. /**
  108448. * Loads a file from database
  108449. * @param url defines the URL to load from
  108450. * @param sceneLoaded defines a callback to call on success
  108451. * @param progressCallBack defines a callback to call when progress changed
  108452. * @param errorCallback defines a callback to call on error
  108453. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  108454. */
  108455. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  108456. private _loadFileAsync;
  108457. private _saveFileAsync;
  108458. /**
  108459. * Validates if xhr data is correct
  108460. * @param xhr defines the request to validate
  108461. * @param dataType defines the expected data type
  108462. * @returns true if data is correct
  108463. */
  108464. private static _ValidateXHRData;
  108465. }
  108466. }
  108467. declare module BABYLON {
  108468. /** @hidden */
  108469. export var gpuUpdateParticlesPixelShader: {
  108470. name: string;
  108471. shader: string;
  108472. };
  108473. }
  108474. declare module BABYLON {
  108475. /** @hidden */
  108476. export var gpuUpdateParticlesVertexShader: {
  108477. name: string;
  108478. shader: string;
  108479. };
  108480. }
  108481. declare module BABYLON {
  108482. /** @hidden */
  108483. export var clipPlaneFragmentDeclaration2: {
  108484. name: string;
  108485. shader: string;
  108486. };
  108487. }
  108488. declare module BABYLON {
  108489. /** @hidden */
  108490. export var gpuRenderParticlesPixelShader: {
  108491. name: string;
  108492. shader: string;
  108493. };
  108494. }
  108495. declare module BABYLON {
  108496. /** @hidden */
  108497. export var clipPlaneVertexDeclaration2: {
  108498. name: string;
  108499. shader: string;
  108500. };
  108501. }
  108502. declare module BABYLON {
  108503. /** @hidden */
  108504. export var gpuRenderParticlesVertexShader: {
  108505. name: string;
  108506. shader: string;
  108507. };
  108508. }
  108509. declare module BABYLON {
  108510. /**
  108511. * This represents a GPU particle system in Babylon
  108512. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  108513. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  108514. */
  108515. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  108516. /**
  108517. * The layer mask we are rendering the particles through.
  108518. */
  108519. layerMask: number;
  108520. private _capacity;
  108521. private _activeCount;
  108522. private _currentActiveCount;
  108523. private _accumulatedCount;
  108524. private _renderEffect;
  108525. private _updateEffect;
  108526. private _buffer0;
  108527. private _buffer1;
  108528. private _spriteBuffer;
  108529. private _updateVAO;
  108530. private _renderVAO;
  108531. private _targetIndex;
  108532. private _sourceBuffer;
  108533. private _targetBuffer;
  108534. private _engine;
  108535. private _currentRenderId;
  108536. private _started;
  108537. private _stopped;
  108538. private _timeDelta;
  108539. private _randomTexture;
  108540. private _randomTexture2;
  108541. private _attributesStrideSize;
  108542. private _updateEffectOptions;
  108543. private _randomTextureSize;
  108544. private _actualFrame;
  108545. private readonly _rawTextureWidth;
  108546. /**
  108547. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  108548. */
  108549. static readonly IsSupported: boolean;
  108550. /**
  108551. * An event triggered when the system is disposed.
  108552. */
  108553. onDisposeObservable: Observable<GPUParticleSystem>;
  108554. /**
  108555. * Gets the maximum number of particles active at the same time.
  108556. * @returns The max number of active particles.
  108557. */
  108558. getCapacity(): number;
  108559. /**
  108560. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  108561. * to override the particles.
  108562. */
  108563. forceDepthWrite: boolean;
  108564. /**
  108565. * Gets or set the number of active particles
  108566. */
  108567. activeParticleCount: number;
  108568. private _preWarmDone;
  108569. /**
  108570. * Is this system ready to be used/rendered
  108571. * @return true if the system is ready
  108572. */
  108573. isReady(): boolean;
  108574. /**
  108575. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108576. * @returns True if it has been started, otherwise false.
  108577. */
  108578. isStarted(): boolean;
  108579. /**
  108580. * Starts the particle system and begins to emit
  108581. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108582. */
  108583. start(delay?: number): void;
  108584. /**
  108585. * Stops the particle system.
  108586. */
  108587. stop(): void;
  108588. /**
  108589. * Remove all active particles
  108590. */
  108591. reset(): void;
  108592. /**
  108593. * Returns the string "GPUParticleSystem"
  108594. * @returns a string containing the class name
  108595. */
  108596. getClassName(): string;
  108597. private _colorGradientsTexture;
  108598. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  108599. /**
  108600. * Adds a new color gradient
  108601. * @param gradient defines the gradient to use (between 0 and 1)
  108602. * @param color1 defines the color to affect to the specified gradient
  108603. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108604. * @returns the current particle system
  108605. */
  108606. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  108607. /**
  108608. * Remove a specific color gradient
  108609. * @param gradient defines the gradient to remove
  108610. * @returns the current particle system
  108611. */
  108612. removeColorGradient(gradient: number): GPUParticleSystem;
  108613. private _angularSpeedGradientsTexture;
  108614. private _sizeGradientsTexture;
  108615. private _velocityGradientsTexture;
  108616. private _limitVelocityGradientsTexture;
  108617. private _dragGradientsTexture;
  108618. private _addFactorGradient;
  108619. /**
  108620. * Adds a new size gradient
  108621. * @param gradient defines the gradient to use (between 0 and 1)
  108622. * @param factor defines the size factor to affect to the specified gradient
  108623. * @returns the current particle system
  108624. */
  108625. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  108626. /**
  108627. * Remove a specific size gradient
  108628. * @param gradient defines the gradient to remove
  108629. * @returns the current particle system
  108630. */
  108631. removeSizeGradient(gradient: number): GPUParticleSystem;
  108632. /**
  108633. * Adds a new angular speed gradient
  108634. * @param gradient defines the gradient to use (between 0 and 1)
  108635. * @param factor defines the angular speed to affect to the specified gradient
  108636. * @returns the current particle system
  108637. */
  108638. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  108639. /**
  108640. * Remove a specific angular speed gradient
  108641. * @param gradient defines the gradient to remove
  108642. * @returns the current particle system
  108643. */
  108644. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  108645. /**
  108646. * Adds a new velocity gradient
  108647. * @param gradient defines the gradient to use (between 0 and 1)
  108648. * @param factor defines the velocity to affect to the specified gradient
  108649. * @returns the current particle system
  108650. */
  108651. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108652. /**
  108653. * Remove a specific velocity gradient
  108654. * @param gradient defines the gradient to remove
  108655. * @returns the current particle system
  108656. */
  108657. removeVelocityGradient(gradient: number): GPUParticleSystem;
  108658. /**
  108659. * Adds a new limit velocity gradient
  108660. * @param gradient defines the gradient to use (between 0 and 1)
  108661. * @param factor defines the limit velocity value to affect to the specified gradient
  108662. * @returns the current particle system
  108663. */
  108664. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108665. /**
  108666. * Remove a specific limit velocity gradient
  108667. * @param gradient defines the gradient to remove
  108668. * @returns the current particle system
  108669. */
  108670. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  108671. /**
  108672. * Adds a new drag gradient
  108673. * @param gradient defines the gradient to use (between 0 and 1)
  108674. * @param factor defines the drag value to affect to the specified gradient
  108675. * @returns the current particle system
  108676. */
  108677. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  108678. /**
  108679. * Remove a specific drag gradient
  108680. * @param gradient defines the gradient to remove
  108681. * @returns the current particle system
  108682. */
  108683. removeDragGradient(gradient: number): GPUParticleSystem;
  108684. /**
  108685. * Not supported by GPUParticleSystem
  108686. * @param gradient defines the gradient to use (between 0 and 1)
  108687. * @param factor defines the emit rate value to affect to the specified gradient
  108688. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108689. * @returns the current particle system
  108690. */
  108691. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108692. /**
  108693. * Not supported by GPUParticleSystem
  108694. * @param gradient defines the gradient to remove
  108695. * @returns the current particle system
  108696. */
  108697. removeEmitRateGradient(gradient: number): IParticleSystem;
  108698. /**
  108699. * Not supported by GPUParticleSystem
  108700. * @param gradient defines the gradient to use (between 0 and 1)
  108701. * @param factor defines the start size value to affect to the specified gradient
  108702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108703. * @returns the current particle system
  108704. */
  108705. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108706. /**
  108707. * Not supported by GPUParticleSystem
  108708. * @param gradient defines the gradient to remove
  108709. * @returns the current particle system
  108710. */
  108711. removeStartSizeGradient(gradient: number): IParticleSystem;
  108712. /**
  108713. * Not supported by GPUParticleSystem
  108714. * @param gradient defines the gradient to use (between 0 and 1)
  108715. * @param min defines the color remap minimal range
  108716. * @param max defines the color remap maximal range
  108717. * @returns the current particle system
  108718. */
  108719. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108720. /**
  108721. * Not supported by GPUParticleSystem
  108722. * @param gradient defines the gradient to remove
  108723. * @returns the current particle system
  108724. */
  108725. removeColorRemapGradient(): IParticleSystem;
  108726. /**
  108727. * Not supported by GPUParticleSystem
  108728. * @param gradient defines the gradient to use (between 0 and 1)
  108729. * @param min defines the alpha remap minimal range
  108730. * @param max defines the alpha remap maximal range
  108731. * @returns the current particle system
  108732. */
  108733. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108734. /**
  108735. * Not supported by GPUParticleSystem
  108736. * @param gradient defines the gradient to remove
  108737. * @returns the current particle system
  108738. */
  108739. removeAlphaRemapGradient(): IParticleSystem;
  108740. /**
  108741. * Not supported by GPUParticleSystem
  108742. * @param gradient defines the gradient to use (between 0 and 1)
  108743. * @param color defines the color to affect to the specified gradient
  108744. * @returns the current particle system
  108745. */
  108746. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  108747. /**
  108748. * Not supported by GPUParticleSystem
  108749. * @param gradient defines the gradient to remove
  108750. * @returns the current particle system
  108751. */
  108752. removeRampGradient(): IParticleSystem;
  108753. /**
  108754. * Not supported by GPUParticleSystem
  108755. * @returns the list of ramp gradients
  108756. */
  108757. getRampGradients(): Nullable<Array<Color3Gradient>>;
  108758. /**
  108759. * Not supported by GPUParticleSystem
  108760. * Gets or sets a boolean indicating that ramp gradients must be used
  108761. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108762. */
  108763. useRampGradients: boolean;
  108764. /**
  108765. * Not supported by GPUParticleSystem
  108766. * @param gradient defines the gradient to use (between 0 and 1)
  108767. * @param factor defines the life time factor to affect to the specified gradient
  108768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108769. * @returns the current particle system
  108770. */
  108771. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108772. /**
  108773. * Not supported by GPUParticleSystem
  108774. * @param gradient defines the gradient to remove
  108775. * @returns the current particle system
  108776. */
  108777. removeLifeTimeGradient(gradient: number): IParticleSystem;
  108778. /**
  108779. * Instantiates a GPU particle system.
  108780. * 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.
  108781. * @param name The name of the particle system
  108782. * @param options The options used to create the system
  108783. * @param scene The scene the particle system belongs to
  108784. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108785. */
  108786. constructor(name: string, options: Partial<{
  108787. capacity: number;
  108788. randomTextureSize: number;
  108789. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  108790. protected _reset(): void;
  108791. private _createUpdateVAO;
  108792. private _createRenderVAO;
  108793. private _initialize;
  108794. /** @hidden */
  108795. _recreateUpdateEffect(): void;
  108796. /** @hidden */
  108797. _recreateRenderEffect(): void;
  108798. /**
  108799. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  108800. * @param preWarm defines if we are in the pre-warmimg phase
  108801. */
  108802. animate(preWarm?: boolean): void;
  108803. private _createFactorGradientTexture;
  108804. private _createSizeGradientTexture;
  108805. private _createAngularSpeedGradientTexture;
  108806. private _createVelocityGradientTexture;
  108807. private _createLimitVelocityGradientTexture;
  108808. private _createDragGradientTexture;
  108809. private _createColorGradientTexture;
  108810. /**
  108811. * Renders the particle system in its current state
  108812. * @param preWarm defines if the system should only update the particles but not render them
  108813. * @returns the current number of particles
  108814. */
  108815. render(preWarm?: boolean): number;
  108816. /**
  108817. * Rebuilds the particle system
  108818. */
  108819. rebuild(): void;
  108820. private _releaseBuffers;
  108821. private _releaseVAOs;
  108822. /**
  108823. * Disposes the particle system and free the associated resources
  108824. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  108825. */
  108826. dispose(disposeTexture?: boolean): void;
  108827. /**
  108828. * Clones the particle system.
  108829. * @param name The name of the cloned object
  108830. * @param newEmitter The new emitter to use
  108831. * @returns the cloned particle system
  108832. */
  108833. clone(name: string, newEmitter: any): GPUParticleSystem;
  108834. /**
  108835. * Serializes the particle system to a JSON object.
  108836. * @returns the JSON object
  108837. */
  108838. serialize(): any;
  108839. /**
  108840. * Parses a JSON object to create a GPU particle system.
  108841. * @param parsedParticleSystem The JSON object to parse
  108842. * @param scene The scene to create the particle system in
  108843. * @param rootUrl The root url to use to load external dependencies like texture
  108844. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  108845. * @returns the parsed GPU particle system
  108846. */
  108847. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  108848. }
  108849. }
  108850. declare module BABYLON {
  108851. /**
  108852. * Represents a set of particle systems working together to create a specific effect
  108853. */
  108854. export class ParticleSystemSet implements IDisposable {
  108855. private _emitterCreationOptions;
  108856. private _emitterNode;
  108857. /**
  108858. * Gets the particle system list
  108859. */
  108860. systems: IParticleSystem[];
  108861. /**
  108862. * Gets the emitter node used with this set
  108863. */
  108864. readonly emitterNode: Nullable<TransformNode>;
  108865. /**
  108866. * Creates a new emitter mesh as a sphere
  108867. * @param options defines the options used to create the sphere
  108868. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  108869. * @param scene defines the hosting scene
  108870. */
  108871. setEmitterAsSphere(options: {
  108872. diameter: number;
  108873. segments: number;
  108874. color: Color3;
  108875. }, renderingGroupId: number, scene: Scene): void;
  108876. /**
  108877. * Starts all particle systems of the set
  108878. * @param emitter defines an optional mesh to use as emitter for the particle systems
  108879. */
  108880. start(emitter?: AbstractMesh): void;
  108881. /**
  108882. * Release all associated resources
  108883. */
  108884. dispose(): void;
  108885. /**
  108886. * Serialize the set into a JSON compatible object
  108887. * @returns a JSON compatible representation of the set
  108888. */
  108889. serialize(): any;
  108890. /**
  108891. * Parse a new ParticleSystemSet from a serialized source
  108892. * @param data defines a JSON compatible representation of the set
  108893. * @param scene defines the hosting scene
  108894. * @param gpu defines if we want GPU particles or CPU particles
  108895. * @returns a new ParticleSystemSet
  108896. */
  108897. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  108898. }
  108899. }
  108900. declare module BABYLON {
  108901. /**
  108902. * This class is made for on one-liner static method to help creating particle system set.
  108903. */
  108904. export class ParticleHelper {
  108905. /**
  108906. * Gets or sets base Assets URL
  108907. */
  108908. static BaseAssetsUrl: string;
  108909. /**
  108910. * Create a default particle system that you can tweak
  108911. * @param emitter defines the emitter to use
  108912. * @param capacity defines the system capacity (default is 500 particles)
  108913. * @param scene defines the hosting scene
  108914. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  108915. * @returns the new Particle system
  108916. */
  108917. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  108918. /**
  108919. * This is the main static method (one-liner) of this helper to create different particle systems
  108920. * @param type This string represents the type to the particle system to create
  108921. * @param scene The scene where the particle system should live
  108922. * @param gpu If the system will use gpu
  108923. * @returns the ParticleSystemSet created
  108924. */
  108925. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  108926. /**
  108927. * Static function used to export a particle system to a ParticleSystemSet variable.
  108928. * Please note that the emitter shape is not exported
  108929. * @param systems defines the particle systems to export
  108930. * @returns the created particle system set
  108931. */
  108932. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  108933. }
  108934. }
  108935. declare module BABYLON {
  108936. interface Engine {
  108937. /**
  108938. * Create an effect to use with particle systems.
  108939. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  108940. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  108941. * @param uniformsNames defines a list of attribute names
  108942. * @param samplers defines an array of string used to represent textures
  108943. * @param defines defines the string containing the defines to use to compile the shaders
  108944. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108945. * @param onCompiled defines a function to call when the effect creation is successful
  108946. * @param onError defines a function to call when the effect creation has failed
  108947. * @returns the new Effect
  108948. */
  108949. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  108950. }
  108951. interface Mesh {
  108952. /**
  108953. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  108954. * @returns an array of IParticleSystem
  108955. */
  108956. getEmittedParticleSystems(): IParticleSystem[];
  108957. /**
  108958. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  108959. * @returns an array of IParticleSystem
  108960. */
  108961. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  108962. }
  108963. /**
  108964. * @hidden
  108965. */
  108966. export var _IDoNeedToBeInTheBuild: number;
  108967. }
  108968. declare module BABYLON {
  108969. interface Scene {
  108970. /** @hidden (Backing field) */
  108971. _physicsEngine: Nullable<IPhysicsEngine>;
  108972. /**
  108973. * Gets the current physics engine
  108974. * @returns a IPhysicsEngine or null if none attached
  108975. */
  108976. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  108977. /**
  108978. * Enables physics to the current scene
  108979. * @param gravity defines the scene's gravity for the physics engine
  108980. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  108981. * @return a boolean indicating if the physics engine was initialized
  108982. */
  108983. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  108984. /**
  108985. * Disables and disposes the physics engine associated with the scene
  108986. */
  108987. disablePhysicsEngine(): void;
  108988. /**
  108989. * Gets a boolean indicating if there is an active physics engine
  108990. * @returns a boolean indicating if there is an active physics engine
  108991. */
  108992. isPhysicsEnabled(): boolean;
  108993. /**
  108994. * Deletes a physics compound impostor
  108995. * @param compound defines the compound to delete
  108996. */
  108997. deleteCompoundImpostor(compound: any): void;
  108998. /**
  108999. * An event triggered when physic simulation is about to be run
  109000. */
  109001. onBeforePhysicsObservable: Observable<Scene>;
  109002. /**
  109003. * An event triggered when physic simulation has been done
  109004. */
  109005. onAfterPhysicsObservable: Observable<Scene>;
  109006. }
  109007. interface AbstractMesh {
  109008. /** @hidden */
  109009. _physicsImpostor: Nullable<PhysicsImpostor>;
  109010. /**
  109011. * Gets or sets impostor used for physic simulation
  109012. * @see http://doc.babylonjs.com/features/physics_engine
  109013. */
  109014. physicsImpostor: Nullable<PhysicsImpostor>;
  109015. /**
  109016. * Gets the current physics impostor
  109017. * @see http://doc.babylonjs.com/features/physics_engine
  109018. * @returns a physics impostor or null
  109019. */
  109020. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  109021. /** Apply a physic impulse to the mesh
  109022. * @param force defines the force to apply
  109023. * @param contactPoint defines where to apply the force
  109024. * @returns the current mesh
  109025. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  109026. */
  109027. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  109028. /**
  109029. * Creates a physic joint between two meshes
  109030. * @param otherMesh defines the other mesh to use
  109031. * @param pivot1 defines the pivot to use on this mesh
  109032. * @param pivot2 defines the pivot to use on the other mesh
  109033. * @param options defines additional options (can be plugin dependent)
  109034. * @returns the current mesh
  109035. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  109036. */
  109037. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  109038. /** @hidden */
  109039. _disposePhysicsObserver: Nullable<Observer<Node>>;
  109040. }
  109041. /**
  109042. * Defines the physics engine scene component responsible to manage a physics engine
  109043. */
  109044. export class PhysicsEngineSceneComponent implements ISceneComponent {
  109045. /**
  109046. * The component name helpful to identify the component in the list of scene components.
  109047. */
  109048. readonly name: string;
  109049. /**
  109050. * The scene the component belongs to.
  109051. */
  109052. scene: Scene;
  109053. /**
  109054. * Creates a new instance of the component for the given scene
  109055. * @param scene Defines the scene to register the component in
  109056. */
  109057. constructor(scene: Scene);
  109058. /**
  109059. * Registers the component in a given scene
  109060. */
  109061. register(): void;
  109062. /**
  109063. * Rebuilds the elements related to this component in case of
  109064. * context lost for instance.
  109065. */
  109066. rebuild(): void;
  109067. /**
  109068. * Disposes the component and the associated ressources
  109069. */
  109070. dispose(): void;
  109071. }
  109072. }
  109073. declare module BABYLON {
  109074. /**
  109075. * A helper for physics simulations
  109076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109077. */
  109078. export class PhysicsHelper {
  109079. private _scene;
  109080. private _physicsEngine;
  109081. /**
  109082. * Initializes the Physics helper
  109083. * @param scene Babylon.js scene
  109084. */
  109085. constructor(scene: Scene);
  109086. /**
  109087. * Applies a radial explosion impulse
  109088. * @param origin the origin of the explosion
  109089. * @param radiusOrEventOptions the radius or the options of radial explosion
  109090. * @param strength the explosion strength
  109091. * @param falloff possible options: Constant & Linear. Defaults to Constant
  109092. * @returns A physics radial explosion event, or null
  109093. */
  109094. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  109095. /**
  109096. * Applies a radial explosion force
  109097. * @param origin the origin of the explosion
  109098. * @param radiusOrEventOptions the radius or the options of radial explosion
  109099. * @param strength the explosion strength
  109100. * @param falloff possible options: Constant & Linear. Defaults to Constant
  109101. * @returns A physics radial explosion event, or null
  109102. */
  109103. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  109104. /**
  109105. * Creates a gravitational field
  109106. * @param origin the origin of the explosion
  109107. * @param radiusOrEventOptions the radius or the options of radial explosion
  109108. * @param strength the explosion strength
  109109. * @param falloff possible options: Constant & Linear. Defaults to Constant
  109110. * @returns A physics gravitational field event, or null
  109111. */
  109112. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  109113. /**
  109114. * Creates a physics updraft event
  109115. * @param origin the origin of the updraft
  109116. * @param radiusOrEventOptions the radius or the options of the updraft
  109117. * @param strength the strength of the updraft
  109118. * @param height the height of the updraft
  109119. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  109120. * @returns A physics updraft event, or null
  109121. */
  109122. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  109123. /**
  109124. * Creates a physics vortex event
  109125. * @param origin the of the vortex
  109126. * @param radiusOrEventOptions the radius or the options of the vortex
  109127. * @param strength the strength of the vortex
  109128. * @param height the height of the vortex
  109129. * @returns a Physics vortex event, or null
  109130. * A physics vortex event or null
  109131. */
  109132. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  109133. }
  109134. /**
  109135. * Represents a physics radial explosion event
  109136. */
  109137. class PhysicsRadialExplosionEvent {
  109138. private _scene;
  109139. private _options;
  109140. private _sphere;
  109141. private _dataFetched;
  109142. /**
  109143. * Initializes a radial explosioin event
  109144. * @param _scene BabylonJS scene
  109145. * @param _options The options for the vortex event
  109146. */
  109147. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  109148. /**
  109149. * Returns the data related to the radial explosion event (sphere).
  109150. * @returns The radial explosion event data
  109151. */
  109152. getData(): PhysicsRadialExplosionEventData;
  109153. /**
  109154. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  109155. * @param impostor A physics imposter
  109156. * @param origin the origin of the explosion
  109157. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  109158. */
  109159. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  109160. /**
  109161. * Disposes the sphere.
  109162. * @param force Specifies if the sphere should be disposed by force
  109163. */
  109164. dispose(force?: boolean): void;
  109165. /*** Helpers ***/
  109166. private _prepareSphere;
  109167. private _intersectsWithSphere;
  109168. }
  109169. /**
  109170. * Represents a gravitational field event
  109171. */
  109172. class PhysicsGravitationalFieldEvent {
  109173. private _physicsHelper;
  109174. private _scene;
  109175. private _origin;
  109176. private _options;
  109177. private _tickCallback;
  109178. private _sphere;
  109179. private _dataFetched;
  109180. /**
  109181. * Initializes the physics gravitational field event
  109182. * @param _physicsHelper A physics helper
  109183. * @param _scene BabylonJS scene
  109184. * @param _origin The origin position of the gravitational field event
  109185. * @param _options The options for the vortex event
  109186. */
  109187. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  109188. /**
  109189. * Returns the data related to the gravitational field event (sphere).
  109190. * @returns A gravitational field event
  109191. */
  109192. getData(): PhysicsGravitationalFieldEventData;
  109193. /**
  109194. * Enables the gravitational field.
  109195. */
  109196. enable(): void;
  109197. /**
  109198. * Disables the gravitational field.
  109199. */
  109200. disable(): void;
  109201. /**
  109202. * Disposes the sphere.
  109203. * @param force The force to dispose from the gravitational field event
  109204. */
  109205. dispose(force?: boolean): void;
  109206. private _tick;
  109207. }
  109208. /**
  109209. * Represents a physics updraft event
  109210. */
  109211. class PhysicsUpdraftEvent {
  109212. private _scene;
  109213. private _origin;
  109214. private _options;
  109215. private _physicsEngine;
  109216. private _originTop;
  109217. private _originDirection;
  109218. private _tickCallback;
  109219. private _cylinder;
  109220. private _cylinderPosition;
  109221. private _dataFetched;
  109222. /**
  109223. * Initializes the physics updraft event
  109224. * @param _scene BabylonJS scene
  109225. * @param _origin The origin position of the updraft
  109226. * @param _options The options for the updraft event
  109227. */
  109228. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  109229. /**
  109230. * Returns the data related to the updraft event (cylinder).
  109231. * @returns A physics updraft event
  109232. */
  109233. getData(): PhysicsUpdraftEventData;
  109234. /**
  109235. * Enables the updraft.
  109236. */
  109237. enable(): void;
  109238. /**
  109239. * Disables the updraft.
  109240. */
  109241. disable(): void;
  109242. /**
  109243. * Disposes the cylinder.
  109244. * @param force Specifies if the updraft should be disposed by force
  109245. */
  109246. dispose(force?: boolean): void;
  109247. private getImpostorForceAndContactPoint;
  109248. private _tick;
  109249. /*** Helpers ***/
  109250. private _prepareCylinder;
  109251. private _intersectsWithCylinder;
  109252. }
  109253. /**
  109254. * Represents a physics vortex event
  109255. */
  109256. class PhysicsVortexEvent {
  109257. private _scene;
  109258. private _origin;
  109259. private _options;
  109260. private _physicsEngine;
  109261. private _originTop;
  109262. private _tickCallback;
  109263. private _cylinder;
  109264. private _cylinderPosition;
  109265. private _dataFetched;
  109266. /**
  109267. * Initializes the physics vortex event
  109268. * @param _scene The BabylonJS scene
  109269. * @param _origin The origin position of the vortex
  109270. * @param _options The options for the vortex event
  109271. */
  109272. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  109273. /**
  109274. * Returns the data related to the vortex event (cylinder).
  109275. * @returns The physics vortex event data
  109276. */
  109277. getData(): PhysicsVortexEventData;
  109278. /**
  109279. * Enables the vortex.
  109280. */
  109281. enable(): void;
  109282. /**
  109283. * Disables the cortex.
  109284. */
  109285. disable(): void;
  109286. /**
  109287. * Disposes the sphere.
  109288. * @param force
  109289. */
  109290. dispose(force?: boolean): void;
  109291. private getImpostorForceAndContactPoint;
  109292. private _tick;
  109293. /*** Helpers ***/
  109294. private _prepareCylinder;
  109295. private _intersectsWithCylinder;
  109296. }
  109297. /**
  109298. * Options fot the radial explosion event
  109299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109300. */
  109301. export class PhysicsRadialExplosionEventOptions {
  109302. /**
  109303. * The radius of the sphere for the radial explosion.
  109304. */
  109305. radius: number;
  109306. /**
  109307. * The strenth of the explosion.
  109308. */
  109309. strength: number;
  109310. /**
  109311. * The strenght of the force in correspondence to the distance of the affected object
  109312. */
  109313. falloff: PhysicsRadialImpulseFalloff;
  109314. /**
  109315. * Sphere options for the radial explosion.
  109316. */
  109317. sphere: {
  109318. segments: number;
  109319. diameter: number;
  109320. };
  109321. }
  109322. /**
  109323. * Options fot the updraft event
  109324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109325. */
  109326. export class PhysicsUpdraftEventOptions {
  109327. /**
  109328. * The radius of the cylinder for the vortex
  109329. */
  109330. radius: number;
  109331. /**
  109332. * The strenth of the updraft.
  109333. */
  109334. strength: number;
  109335. /**
  109336. * The height of the cylinder for the updraft.
  109337. */
  109338. height: number;
  109339. /**
  109340. * The mode for the the updraft.
  109341. */
  109342. updraftMode: PhysicsUpdraftMode;
  109343. }
  109344. /**
  109345. * Options fot the vortex event
  109346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109347. */
  109348. export class PhysicsVortexEventOptions {
  109349. /**
  109350. * The radius of the cylinder for the vortex
  109351. */
  109352. radius: number;
  109353. /**
  109354. * The strenth of the vortex.
  109355. */
  109356. strength: number;
  109357. /**
  109358. * The height of the cylinder for the vortex.
  109359. */
  109360. height: number;
  109361. /**
  109362. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  109363. */
  109364. centripetalForceThreshold: number;
  109365. /**
  109366. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  109367. */
  109368. centripetalForceMultiplier: number;
  109369. /**
  109370. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  109371. */
  109372. centrifugalForceMultiplier: number;
  109373. /**
  109374. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  109375. */
  109376. updraftForceMultiplier: number;
  109377. }
  109378. /**
  109379. * The strenght of the force in correspondence to the distance of the affected object
  109380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109381. */
  109382. export enum PhysicsRadialImpulseFalloff {
  109383. /** Defines that impulse is constant in strength across it's whole radius */
  109384. Constant = 0,
  109385. /** Defines that impulse gets weaker if it's further from the origin */
  109386. Linear = 1
  109387. }
  109388. /**
  109389. * The strength of the force in correspondence to the distance of the affected object
  109390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109391. */
  109392. export enum PhysicsUpdraftMode {
  109393. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  109394. Center = 0,
  109395. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  109396. Perpendicular = 1
  109397. }
  109398. /**
  109399. * Interface for a physics force and contact point
  109400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109401. */
  109402. export interface PhysicsForceAndContactPoint {
  109403. /**
  109404. * The force applied at the contact point
  109405. */
  109406. force: Vector3;
  109407. /**
  109408. * The contact point
  109409. */
  109410. contactPoint: Vector3;
  109411. }
  109412. /**
  109413. * Interface for radial explosion event data
  109414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109415. */
  109416. export interface PhysicsRadialExplosionEventData {
  109417. /**
  109418. * A sphere used for the radial explosion event
  109419. */
  109420. sphere: Mesh;
  109421. }
  109422. /**
  109423. * Interface for gravitational field event data
  109424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109425. */
  109426. export interface PhysicsGravitationalFieldEventData {
  109427. /**
  109428. * A sphere mesh used for the gravitational field event
  109429. */
  109430. sphere: Mesh;
  109431. }
  109432. /**
  109433. * Interface for updraft event data
  109434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109435. */
  109436. export interface PhysicsUpdraftEventData {
  109437. /**
  109438. * A cylinder used for the updraft event
  109439. */
  109440. cylinder: Mesh;
  109441. }
  109442. /**
  109443. * Interface for vortex event data
  109444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109445. */
  109446. export interface PhysicsVortexEventData {
  109447. /**
  109448. * A cylinder used for the vortex event
  109449. */
  109450. cylinder: Mesh;
  109451. }
  109452. }
  109453. declare module BABYLON {
  109454. /**
  109455. * AmmoJS Physics plugin
  109456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  109457. * @see https://github.com/kripken/ammo.js/
  109458. */
  109459. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  109460. private _useDeltaForWorldStep;
  109461. /**
  109462. * Reference to the Ammo library
  109463. */
  109464. bjsAMMO: any;
  109465. /**
  109466. * Created ammoJS world which physics bodies are added to
  109467. */
  109468. world: any;
  109469. /**
  109470. * Name of the plugin
  109471. */
  109472. name: string;
  109473. private _timeStep;
  109474. private _fixedTimeStep;
  109475. private _maxSteps;
  109476. private _tmpQuaternion;
  109477. private _tmpAmmoTransform;
  109478. private _tmpAmmoQuaternion;
  109479. private _tmpAmmoConcreteContactResultCallback;
  109480. private _collisionConfiguration;
  109481. private _dispatcher;
  109482. private _overlappingPairCache;
  109483. private _solver;
  109484. private _softBodySolver;
  109485. private _tmpAmmoVectorA;
  109486. private _tmpAmmoVectorB;
  109487. private _tmpAmmoVectorC;
  109488. private _tmpAmmoVectorD;
  109489. private _tmpContactCallbackResult;
  109490. private _tmpAmmoVectorRCA;
  109491. private _tmpAmmoVectorRCB;
  109492. private _raycastResult;
  109493. private static readonly DISABLE_COLLISION_FLAG;
  109494. private static readonly KINEMATIC_FLAG;
  109495. private static readonly DISABLE_DEACTIVATION_FLAG;
  109496. /**
  109497. * Initializes the ammoJS plugin
  109498. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  109499. * @param ammoInjection can be used to inject your own ammo reference
  109500. */
  109501. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  109502. /**
  109503. * Sets the gravity of the physics world (m/(s^2))
  109504. * @param gravity Gravity to set
  109505. */
  109506. setGravity(gravity: Vector3): void;
  109507. /**
  109508. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109509. * @param timeStep timestep to use in seconds
  109510. */
  109511. setTimeStep(timeStep: number): void;
  109512. /**
  109513. * 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)
  109514. * @param fixedTimeStep fixedTimeStep to use in seconds
  109515. */
  109516. setFixedTimeStep(fixedTimeStep: number): void;
  109517. /**
  109518. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109519. * @param maxSteps the maximum number of steps by the physics engine per frame
  109520. */
  109521. setMaxSteps(maxSteps: number): void;
  109522. /**
  109523. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109524. * @returns the current timestep in seconds
  109525. */
  109526. getTimeStep(): number;
  109527. private _isImpostorInContact;
  109528. private _isImpostorPairInContact;
  109529. private _stepSimulation;
  109530. /**
  109531. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109532. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109533. * After the step the babylon meshes are set to the position of the physics imposters
  109534. * @param delta amount of time to step forward
  109535. * @param impostors array of imposters to update before/after the step
  109536. */
  109537. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  109538. /**
  109539. * Update babylon mesh to match physics world object
  109540. * @param impostor imposter to match
  109541. */
  109542. private _afterSoftStep;
  109543. /**
  109544. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  109545. * @param impostor imposter to match
  109546. */
  109547. private _ropeStep;
  109548. /**
  109549. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  109550. * @param impostor imposter to match
  109551. */
  109552. private _softbodyOrClothStep;
  109553. private _tmpVector;
  109554. private _tmpMatrix;
  109555. /**
  109556. * Applies an impulse on the imposter
  109557. * @param impostor imposter to apply impulse to
  109558. * @param force amount of force to be applied to the imposter
  109559. * @param contactPoint the location to apply the impulse on the imposter
  109560. */
  109561. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109562. /**
  109563. * Applies a force on the imposter
  109564. * @param impostor imposter to apply force
  109565. * @param force amount of force to be applied to the imposter
  109566. * @param contactPoint the location to apply the force on the imposter
  109567. */
  109568. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109569. /**
  109570. * Creates a physics body using the plugin
  109571. * @param impostor the imposter to create the physics body on
  109572. */
  109573. generatePhysicsBody(impostor: PhysicsImpostor): void;
  109574. /**
  109575. * Removes the physics body from the imposter and disposes of the body's memory
  109576. * @param impostor imposter to remove the physics body from
  109577. */
  109578. removePhysicsBody(impostor: PhysicsImpostor): void;
  109579. /**
  109580. * Generates a joint
  109581. * @param impostorJoint the imposter joint to create the joint with
  109582. */
  109583. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  109584. /**
  109585. * Removes a joint
  109586. * @param impostorJoint the imposter joint to remove the joint from
  109587. */
  109588. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  109589. private _addMeshVerts;
  109590. /**
  109591. * Initialise the soft body vertices to match its object's (mesh) vertices
  109592. * Softbody vertices (nodes) are in world space and to match this
  109593. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  109594. * @param impostor to create the softbody for
  109595. */
  109596. private _softVertexData;
  109597. /**
  109598. * Create an impostor's soft body
  109599. * @param impostor to create the softbody for
  109600. */
  109601. private _createSoftbody;
  109602. /**
  109603. * Create cloth for an impostor
  109604. * @param impostor to create the softbody for
  109605. */
  109606. private _createCloth;
  109607. /**
  109608. * Create rope for an impostor
  109609. * @param impostor to create the softbody for
  109610. */
  109611. private _createRope;
  109612. private _addHullVerts;
  109613. private _createShape;
  109614. /**
  109615. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109616. * @param impostor imposter containing the physics body and babylon object
  109617. */
  109618. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  109619. /**
  109620. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109621. * @param impostor imposter containing the physics body and babylon object
  109622. * @param newPosition new position
  109623. * @param newRotation new rotation
  109624. */
  109625. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  109626. /**
  109627. * If this plugin is supported
  109628. * @returns true if its supported
  109629. */
  109630. isSupported(): boolean;
  109631. /**
  109632. * Sets the linear velocity of the physics body
  109633. * @param impostor imposter to set the velocity on
  109634. * @param velocity velocity to set
  109635. */
  109636. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109637. /**
  109638. * Sets the angular velocity of the physics body
  109639. * @param impostor imposter to set the velocity on
  109640. * @param velocity velocity to set
  109641. */
  109642. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109643. /**
  109644. * gets the linear velocity
  109645. * @param impostor imposter to get linear velocity from
  109646. * @returns linear velocity
  109647. */
  109648. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109649. /**
  109650. * gets the angular velocity
  109651. * @param impostor imposter to get angular velocity from
  109652. * @returns angular velocity
  109653. */
  109654. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109655. /**
  109656. * Sets the mass of physics body
  109657. * @param impostor imposter to set the mass on
  109658. * @param mass mass to set
  109659. */
  109660. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  109661. /**
  109662. * Gets the mass of the physics body
  109663. * @param impostor imposter to get the mass from
  109664. * @returns mass
  109665. */
  109666. getBodyMass(impostor: PhysicsImpostor): number;
  109667. /**
  109668. * Gets friction of the impostor
  109669. * @param impostor impostor to get friction from
  109670. * @returns friction value
  109671. */
  109672. getBodyFriction(impostor: PhysicsImpostor): number;
  109673. /**
  109674. * Sets friction of the impostor
  109675. * @param impostor impostor to set friction on
  109676. * @param friction friction value
  109677. */
  109678. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  109679. /**
  109680. * Gets restitution of the impostor
  109681. * @param impostor impostor to get restitution from
  109682. * @returns restitution value
  109683. */
  109684. getBodyRestitution(impostor: PhysicsImpostor): number;
  109685. /**
  109686. * Sets resitution of the impostor
  109687. * @param impostor impostor to set resitution on
  109688. * @param restitution resitution value
  109689. */
  109690. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  109691. /**
  109692. * Gets pressure inside the impostor
  109693. * @param impostor impostor to get pressure from
  109694. * @returns pressure value
  109695. */
  109696. getBodyPressure(impostor: PhysicsImpostor): number;
  109697. /**
  109698. * Sets pressure inside a soft body impostor
  109699. * Cloth and rope must remain 0 pressure
  109700. * @param impostor impostor to set pressure on
  109701. * @param pressure pressure value
  109702. */
  109703. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  109704. /**
  109705. * Gets stiffness of the impostor
  109706. * @param impostor impostor to get stiffness from
  109707. * @returns pressure value
  109708. */
  109709. getBodyStiffness(impostor: PhysicsImpostor): number;
  109710. /**
  109711. * Sets stiffness of the impostor
  109712. * @param impostor impostor to set stiffness on
  109713. * @param stiffness stiffness value from 0 to 1
  109714. */
  109715. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  109716. /**
  109717. * Gets velocityIterations of the impostor
  109718. * @param impostor impostor to get velocity iterations from
  109719. * @returns velocityIterations value
  109720. */
  109721. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  109722. /**
  109723. * Sets velocityIterations of the impostor
  109724. * @param impostor impostor to set velocity iterations on
  109725. * @param velocityIterations velocityIterations value
  109726. */
  109727. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  109728. /**
  109729. * Gets positionIterations of the impostor
  109730. * @param impostor impostor to get position iterations from
  109731. * @returns positionIterations value
  109732. */
  109733. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  109734. /**
  109735. * Sets positionIterations of the impostor
  109736. * @param impostor impostor to set position on
  109737. * @param positionIterations positionIterations value
  109738. */
  109739. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  109740. /**
  109741. * Append an anchor to a cloth object
  109742. * @param impostor is the cloth impostor to add anchor to
  109743. * @param otherImpostor is the rigid impostor to anchor to
  109744. * @param width ratio across width from 0 to 1
  109745. * @param height ratio up height from 0 to 1
  109746. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  109747. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  109748. */
  109749. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  109750. /**
  109751. * Append an hook to a rope object
  109752. * @param impostor is the rope impostor to add hook to
  109753. * @param otherImpostor is the rigid impostor to hook to
  109754. * @param length ratio along the rope from 0 to 1
  109755. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  109756. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  109757. */
  109758. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  109759. /**
  109760. * Sleeps the physics body and stops it from being active
  109761. * @param impostor impostor to sleep
  109762. */
  109763. sleepBody(impostor: PhysicsImpostor): void;
  109764. /**
  109765. * Activates the physics body
  109766. * @param impostor impostor to activate
  109767. */
  109768. wakeUpBody(impostor: PhysicsImpostor): void;
  109769. /**
  109770. * Updates the distance parameters of the joint
  109771. * @param joint joint to update
  109772. * @param maxDistance maximum distance of the joint
  109773. * @param minDistance minimum distance of the joint
  109774. */
  109775. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  109776. /**
  109777. * Sets a motor on the joint
  109778. * @param joint joint to set motor on
  109779. * @param speed speed of the motor
  109780. * @param maxForce maximum force of the motor
  109781. * @param motorIndex index of the motor
  109782. */
  109783. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  109784. /**
  109785. * Sets the motors limit
  109786. * @param joint joint to set limit on
  109787. * @param upperLimit upper limit
  109788. * @param lowerLimit lower limit
  109789. */
  109790. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  109791. /**
  109792. * Syncs the position and rotation of a mesh with the impostor
  109793. * @param mesh mesh to sync
  109794. * @param impostor impostor to update the mesh with
  109795. */
  109796. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  109797. /**
  109798. * Gets the radius of the impostor
  109799. * @param impostor impostor to get radius from
  109800. * @returns the radius
  109801. */
  109802. getRadius(impostor: PhysicsImpostor): number;
  109803. /**
  109804. * Gets the box size of the impostor
  109805. * @param impostor impostor to get box size from
  109806. * @param result the resulting box size
  109807. */
  109808. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  109809. /**
  109810. * Disposes of the impostor
  109811. */
  109812. dispose(): void;
  109813. /**
  109814. * Does a raycast in the physics world
  109815. * @param from when should the ray start?
  109816. * @param to when should the ray end?
  109817. * @returns PhysicsRaycastResult
  109818. */
  109819. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  109820. }
  109821. }
  109822. declare module BABYLON {
  109823. /** @hidden */
  109824. export var blackAndWhitePixelShader: {
  109825. name: string;
  109826. shader: string;
  109827. };
  109828. }
  109829. declare module BABYLON {
  109830. /**
  109831. * Post process used to render in black and white
  109832. */
  109833. export class BlackAndWhitePostProcess extends PostProcess {
  109834. /**
  109835. * Linear about to convert he result to black and white (default: 1)
  109836. */
  109837. degree: number;
  109838. /**
  109839. * Creates a black and white post process
  109840. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  109841. * @param name The name of the effect.
  109842. * @param options The required width/height ratio to downsize to before computing the render pass.
  109843. * @param camera The camera to apply the render pass to.
  109844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109845. * @param engine The engine which the post process will be applied. (default: current engine)
  109846. * @param reusable If the post process can be reused on the same frame. (default: false)
  109847. */
  109848. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109849. }
  109850. }
  109851. declare module BABYLON {
  109852. /**
  109853. * This represents a set of one or more post processes in Babylon.
  109854. * A post process can be used to apply a shader to a texture after it is rendered.
  109855. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109856. */
  109857. export class PostProcessRenderEffect {
  109858. private _postProcesses;
  109859. private _getPostProcesses;
  109860. private _singleInstance;
  109861. private _cameras;
  109862. private _indicesForCamera;
  109863. /**
  109864. * Name of the effect
  109865. * @hidden
  109866. */
  109867. _name: string;
  109868. /**
  109869. * Instantiates a post process render effect.
  109870. * A post process can be used to apply a shader to a texture after it is rendered.
  109871. * @param engine The engine the effect is tied to
  109872. * @param name The name of the effect
  109873. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  109874. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  109875. */
  109876. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  109877. /**
  109878. * Checks if all the post processes in the effect are supported.
  109879. */
  109880. readonly isSupported: boolean;
  109881. /**
  109882. * Updates the current state of the effect
  109883. * @hidden
  109884. */
  109885. _update(): void;
  109886. /**
  109887. * Attaches the effect on cameras
  109888. * @param cameras The camera to attach to.
  109889. * @hidden
  109890. */
  109891. _attachCameras(cameras: Camera): void;
  109892. /**
  109893. * Attaches the effect on cameras
  109894. * @param cameras The camera to attach to.
  109895. * @hidden
  109896. */
  109897. _attachCameras(cameras: Camera[]): void;
  109898. /**
  109899. * Detatches the effect on cameras
  109900. * @param cameras The camera to detatch from.
  109901. * @hidden
  109902. */
  109903. _detachCameras(cameras: Camera): void;
  109904. /**
  109905. * Detatches the effect on cameras
  109906. * @param cameras The camera to detatch from.
  109907. * @hidden
  109908. */
  109909. _detachCameras(cameras: Camera[]): void;
  109910. /**
  109911. * Enables the effect on given cameras
  109912. * @param cameras The camera to enable.
  109913. * @hidden
  109914. */
  109915. _enable(cameras: Camera): void;
  109916. /**
  109917. * Enables the effect on given cameras
  109918. * @param cameras The camera to enable.
  109919. * @hidden
  109920. */
  109921. _enable(cameras: Nullable<Camera[]>): void;
  109922. /**
  109923. * Disables the effect on the given cameras
  109924. * @param cameras The camera to disable.
  109925. * @hidden
  109926. */
  109927. _disable(cameras: Camera): void;
  109928. /**
  109929. * Disables the effect on the given cameras
  109930. * @param cameras The camera to disable.
  109931. * @hidden
  109932. */
  109933. _disable(cameras: Nullable<Camera[]>): void;
  109934. /**
  109935. * Gets a list of the post processes contained in the effect.
  109936. * @param camera The camera to get the post processes on.
  109937. * @returns The list of the post processes in the effect.
  109938. */
  109939. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  109940. }
  109941. }
  109942. declare module BABYLON {
  109943. /** @hidden */
  109944. export var extractHighlightsPixelShader: {
  109945. name: string;
  109946. shader: string;
  109947. };
  109948. }
  109949. declare module BABYLON {
  109950. /**
  109951. * 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.
  109952. */
  109953. export class ExtractHighlightsPostProcess extends PostProcess {
  109954. /**
  109955. * The luminance threshold, pixels below this value will be set to black.
  109956. */
  109957. threshold: number;
  109958. /** @hidden */
  109959. _exposure: number;
  109960. /**
  109961. * Post process which has the input texture to be used when performing highlight extraction
  109962. * @hidden
  109963. */
  109964. _inputPostProcess: Nullable<PostProcess>;
  109965. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109966. }
  109967. }
  109968. declare module BABYLON {
  109969. /** @hidden */
  109970. export var bloomMergePixelShader: {
  109971. name: string;
  109972. shader: string;
  109973. };
  109974. }
  109975. declare module BABYLON {
  109976. /**
  109977. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109978. */
  109979. export class BloomMergePostProcess extends PostProcess {
  109980. /** Weight of the bloom to be added to the original input. */
  109981. weight: number;
  109982. /**
  109983. * Creates a new instance of @see BloomMergePostProcess
  109984. * @param name The name of the effect.
  109985. * @param originalFromInput Post process which's input will be used for the merge.
  109986. * @param blurred Blurred highlights post process which's output will be used.
  109987. * @param weight Weight of the bloom to be added to the original input.
  109988. * @param options The required width/height ratio to downsize to before computing the render pass.
  109989. * @param camera The camera to apply the render pass to.
  109990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109991. * @param engine The engine which the post process will be applied. (default: current engine)
  109992. * @param reusable If the post process can be reused on the same frame. (default: false)
  109993. * @param textureType Type of textures used when performing the post process. (default: 0)
  109994. * @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)
  109995. */
  109996. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  109997. /** Weight of the bloom to be added to the original input. */
  109998. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109999. }
  110000. }
  110001. declare module BABYLON {
  110002. /**
  110003. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  110004. */
  110005. export class BloomEffect extends PostProcessRenderEffect {
  110006. private bloomScale;
  110007. /**
  110008. * @hidden Internal
  110009. */
  110010. _effects: Array<PostProcess>;
  110011. /**
  110012. * @hidden Internal
  110013. */
  110014. _downscale: ExtractHighlightsPostProcess;
  110015. private _blurX;
  110016. private _blurY;
  110017. private _merge;
  110018. /**
  110019. * The luminance threshold to find bright areas of the image to bloom.
  110020. */
  110021. threshold: number;
  110022. /**
  110023. * The strength of the bloom.
  110024. */
  110025. weight: number;
  110026. /**
  110027. * Specifies the size of the bloom blur kernel, relative to the final output size
  110028. */
  110029. kernel: number;
  110030. /**
  110031. * Creates a new instance of @see BloomEffect
  110032. * @param scene The scene the effect belongs to.
  110033. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  110034. * @param bloomKernel The size of the kernel to be used when applying the blur.
  110035. * @param bloomWeight The the strength of bloom.
  110036. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  110037. * @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)
  110038. */
  110039. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  110040. /**
  110041. * Disposes each of the internal effects for a given camera.
  110042. * @param camera The camera to dispose the effect on.
  110043. */
  110044. disposeEffects(camera: Camera): void;
  110045. /**
  110046. * @hidden Internal
  110047. */
  110048. _updateEffects(): void;
  110049. /**
  110050. * Internal
  110051. * @returns if all the contained post processes are ready.
  110052. * @hidden
  110053. */
  110054. _isReady(): boolean;
  110055. }
  110056. }
  110057. declare module BABYLON {
  110058. /** @hidden */
  110059. export var chromaticAberrationPixelShader: {
  110060. name: string;
  110061. shader: string;
  110062. };
  110063. }
  110064. declare module BABYLON {
  110065. /**
  110066. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  110067. */
  110068. export class ChromaticAberrationPostProcess extends PostProcess {
  110069. /**
  110070. * The amount of seperation of rgb channels (default: 30)
  110071. */
  110072. aberrationAmount: number;
  110073. /**
  110074. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  110075. */
  110076. radialIntensity: number;
  110077. /**
  110078. * 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))
  110079. */
  110080. direction: Vector2;
  110081. /**
  110082. * 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))
  110083. */
  110084. centerPosition: Vector2;
  110085. /**
  110086. * Creates a new instance ChromaticAberrationPostProcess
  110087. * @param name The name of the effect.
  110088. * @param screenWidth The width of the screen to apply the effect on.
  110089. * @param screenHeight The height of the screen to apply the effect on.
  110090. * @param options The required width/height ratio to downsize to before computing the render pass.
  110091. * @param camera The camera to apply the render pass to.
  110092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110093. * @param engine The engine which the post process will be applied. (default: current engine)
  110094. * @param reusable If the post process can be reused on the same frame. (default: false)
  110095. * @param textureType Type of textures used when performing the post process. (default: 0)
  110096. * @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)
  110097. */
  110098. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110099. }
  110100. }
  110101. declare module BABYLON {
  110102. /** @hidden */
  110103. export var circleOfConfusionPixelShader: {
  110104. name: string;
  110105. shader: string;
  110106. };
  110107. }
  110108. declare module BABYLON {
  110109. /**
  110110. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  110111. */
  110112. export class CircleOfConfusionPostProcess extends PostProcess {
  110113. /**
  110114. * 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.
  110115. */
  110116. lensSize: number;
  110117. /**
  110118. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  110119. */
  110120. fStop: number;
  110121. /**
  110122. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  110123. */
  110124. focusDistance: number;
  110125. /**
  110126. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  110127. */
  110128. focalLength: number;
  110129. private _depthTexture;
  110130. /**
  110131. * Creates a new instance CircleOfConfusionPostProcess
  110132. * @param name The name of the effect.
  110133. * @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.
  110134. * @param options The required width/height ratio to downsize to before computing the render pass.
  110135. * @param camera The camera to apply the render pass to.
  110136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110137. * @param engine The engine which the post process will be applied. (default: current engine)
  110138. * @param reusable If the post process can be reused on the same frame. (default: false)
  110139. * @param textureType Type of textures used when performing the post process. (default: 0)
  110140. * @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)
  110141. */
  110142. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110143. /**
  110144. * 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.
  110145. */
  110146. depthTexture: RenderTargetTexture;
  110147. }
  110148. }
  110149. declare module BABYLON {
  110150. /** @hidden */
  110151. export var colorCorrectionPixelShader: {
  110152. name: string;
  110153. shader: string;
  110154. };
  110155. }
  110156. declare module BABYLON {
  110157. /**
  110158. *
  110159. * This post-process allows the modification of rendered colors by using
  110160. * a 'look-up table' (LUT). This effect is also called Color Grading.
  110161. *
  110162. * The object needs to be provided an url to a texture containing the color
  110163. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  110164. * Use an image editing software to tweak the LUT to match your needs.
  110165. *
  110166. * For an example of a color LUT, see here:
  110167. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  110168. * For explanations on color grading, see here:
  110169. * @see http://udn.epicgames.com/Three/ColorGrading.html
  110170. *
  110171. */
  110172. export class ColorCorrectionPostProcess extends PostProcess {
  110173. private _colorTableTexture;
  110174. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110175. }
  110176. }
  110177. declare module BABYLON {
  110178. /** @hidden */
  110179. export var convolutionPixelShader: {
  110180. name: string;
  110181. shader: string;
  110182. };
  110183. }
  110184. declare module BABYLON {
  110185. /**
  110186. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  110187. * input texture to perform effects such as edge detection or sharpening
  110188. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110189. */
  110190. export class ConvolutionPostProcess extends PostProcess {
  110191. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  110192. kernel: number[];
  110193. /**
  110194. * Creates a new instance ConvolutionPostProcess
  110195. * @param name The name of the effect.
  110196. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  110197. * @param options The required width/height ratio to downsize to before computing the render pass.
  110198. * @param camera The camera to apply the render pass to.
  110199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110200. * @param engine The engine which the post process will be applied. (default: current engine)
  110201. * @param reusable If the post process can be reused on the same frame. (default: false)
  110202. * @param textureType Type of textures used when performing the post process. (default: 0)
  110203. */
  110204. constructor(name: string,
  110205. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  110206. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110207. /**
  110208. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110209. */
  110210. static EdgeDetect0Kernel: number[];
  110211. /**
  110212. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110213. */
  110214. static EdgeDetect1Kernel: number[];
  110215. /**
  110216. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110217. */
  110218. static EdgeDetect2Kernel: number[];
  110219. /**
  110220. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110221. */
  110222. static SharpenKernel: number[];
  110223. /**
  110224. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110225. */
  110226. static EmbossKernel: number[];
  110227. /**
  110228. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110229. */
  110230. static GaussianKernel: number[];
  110231. }
  110232. }
  110233. declare module BABYLON {
  110234. /**
  110235. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  110236. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  110237. * based on samples that have a large difference in distance than the center pixel.
  110238. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  110239. */
  110240. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  110241. direction: Vector2;
  110242. /**
  110243. * Creates a new instance CircleOfConfusionPostProcess
  110244. * @param name The name of the effect.
  110245. * @param scene The scene the effect belongs to.
  110246. * @param direction The direction the blur should be applied.
  110247. * @param kernel The size of the kernel used to blur.
  110248. * @param options The required width/height ratio to downsize to before computing the render pass.
  110249. * @param camera The camera to apply the render pass to.
  110250. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  110251. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  110252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110253. * @param engine The engine which the post process will be applied. (default: current engine)
  110254. * @param reusable If the post process can be reused on the same frame. (default: false)
  110255. * @param textureType Type of textures used when performing the post process. (default: 0)
  110256. * @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)
  110257. */
  110258. 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);
  110259. }
  110260. }
  110261. declare module BABYLON {
  110262. /** @hidden */
  110263. export var depthOfFieldMergePixelShader: {
  110264. name: string;
  110265. shader: string;
  110266. };
  110267. }
  110268. declare module BABYLON {
  110269. /**
  110270. * Options to be set when merging outputs from the default pipeline.
  110271. */
  110272. export class DepthOfFieldMergePostProcessOptions {
  110273. /**
  110274. * The original image to merge on top of
  110275. */
  110276. originalFromInput: PostProcess;
  110277. /**
  110278. * Parameters to perform the merge of the depth of field effect
  110279. */
  110280. depthOfField?: {
  110281. circleOfConfusion: PostProcess;
  110282. blurSteps: Array<PostProcess>;
  110283. };
  110284. /**
  110285. * Parameters to perform the merge of bloom effect
  110286. */
  110287. bloom?: {
  110288. blurred: PostProcess;
  110289. weight: number;
  110290. };
  110291. }
  110292. /**
  110293. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  110294. */
  110295. export class DepthOfFieldMergePostProcess extends PostProcess {
  110296. private blurSteps;
  110297. /**
  110298. * Creates a new instance of DepthOfFieldMergePostProcess
  110299. * @param name The name of the effect.
  110300. * @param originalFromInput Post process which's input will be used for the merge.
  110301. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  110302. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  110303. * @param options The required width/height ratio to downsize to before computing the render pass.
  110304. * @param camera The camera to apply the render pass to.
  110305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110306. * @param engine The engine which the post process will be applied. (default: current engine)
  110307. * @param reusable If the post process can be reused on the same frame. (default: false)
  110308. * @param textureType Type of textures used when performing the post process. (default: 0)
  110309. * @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)
  110310. */
  110311. 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);
  110312. /**
  110313. * Updates the effect with the current post process compile time values and recompiles the shader.
  110314. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  110315. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  110316. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  110317. * @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
  110318. * @param onCompiled Called when the shader has been compiled.
  110319. * @param onError Called if there is an error when compiling a shader.
  110320. */
  110321. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  110322. }
  110323. }
  110324. declare module BABYLON {
  110325. /**
  110326. * Specifies the level of max blur that should be applied when using the depth of field effect
  110327. */
  110328. export enum DepthOfFieldEffectBlurLevel {
  110329. /**
  110330. * Subtle blur
  110331. */
  110332. Low = 0,
  110333. /**
  110334. * Medium blur
  110335. */
  110336. Medium = 1,
  110337. /**
  110338. * Large blur
  110339. */
  110340. High = 2
  110341. }
  110342. /**
  110343. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  110344. */
  110345. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  110346. private _circleOfConfusion;
  110347. /**
  110348. * @hidden Internal, blurs from high to low
  110349. */
  110350. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  110351. private _depthOfFieldBlurY;
  110352. private _dofMerge;
  110353. /**
  110354. * @hidden Internal post processes in depth of field effect
  110355. */
  110356. _effects: Array<PostProcess>;
  110357. /**
  110358. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  110359. */
  110360. focalLength: number;
  110361. /**
  110362. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  110363. */
  110364. fStop: number;
  110365. /**
  110366. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  110367. */
  110368. focusDistance: number;
  110369. /**
  110370. * 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.
  110371. */
  110372. lensSize: number;
  110373. /**
  110374. * Creates a new instance DepthOfFieldEffect
  110375. * @param scene The scene the effect belongs to.
  110376. * @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.
  110377. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  110378. * @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)
  110379. */
  110380. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  110381. /**
  110382. * 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.
  110383. */
  110384. depthTexture: RenderTargetTexture;
  110385. /**
  110386. * Disposes each of the internal effects for a given camera.
  110387. * @param camera The camera to dispose the effect on.
  110388. */
  110389. disposeEffects(camera: Camera): void;
  110390. /**
  110391. * @hidden Internal
  110392. */
  110393. _updateEffects(): void;
  110394. /**
  110395. * Internal
  110396. * @returns if all the contained post processes are ready.
  110397. * @hidden
  110398. */
  110399. _isReady(): boolean;
  110400. }
  110401. }
  110402. declare module BABYLON {
  110403. /** @hidden */
  110404. export var displayPassPixelShader: {
  110405. name: string;
  110406. shader: string;
  110407. };
  110408. }
  110409. declare module BABYLON {
  110410. /**
  110411. * DisplayPassPostProcess which produces an output the same as it's input
  110412. */
  110413. export class DisplayPassPostProcess extends PostProcess {
  110414. /**
  110415. * Creates the DisplayPassPostProcess
  110416. * @param name The name of the effect.
  110417. * @param options The required width/height ratio to downsize to before computing the render pass.
  110418. * @param camera The camera to apply the render pass to.
  110419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110420. * @param engine The engine which the post process will be applied. (default: current engine)
  110421. * @param reusable If the post process can be reused on the same frame. (default: false)
  110422. */
  110423. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110424. }
  110425. }
  110426. declare module BABYLON {
  110427. /** @hidden */
  110428. export var filterPixelShader: {
  110429. name: string;
  110430. shader: string;
  110431. };
  110432. }
  110433. declare module BABYLON {
  110434. /**
  110435. * Applies a kernel filter to the image
  110436. */
  110437. export class FilterPostProcess extends PostProcess {
  110438. /** The matrix to be applied to the image */
  110439. kernelMatrix: Matrix;
  110440. /**
  110441. *
  110442. * @param name The name of the effect.
  110443. * @param kernelMatrix The matrix to be applied to the image
  110444. * @param options The required width/height ratio to downsize to before computing the render pass.
  110445. * @param camera The camera to apply the render pass to.
  110446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110447. * @param engine The engine which the post process will be applied. (default: current engine)
  110448. * @param reusable If the post process can be reused on the same frame. (default: false)
  110449. */
  110450. constructor(name: string,
  110451. /** The matrix to be applied to the image */
  110452. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110453. }
  110454. }
  110455. declare module BABYLON {
  110456. /** @hidden */
  110457. export var fxaaPixelShader: {
  110458. name: string;
  110459. shader: string;
  110460. };
  110461. }
  110462. declare module BABYLON {
  110463. /** @hidden */
  110464. export var fxaaVertexShader: {
  110465. name: string;
  110466. shader: string;
  110467. };
  110468. }
  110469. declare module BABYLON {
  110470. /**
  110471. * Fxaa post process
  110472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  110473. */
  110474. export class FxaaPostProcess extends PostProcess {
  110475. /** @hidden */
  110476. texelWidth: number;
  110477. /** @hidden */
  110478. texelHeight: number;
  110479. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110480. private _getDefines;
  110481. }
  110482. }
  110483. declare module BABYLON {
  110484. /** @hidden */
  110485. export var grainPixelShader: {
  110486. name: string;
  110487. shader: string;
  110488. };
  110489. }
  110490. declare module BABYLON {
  110491. /**
  110492. * The GrainPostProcess adds noise to the image at mid luminance levels
  110493. */
  110494. export class GrainPostProcess extends PostProcess {
  110495. /**
  110496. * The intensity of the grain added (default: 30)
  110497. */
  110498. intensity: number;
  110499. /**
  110500. * If the grain should be randomized on every frame
  110501. */
  110502. animated: boolean;
  110503. /**
  110504. * Creates a new instance of @see GrainPostProcess
  110505. * @param name The name of the effect.
  110506. * @param options The required width/height ratio to downsize to before computing the render pass.
  110507. * @param camera The camera to apply the render pass to.
  110508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110509. * @param engine The engine which the post process will be applied. (default: current engine)
  110510. * @param reusable If the post process can be reused on the same frame. (default: false)
  110511. * @param textureType Type of textures used when performing the post process. (default: 0)
  110512. * @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)
  110513. */
  110514. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110515. }
  110516. }
  110517. declare module BABYLON {
  110518. /** @hidden */
  110519. export var highlightsPixelShader: {
  110520. name: string;
  110521. shader: string;
  110522. };
  110523. }
  110524. declare module BABYLON {
  110525. /**
  110526. * Extracts highlights from the image
  110527. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110528. */
  110529. export class HighlightsPostProcess extends PostProcess {
  110530. /**
  110531. * Extracts highlights from the image
  110532. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110533. * @param name The name of the effect.
  110534. * @param options The required width/height ratio to downsize to before computing the render pass.
  110535. * @param camera The camera to apply the render pass to.
  110536. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110537. * @param engine The engine which the post process will be applied. (default: current engine)
  110538. * @param reusable If the post process can be reused on the same frame. (default: false)
  110539. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  110540. */
  110541. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110542. }
  110543. }
  110544. declare module BABYLON {
  110545. /** @hidden */
  110546. export var mrtFragmentDeclaration: {
  110547. name: string;
  110548. shader: string;
  110549. };
  110550. }
  110551. declare module BABYLON {
  110552. /** @hidden */
  110553. export var geometryPixelShader: {
  110554. name: string;
  110555. shader: string;
  110556. };
  110557. }
  110558. declare module BABYLON {
  110559. /** @hidden */
  110560. export var geometryVertexShader: {
  110561. name: string;
  110562. shader: string;
  110563. };
  110564. }
  110565. declare module BABYLON {
  110566. /**
  110567. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  110568. */
  110569. export class GeometryBufferRenderer {
  110570. /**
  110571. * Constant used to retrieve the position texture index in the G-Buffer textures array
  110572. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  110573. */
  110574. static readonly POSITION_TEXTURE_TYPE: number;
  110575. /**
  110576. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  110577. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  110578. */
  110579. static readonly VELOCITY_TEXTURE_TYPE: number;
  110580. /**
  110581. * Dictionary used to store the previous transformation matrices of each rendered mesh
  110582. * in order to compute objects velocities when enableVelocity is set to "true"
  110583. * @hidden
  110584. */
  110585. _previousTransformationMatrices: {
  110586. [index: number]: Matrix;
  110587. };
  110588. private _scene;
  110589. private _multiRenderTarget;
  110590. private _ratio;
  110591. private _enablePosition;
  110592. private _enableVelocity;
  110593. private _positionIndex;
  110594. private _velocityIndex;
  110595. protected _effect: Effect;
  110596. protected _cachedDefines: string;
  110597. /**
  110598. * Set the render list (meshes to be rendered) used in the G buffer.
  110599. */
  110600. renderList: Mesh[];
  110601. /**
  110602. * Gets wether or not G buffer are supported by the running hardware.
  110603. * This requires draw buffer supports
  110604. */
  110605. readonly isSupported: boolean;
  110606. /**
  110607. * Returns the index of the given texture type in the G-Buffer textures array
  110608. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  110609. * @returns the index of the given texture type in the G-Buffer textures array
  110610. */
  110611. getTextureIndex(textureType: number): number;
  110612. /**
  110613. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  110614. */
  110615. /**
  110616. * Sets whether or not objects positions are enabled for the G buffer.
  110617. */
  110618. enablePosition: boolean;
  110619. /**
  110620. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  110621. */
  110622. /**
  110623. * Sets wether or not objects velocities are enabled for the G buffer.
  110624. */
  110625. enableVelocity: boolean;
  110626. /**
  110627. * Gets the scene associated with the buffer.
  110628. */
  110629. readonly scene: Scene;
  110630. /**
  110631. * Gets the ratio used by the buffer during its creation.
  110632. * How big is the buffer related to the main canvas.
  110633. */
  110634. readonly ratio: number;
  110635. /** @hidden */
  110636. static _SceneComponentInitialization: (scene: Scene) => void;
  110637. /**
  110638. * Creates a new G Buffer for the scene
  110639. * @param scene The scene the buffer belongs to
  110640. * @param ratio How big is the buffer related to the main canvas.
  110641. */
  110642. constructor(scene: Scene, ratio?: number);
  110643. /**
  110644. * Checks wether everything is ready to render a submesh to the G buffer.
  110645. * @param subMesh the submesh to check readiness for
  110646. * @param useInstances is the mesh drawn using instance or not
  110647. * @returns true if ready otherwise false
  110648. */
  110649. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110650. /**
  110651. * Gets the current underlying G Buffer.
  110652. * @returns the buffer
  110653. */
  110654. getGBuffer(): MultiRenderTarget;
  110655. /**
  110656. * Gets the number of samples used to render the buffer (anti aliasing).
  110657. */
  110658. /**
  110659. * Sets the number of samples used to render the buffer (anti aliasing).
  110660. */
  110661. samples: number;
  110662. /**
  110663. * Disposes the renderer and frees up associated resources.
  110664. */
  110665. dispose(): void;
  110666. protected _createRenderTargets(): void;
  110667. }
  110668. }
  110669. declare module BABYLON {
  110670. interface Scene {
  110671. /** @hidden (Backing field) */
  110672. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110673. /**
  110674. * Gets or Sets the current geometry buffer associated to the scene.
  110675. */
  110676. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110677. /**
  110678. * Enables a GeometryBufferRender and associates it with the scene
  110679. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  110680. * @returns the GeometryBufferRenderer
  110681. */
  110682. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  110683. /**
  110684. * Disables the GeometryBufferRender associated with the scene
  110685. */
  110686. disableGeometryBufferRenderer(): void;
  110687. }
  110688. /**
  110689. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  110690. * in several rendering techniques.
  110691. */
  110692. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  110693. /**
  110694. * The component name helpful to identify the component in the list of scene components.
  110695. */
  110696. readonly name: string;
  110697. /**
  110698. * The scene the component belongs to.
  110699. */
  110700. scene: Scene;
  110701. /**
  110702. * Creates a new instance of the component for the given scene
  110703. * @param scene Defines the scene to register the component in
  110704. */
  110705. constructor(scene: Scene);
  110706. /**
  110707. * Registers the component in a given scene
  110708. */
  110709. register(): void;
  110710. /**
  110711. * Rebuilds the elements related to this component in case of
  110712. * context lost for instance.
  110713. */
  110714. rebuild(): void;
  110715. /**
  110716. * Disposes the component and the associated ressources
  110717. */
  110718. dispose(): void;
  110719. private _gatherRenderTargets;
  110720. }
  110721. }
  110722. declare module BABYLON {
  110723. /** @hidden */
  110724. export var motionBlurPixelShader: {
  110725. name: string;
  110726. shader: string;
  110727. };
  110728. }
  110729. declare module BABYLON {
  110730. /**
  110731. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  110732. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  110733. * As an example, all you have to do is to create the post-process:
  110734. * var mb = new BABYLON.MotionBlurPostProcess(
  110735. * 'mb', // The name of the effect.
  110736. * scene, // The scene containing the objects to blur according to their velocity.
  110737. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  110738. * camera // The camera to apply the render pass to.
  110739. * );
  110740. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  110741. */
  110742. export class MotionBlurPostProcess extends PostProcess {
  110743. /**
  110744. * Defines how much the image is blurred by the movement. Default value is equal to 1
  110745. */
  110746. motionStrength: number;
  110747. /**
  110748. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  110749. */
  110750. /**
  110751. * Sets the number of iterations to be used for motion blur quality
  110752. */
  110753. motionBlurSamples: number;
  110754. private _motionBlurSamples;
  110755. private _geometryBufferRenderer;
  110756. /**
  110757. * Creates a new instance MotionBlurPostProcess
  110758. * @param name The name of the effect.
  110759. * @param scene The scene containing the objects to blur according to their velocity.
  110760. * @param options The required width/height ratio to downsize to before computing the render pass.
  110761. * @param camera The camera to apply the render pass to.
  110762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110763. * @param engine The engine which the post process will be applied. (default: current engine)
  110764. * @param reusable If the post process can be reused on the same frame. (default: false)
  110765. * @param textureType Type of textures used when performing the post process. (default: 0)
  110766. * @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)
  110767. */
  110768. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110769. /**
  110770. * Disposes the post process.
  110771. * @param camera The camera to dispose the post process on.
  110772. */
  110773. dispose(camera?: Camera): void;
  110774. }
  110775. }
  110776. declare module BABYLON {
  110777. /** @hidden */
  110778. export var refractionPixelShader: {
  110779. name: string;
  110780. shader: string;
  110781. };
  110782. }
  110783. declare module BABYLON {
  110784. /**
  110785. * Post process which applies a refractin texture
  110786. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110787. */
  110788. export class RefractionPostProcess extends PostProcess {
  110789. /** the base color of the refraction (used to taint the rendering) */
  110790. color: Color3;
  110791. /** simulated refraction depth */
  110792. depth: number;
  110793. /** the coefficient of the base color (0 to remove base color tainting) */
  110794. colorLevel: number;
  110795. private _refTexture;
  110796. private _ownRefractionTexture;
  110797. /**
  110798. * Gets or sets the refraction texture
  110799. * Please note that you are responsible for disposing the texture if you set it manually
  110800. */
  110801. refractionTexture: Texture;
  110802. /**
  110803. * Initializes the RefractionPostProcess
  110804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110805. * @param name The name of the effect.
  110806. * @param refractionTextureUrl Url of the refraction texture to use
  110807. * @param color the base color of the refraction (used to taint the rendering)
  110808. * @param depth simulated refraction depth
  110809. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  110810. * @param camera The camera to apply the render pass to.
  110811. * @param options The required width/height ratio to downsize to before computing the render pass.
  110812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110813. * @param engine The engine which the post process will be applied. (default: current engine)
  110814. * @param reusable If the post process can be reused on the same frame. (default: false)
  110815. */
  110816. constructor(name: string, refractionTextureUrl: string,
  110817. /** the base color of the refraction (used to taint the rendering) */
  110818. color: Color3,
  110819. /** simulated refraction depth */
  110820. depth: number,
  110821. /** the coefficient of the base color (0 to remove base color tainting) */
  110822. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110823. /**
  110824. * Disposes of the post process
  110825. * @param camera Camera to dispose post process on
  110826. */
  110827. dispose(camera: Camera): void;
  110828. }
  110829. }
  110830. declare module BABYLON {
  110831. /** @hidden */
  110832. export var sharpenPixelShader: {
  110833. name: string;
  110834. shader: string;
  110835. };
  110836. }
  110837. declare module BABYLON {
  110838. /**
  110839. * The SharpenPostProcess applies a sharpen kernel to every pixel
  110840. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110841. */
  110842. export class SharpenPostProcess extends PostProcess {
  110843. /**
  110844. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  110845. */
  110846. colorAmount: number;
  110847. /**
  110848. * How much sharpness should be applied (default: 0.3)
  110849. */
  110850. edgeAmount: number;
  110851. /**
  110852. * Creates a new instance ConvolutionPostProcess
  110853. * @param name The name of the effect.
  110854. * @param options The required width/height ratio to downsize to before computing the render pass.
  110855. * @param camera The camera to apply the render pass to.
  110856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110857. * @param engine The engine which the post process will be applied. (default: current engine)
  110858. * @param reusable If the post process can be reused on the same frame. (default: false)
  110859. * @param textureType Type of textures used when performing the post process. (default: 0)
  110860. * @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)
  110861. */
  110862. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110863. }
  110864. }
  110865. declare module BABYLON {
  110866. /**
  110867. * PostProcessRenderPipeline
  110868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110869. */
  110870. export class PostProcessRenderPipeline {
  110871. private engine;
  110872. private _renderEffects;
  110873. private _renderEffectsForIsolatedPass;
  110874. /**
  110875. * List of inspectable custom properties (used by the Inspector)
  110876. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110877. */
  110878. inspectableCustomProperties: IInspectable[];
  110879. /**
  110880. * @hidden
  110881. */
  110882. protected _cameras: Camera[];
  110883. /** @hidden */
  110884. _name: string;
  110885. /**
  110886. * Gets pipeline name
  110887. */
  110888. readonly name: string;
  110889. /**
  110890. * Initializes a PostProcessRenderPipeline
  110891. * @param engine engine to add the pipeline to
  110892. * @param name name of the pipeline
  110893. */
  110894. constructor(engine: Engine, name: string);
  110895. /**
  110896. * Gets the class name
  110897. * @returns "PostProcessRenderPipeline"
  110898. */
  110899. getClassName(): string;
  110900. /**
  110901. * If all the render effects in the pipeline are supported
  110902. */
  110903. readonly isSupported: boolean;
  110904. /**
  110905. * Adds an effect to the pipeline
  110906. * @param renderEffect the effect to add
  110907. */
  110908. addEffect(renderEffect: PostProcessRenderEffect): void;
  110909. /** @hidden */
  110910. _rebuild(): void;
  110911. /** @hidden */
  110912. _enableEffect(renderEffectName: string, cameras: Camera): void;
  110913. /** @hidden */
  110914. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  110915. /** @hidden */
  110916. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110917. /** @hidden */
  110918. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110919. /** @hidden */
  110920. _attachCameras(cameras: Camera, unique: boolean): void;
  110921. /** @hidden */
  110922. _attachCameras(cameras: Camera[], unique: boolean): void;
  110923. /** @hidden */
  110924. _detachCameras(cameras: Camera): void;
  110925. /** @hidden */
  110926. _detachCameras(cameras: Nullable<Camera[]>): void;
  110927. /** @hidden */
  110928. _update(): void;
  110929. /** @hidden */
  110930. _reset(): void;
  110931. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  110932. /**
  110933. * Disposes of the pipeline
  110934. */
  110935. dispose(): void;
  110936. }
  110937. }
  110938. declare module BABYLON {
  110939. /**
  110940. * PostProcessRenderPipelineManager class
  110941. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110942. */
  110943. export class PostProcessRenderPipelineManager {
  110944. private _renderPipelines;
  110945. /**
  110946. * Initializes a PostProcessRenderPipelineManager
  110947. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110948. */
  110949. constructor();
  110950. /**
  110951. * Gets the list of supported render pipelines
  110952. */
  110953. readonly supportedPipelines: PostProcessRenderPipeline[];
  110954. /**
  110955. * Adds a pipeline to the manager
  110956. * @param renderPipeline The pipeline to add
  110957. */
  110958. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  110959. /**
  110960. * Attaches a camera to the pipeline
  110961. * @param renderPipelineName The name of the pipeline to attach to
  110962. * @param cameras the camera to attach
  110963. * @param unique if the camera can be attached multiple times to the pipeline
  110964. */
  110965. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  110966. /**
  110967. * Detaches a camera from the pipeline
  110968. * @param renderPipelineName The name of the pipeline to detach from
  110969. * @param cameras the camera to detach
  110970. */
  110971. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  110972. /**
  110973. * Enables an effect by name on a pipeline
  110974. * @param renderPipelineName the name of the pipeline to enable the effect in
  110975. * @param renderEffectName the name of the effect to enable
  110976. * @param cameras the cameras that the effect should be enabled on
  110977. */
  110978. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110979. /**
  110980. * Disables an effect by name on a pipeline
  110981. * @param renderPipelineName the name of the pipeline to disable the effect in
  110982. * @param renderEffectName the name of the effect to disable
  110983. * @param cameras the cameras that the effect should be disabled on
  110984. */
  110985. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110986. /**
  110987. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  110988. */
  110989. update(): void;
  110990. /** @hidden */
  110991. _rebuild(): void;
  110992. /**
  110993. * Disposes of the manager and pipelines
  110994. */
  110995. dispose(): void;
  110996. }
  110997. }
  110998. declare module BABYLON {
  110999. interface Scene {
  111000. /** @hidden (Backing field) */
  111001. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  111002. /**
  111003. * Gets the postprocess render pipeline manager
  111004. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111005. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  111006. */
  111007. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  111008. }
  111009. /**
  111010. * Defines the Render Pipeline scene component responsible to rendering pipelines
  111011. */
  111012. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  111013. /**
  111014. * The component name helpfull to identify the component in the list of scene components.
  111015. */
  111016. readonly name: string;
  111017. /**
  111018. * The scene the component belongs to.
  111019. */
  111020. scene: Scene;
  111021. /**
  111022. * Creates a new instance of the component for the given scene
  111023. * @param scene Defines the scene to register the component in
  111024. */
  111025. constructor(scene: Scene);
  111026. /**
  111027. * Registers the component in a given scene
  111028. */
  111029. register(): void;
  111030. /**
  111031. * Rebuilds the elements related to this component in case of
  111032. * context lost for instance.
  111033. */
  111034. rebuild(): void;
  111035. /**
  111036. * Disposes the component and the associated ressources
  111037. */
  111038. dispose(): void;
  111039. private _gatherRenderTargets;
  111040. }
  111041. }
  111042. declare module BABYLON {
  111043. /**
  111044. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  111045. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  111046. */
  111047. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111048. private _scene;
  111049. private _camerasToBeAttached;
  111050. /**
  111051. * ID of the sharpen post process,
  111052. */
  111053. private readonly SharpenPostProcessId;
  111054. /**
  111055. * @ignore
  111056. * ID of the image processing post process;
  111057. */
  111058. readonly ImageProcessingPostProcessId: string;
  111059. /**
  111060. * @ignore
  111061. * ID of the Fast Approximate Anti-Aliasing post process;
  111062. */
  111063. readonly FxaaPostProcessId: string;
  111064. /**
  111065. * ID of the chromatic aberration post process,
  111066. */
  111067. private readonly ChromaticAberrationPostProcessId;
  111068. /**
  111069. * ID of the grain post process
  111070. */
  111071. private readonly GrainPostProcessId;
  111072. /**
  111073. * Sharpen post process which will apply a sharpen convolution to enhance edges
  111074. */
  111075. sharpen: SharpenPostProcess;
  111076. private _sharpenEffect;
  111077. private bloom;
  111078. /**
  111079. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  111080. */
  111081. depthOfField: DepthOfFieldEffect;
  111082. /**
  111083. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111084. */
  111085. fxaa: FxaaPostProcess;
  111086. /**
  111087. * Image post processing pass used to perform operations such as tone mapping or color grading.
  111088. */
  111089. imageProcessing: ImageProcessingPostProcess;
  111090. /**
  111091. * Chromatic aberration post process which will shift rgb colors in the image
  111092. */
  111093. chromaticAberration: ChromaticAberrationPostProcess;
  111094. private _chromaticAberrationEffect;
  111095. /**
  111096. * Grain post process which add noise to the image
  111097. */
  111098. grain: GrainPostProcess;
  111099. private _grainEffect;
  111100. /**
  111101. * Glow post process which adds a glow to emissive areas of the image
  111102. */
  111103. private _glowLayer;
  111104. /**
  111105. * Animations which can be used to tweak settings over a period of time
  111106. */
  111107. animations: Animation[];
  111108. private _imageProcessingConfigurationObserver;
  111109. private _sharpenEnabled;
  111110. private _bloomEnabled;
  111111. private _depthOfFieldEnabled;
  111112. private _depthOfFieldBlurLevel;
  111113. private _fxaaEnabled;
  111114. private _imageProcessingEnabled;
  111115. private _defaultPipelineTextureType;
  111116. private _bloomScale;
  111117. private _chromaticAberrationEnabled;
  111118. private _grainEnabled;
  111119. private _buildAllowed;
  111120. /**
  111121. * Gets active scene
  111122. */
  111123. readonly scene: Scene;
  111124. /**
  111125. * Enable or disable the sharpen process from the pipeline
  111126. */
  111127. sharpenEnabled: boolean;
  111128. private _resizeObserver;
  111129. private _hardwareScaleLevel;
  111130. private _bloomKernel;
  111131. /**
  111132. * Specifies the size of the bloom blur kernel, relative to the final output size
  111133. */
  111134. bloomKernel: number;
  111135. /**
  111136. * Specifies the weight of the bloom in the final rendering
  111137. */
  111138. private _bloomWeight;
  111139. /**
  111140. * Specifies the luma threshold for the area that will be blurred by the bloom
  111141. */
  111142. private _bloomThreshold;
  111143. private _hdr;
  111144. /**
  111145. * The strength of the bloom.
  111146. */
  111147. bloomWeight: number;
  111148. /**
  111149. * The strength of the bloom.
  111150. */
  111151. bloomThreshold: number;
  111152. /**
  111153. * The scale of the bloom, lower value will provide better performance.
  111154. */
  111155. bloomScale: number;
  111156. /**
  111157. * Enable or disable the bloom from the pipeline
  111158. */
  111159. bloomEnabled: boolean;
  111160. private _rebuildBloom;
  111161. /**
  111162. * If the depth of field is enabled.
  111163. */
  111164. depthOfFieldEnabled: boolean;
  111165. /**
  111166. * Blur level of the depth of field effect. (Higher blur will effect performance)
  111167. */
  111168. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  111169. /**
  111170. * If the anti aliasing is enabled.
  111171. */
  111172. fxaaEnabled: boolean;
  111173. private _samples;
  111174. /**
  111175. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111176. */
  111177. samples: number;
  111178. /**
  111179. * If image processing is enabled.
  111180. */
  111181. imageProcessingEnabled: boolean;
  111182. /**
  111183. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  111184. */
  111185. glowLayerEnabled: boolean;
  111186. /**
  111187. * Enable or disable the chromaticAberration process from the pipeline
  111188. */
  111189. chromaticAberrationEnabled: boolean;
  111190. /**
  111191. * Enable or disable the grain process from the pipeline
  111192. */
  111193. grainEnabled: boolean;
  111194. /**
  111195. * @constructor
  111196. * @param name - The rendering pipeline name (default: "")
  111197. * @param hdr - If high dynamic range textures should be used (default: true)
  111198. * @param scene - The scene linked to this pipeline (default: the last created scene)
  111199. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  111200. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  111201. */
  111202. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  111203. /**
  111204. * Get the class name
  111205. * @returns "DefaultRenderingPipeline"
  111206. */
  111207. getClassName(): string;
  111208. /**
  111209. * Force the compilation of the entire pipeline.
  111210. */
  111211. prepare(): void;
  111212. private _hasCleared;
  111213. private _prevPostProcess;
  111214. private _prevPrevPostProcess;
  111215. private _setAutoClearAndTextureSharing;
  111216. private _depthOfFieldSceneObserver;
  111217. private _buildPipeline;
  111218. private _disposePostProcesses;
  111219. /**
  111220. * Adds a camera to the pipeline
  111221. * @param camera the camera to be added
  111222. */
  111223. addCamera(camera: Camera): void;
  111224. /**
  111225. * Removes a camera from the pipeline
  111226. * @param camera the camera to remove
  111227. */
  111228. removeCamera(camera: Camera): void;
  111229. /**
  111230. * Dispose of the pipeline and stop all post processes
  111231. */
  111232. dispose(): void;
  111233. /**
  111234. * Serialize the rendering pipeline (Used when exporting)
  111235. * @returns the serialized object
  111236. */
  111237. serialize(): any;
  111238. /**
  111239. * Parse the serialized pipeline
  111240. * @param source Source pipeline.
  111241. * @param scene The scene to load the pipeline to.
  111242. * @param rootUrl The URL of the serialized pipeline.
  111243. * @returns An instantiated pipeline from the serialized object.
  111244. */
  111245. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  111246. }
  111247. }
  111248. declare module BABYLON {
  111249. /** @hidden */
  111250. export var lensHighlightsPixelShader: {
  111251. name: string;
  111252. shader: string;
  111253. };
  111254. }
  111255. declare module BABYLON {
  111256. /** @hidden */
  111257. export var depthOfFieldPixelShader: {
  111258. name: string;
  111259. shader: string;
  111260. };
  111261. }
  111262. declare module BABYLON {
  111263. /**
  111264. * BABYLON.JS Chromatic Aberration GLSL Shader
  111265. * Author: Olivier Guyot
  111266. * Separates very slightly R, G and B colors on the edges of the screen
  111267. * Inspired by Francois Tarlier & Martins Upitis
  111268. */
  111269. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  111270. /**
  111271. * @ignore
  111272. * The chromatic aberration PostProcess id in the pipeline
  111273. */
  111274. LensChromaticAberrationEffect: string;
  111275. /**
  111276. * @ignore
  111277. * The highlights enhancing PostProcess id in the pipeline
  111278. */
  111279. HighlightsEnhancingEffect: string;
  111280. /**
  111281. * @ignore
  111282. * The depth-of-field PostProcess id in the pipeline
  111283. */
  111284. LensDepthOfFieldEffect: string;
  111285. private _scene;
  111286. private _depthTexture;
  111287. private _grainTexture;
  111288. private _chromaticAberrationPostProcess;
  111289. private _highlightsPostProcess;
  111290. private _depthOfFieldPostProcess;
  111291. private _edgeBlur;
  111292. private _grainAmount;
  111293. private _chromaticAberration;
  111294. private _distortion;
  111295. private _highlightsGain;
  111296. private _highlightsThreshold;
  111297. private _dofDistance;
  111298. private _dofAperture;
  111299. private _dofDarken;
  111300. private _dofPentagon;
  111301. private _blurNoise;
  111302. /**
  111303. * @constructor
  111304. *
  111305. * Effect parameters are as follow:
  111306. * {
  111307. * chromatic_aberration: number; // from 0 to x (1 for realism)
  111308. * edge_blur: number; // from 0 to x (1 for realism)
  111309. * distortion: number; // from 0 to x (1 for realism)
  111310. * grain_amount: number; // from 0 to 1
  111311. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  111312. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  111313. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  111314. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  111315. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  111316. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  111317. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  111318. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  111319. * }
  111320. * Note: if an effect parameter is unset, effect is disabled
  111321. *
  111322. * @param name The rendering pipeline name
  111323. * @param parameters - An object containing all parameters (see above)
  111324. * @param scene The scene linked to this pipeline
  111325. * @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)
  111326. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111327. */
  111328. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  111329. /**
  111330. * Get the class name
  111331. * @returns "LensRenderingPipeline"
  111332. */
  111333. getClassName(): string;
  111334. /**
  111335. * Gets associated scene
  111336. */
  111337. readonly scene: Scene;
  111338. /**
  111339. * Gets or sets the edge blur
  111340. */
  111341. edgeBlur: number;
  111342. /**
  111343. * Gets or sets the grain amount
  111344. */
  111345. grainAmount: number;
  111346. /**
  111347. * Gets or sets the chromatic aberration amount
  111348. */
  111349. chromaticAberration: number;
  111350. /**
  111351. * Gets or sets the depth of field aperture
  111352. */
  111353. dofAperture: number;
  111354. /**
  111355. * Gets or sets the edge distortion
  111356. */
  111357. edgeDistortion: number;
  111358. /**
  111359. * Gets or sets the depth of field distortion
  111360. */
  111361. dofDistortion: number;
  111362. /**
  111363. * Gets or sets the darken out of focus amount
  111364. */
  111365. darkenOutOfFocus: number;
  111366. /**
  111367. * Gets or sets a boolean indicating if blur noise is enabled
  111368. */
  111369. blurNoise: boolean;
  111370. /**
  111371. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  111372. */
  111373. pentagonBokeh: boolean;
  111374. /**
  111375. * Gets or sets the highlight grain amount
  111376. */
  111377. highlightsGain: number;
  111378. /**
  111379. * Gets or sets the highlight threshold
  111380. */
  111381. highlightsThreshold: number;
  111382. /**
  111383. * Sets the amount of blur at the edges
  111384. * @param amount blur amount
  111385. */
  111386. setEdgeBlur(amount: number): void;
  111387. /**
  111388. * Sets edge blur to 0
  111389. */
  111390. disableEdgeBlur(): void;
  111391. /**
  111392. * Sets the amout of grain
  111393. * @param amount Amount of grain
  111394. */
  111395. setGrainAmount(amount: number): void;
  111396. /**
  111397. * Set grain amount to 0
  111398. */
  111399. disableGrain(): void;
  111400. /**
  111401. * Sets the chromatic aberration amount
  111402. * @param amount amount of chromatic aberration
  111403. */
  111404. setChromaticAberration(amount: number): void;
  111405. /**
  111406. * Sets chromatic aberration amount to 0
  111407. */
  111408. disableChromaticAberration(): void;
  111409. /**
  111410. * Sets the EdgeDistortion amount
  111411. * @param amount amount of EdgeDistortion
  111412. */
  111413. setEdgeDistortion(amount: number): void;
  111414. /**
  111415. * Sets edge distortion to 0
  111416. */
  111417. disableEdgeDistortion(): void;
  111418. /**
  111419. * Sets the FocusDistance amount
  111420. * @param amount amount of FocusDistance
  111421. */
  111422. setFocusDistance(amount: number): void;
  111423. /**
  111424. * Disables depth of field
  111425. */
  111426. disableDepthOfField(): void;
  111427. /**
  111428. * Sets the Aperture amount
  111429. * @param amount amount of Aperture
  111430. */
  111431. setAperture(amount: number): void;
  111432. /**
  111433. * Sets the DarkenOutOfFocus amount
  111434. * @param amount amount of DarkenOutOfFocus
  111435. */
  111436. setDarkenOutOfFocus(amount: number): void;
  111437. private _pentagonBokehIsEnabled;
  111438. /**
  111439. * Creates a pentagon bokeh effect
  111440. */
  111441. enablePentagonBokeh(): void;
  111442. /**
  111443. * Disables the pentagon bokeh effect
  111444. */
  111445. disablePentagonBokeh(): void;
  111446. /**
  111447. * Enables noise blur
  111448. */
  111449. enableNoiseBlur(): void;
  111450. /**
  111451. * Disables noise blur
  111452. */
  111453. disableNoiseBlur(): void;
  111454. /**
  111455. * Sets the HighlightsGain amount
  111456. * @param amount amount of HighlightsGain
  111457. */
  111458. setHighlightsGain(amount: number): void;
  111459. /**
  111460. * Sets the HighlightsThreshold amount
  111461. * @param amount amount of HighlightsThreshold
  111462. */
  111463. setHighlightsThreshold(amount: number): void;
  111464. /**
  111465. * Disables highlights
  111466. */
  111467. disableHighlights(): void;
  111468. /**
  111469. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  111470. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  111471. */
  111472. dispose(disableDepthRender?: boolean): void;
  111473. private _createChromaticAberrationPostProcess;
  111474. private _createHighlightsPostProcess;
  111475. private _createDepthOfFieldPostProcess;
  111476. private _createGrainTexture;
  111477. }
  111478. }
  111479. declare module BABYLON {
  111480. /** @hidden */
  111481. export var ssao2PixelShader: {
  111482. name: string;
  111483. shader: string;
  111484. };
  111485. }
  111486. declare module BABYLON {
  111487. /** @hidden */
  111488. export var ssaoCombinePixelShader: {
  111489. name: string;
  111490. shader: string;
  111491. };
  111492. }
  111493. declare module BABYLON {
  111494. /**
  111495. * Render pipeline to produce ssao effect
  111496. */
  111497. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  111498. /**
  111499. * @ignore
  111500. * The PassPostProcess id in the pipeline that contains the original scene color
  111501. */
  111502. SSAOOriginalSceneColorEffect: string;
  111503. /**
  111504. * @ignore
  111505. * The SSAO PostProcess id in the pipeline
  111506. */
  111507. SSAORenderEffect: string;
  111508. /**
  111509. * @ignore
  111510. * The horizontal blur PostProcess id in the pipeline
  111511. */
  111512. SSAOBlurHRenderEffect: string;
  111513. /**
  111514. * @ignore
  111515. * The vertical blur PostProcess id in the pipeline
  111516. */
  111517. SSAOBlurVRenderEffect: string;
  111518. /**
  111519. * @ignore
  111520. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111521. */
  111522. SSAOCombineRenderEffect: string;
  111523. /**
  111524. * The output strength of the SSAO post-process. Default value is 1.0.
  111525. */
  111526. totalStrength: number;
  111527. /**
  111528. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  111529. */
  111530. maxZ: number;
  111531. /**
  111532. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  111533. */
  111534. minZAspect: number;
  111535. private _samples;
  111536. /**
  111537. * Number of samples used for the SSAO calculations. Default value is 8
  111538. */
  111539. samples: number;
  111540. private _textureSamples;
  111541. /**
  111542. * Number of samples to use for antialiasing
  111543. */
  111544. textureSamples: number;
  111545. /**
  111546. * Ratio object used for SSAO ratio and blur ratio
  111547. */
  111548. private _ratio;
  111549. /**
  111550. * Dynamically generated sphere sampler.
  111551. */
  111552. private _sampleSphere;
  111553. /**
  111554. * Blur filter offsets
  111555. */
  111556. private _samplerOffsets;
  111557. private _expensiveBlur;
  111558. /**
  111559. * If bilateral blur should be used
  111560. */
  111561. expensiveBlur: boolean;
  111562. /**
  111563. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  111564. */
  111565. radius: number;
  111566. /**
  111567. * The base color of the SSAO post-process
  111568. * The final result is "base + ssao" between [0, 1]
  111569. */
  111570. base: number;
  111571. /**
  111572. * Support test.
  111573. */
  111574. static readonly IsSupported: boolean;
  111575. private _scene;
  111576. private _depthTexture;
  111577. private _normalTexture;
  111578. private _randomTexture;
  111579. private _originalColorPostProcess;
  111580. private _ssaoPostProcess;
  111581. private _blurHPostProcess;
  111582. private _blurVPostProcess;
  111583. private _ssaoCombinePostProcess;
  111584. private _firstUpdate;
  111585. /**
  111586. * Gets active scene
  111587. */
  111588. readonly scene: Scene;
  111589. /**
  111590. * @constructor
  111591. * @param name The rendering pipeline name
  111592. * @param scene The scene linked to this pipeline
  111593. * @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 }
  111594. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111595. */
  111596. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111597. /**
  111598. * Get the class name
  111599. * @returns "SSAO2RenderingPipeline"
  111600. */
  111601. getClassName(): string;
  111602. /**
  111603. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111604. */
  111605. dispose(disableGeometryBufferRenderer?: boolean): void;
  111606. private _createBlurPostProcess;
  111607. /** @hidden */
  111608. _rebuild(): void;
  111609. private _bits;
  111610. private _radicalInverse_VdC;
  111611. private _hammersley;
  111612. private _hemisphereSample_uniform;
  111613. private _generateHemisphere;
  111614. private _createSSAOPostProcess;
  111615. private _createSSAOCombinePostProcess;
  111616. private _createRandomTexture;
  111617. /**
  111618. * Serialize the rendering pipeline (Used when exporting)
  111619. * @returns the serialized object
  111620. */
  111621. serialize(): any;
  111622. /**
  111623. * Parse the serialized pipeline
  111624. * @param source Source pipeline.
  111625. * @param scene The scene to load the pipeline to.
  111626. * @param rootUrl The URL of the serialized pipeline.
  111627. * @returns An instantiated pipeline from the serialized object.
  111628. */
  111629. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  111630. }
  111631. }
  111632. declare module BABYLON {
  111633. /** @hidden */
  111634. export var ssaoPixelShader: {
  111635. name: string;
  111636. shader: string;
  111637. };
  111638. }
  111639. declare module BABYLON {
  111640. /**
  111641. * Render pipeline to produce ssao effect
  111642. */
  111643. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  111644. /**
  111645. * @ignore
  111646. * The PassPostProcess id in the pipeline that contains the original scene color
  111647. */
  111648. SSAOOriginalSceneColorEffect: string;
  111649. /**
  111650. * @ignore
  111651. * The SSAO PostProcess id in the pipeline
  111652. */
  111653. SSAORenderEffect: string;
  111654. /**
  111655. * @ignore
  111656. * The horizontal blur PostProcess id in the pipeline
  111657. */
  111658. SSAOBlurHRenderEffect: string;
  111659. /**
  111660. * @ignore
  111661. * The vertical blur PostProcess id in the pipeline
  111662. */
  111663. SSAOBlurVRenderEffect: string;
  111664. /**
  111665. * @ignore
  111666. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111667. */
  111668. SSAOCombineRenderEffect: string;
  111669. /**
  111670. * The output strength of the SSAO post-process. Default value is 1.0.
  111671. */
  111672. totalStrength: number;
  111673. /**
  111674. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  111675. */
  111676. radius: number;
  111677. /**
  111678. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  111679. * Must not be equal to fallOff and superior to fallOff.
  111680. * Default value is 0.0075
  111681. */
  111682. area: number;
  111683. /**
  111684. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  111685. * Must not be equal to area and inferior to area.
  111686. * Default value is 0.000001
  111687. */
  111688. fallOff: number;
  111689. /**
  111690. * The base color of the SSAO post-process
  111691. * The final result is "base + ssao" between [0, 1]
  111692. */
  111693. base: number;
  111694. private _scene;
  111695. private _depthTexture;
  111696. private _randomTexture;
  111697. private _originalColorPostProcess;
  111698. private _ssaoPostProcess;
  111699. private _blurHPostProcess;
  111700. private _blurVPostProcess;
  111701. private _ssaoCombinePostProcess;
  111702. private _firstUpdate;
  111703. /**
  111704. * Gets active scene
  111705. */
  111706. readonly scene: Scene;
  111707. /**
  111708. * @constructor
  111709. * @param name - The rendering pipeline name
  111710. * @param scene - The scene linked to this pipeline
  111711. * @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 }
  111712. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  111713. */
  111714. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111715. /**
  111716. * Get the class name
  111717. * @returns "SSAORenderingPipeline"
  111718. */
  111719. getClassName(): string;
  111720. /**
  111721. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111722. */
  111723. dispose(disableDepthRender?: boolean): void;
  111724. private _createBlurPostProcess;
  111725. /** @hidden */
  111726. _rebuild(): void;
  111727. private _createSSAOPostProcess;
  111728. private _createSSAOCombinePostProcess;
  111729. private _createRandomTexture;
  111730. }
  111731. }
  111732. declare module BABYLON {
  111733. /** @hidden */
  111734. export var standardPixelShader: {
  111735. name: string;
  111736. shader: string;
  111737. };
  111738. }
  111739. declare module BABYLON {
  111740. /**
  111741. * Standard rendering pipeline
  111742. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111743. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  111744. */
  111745. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111746. /**
  111747. * Public members
  111748. */
  111749. /**
  111750. * Post-process which contains the original scene color before the pipeline applies all the effects
  111751. */
  111752. originalPostProcess: Nullable<PostProcess>;
  111753. /**
  111754. * Post-process used to down scale an image x4
  111755. */
  111756. downSampleX4PostProcess: Nullable<PostProcess>;
  111757. /**
  111758. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  111759. */
  111760. brightPassPostProcess: Nullable<PostProcess>;
  111761. /**
  111762. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  111763. */
  111764. blurHPostProcesses: PostProcess[];
  111765. /**
  111766. * Post-process array storing all the vertical blur post-processes used by the pipeline
  111767. */
  111768. blurVPostProcesses: PostProcess[];
  111769. /**
  111770. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  111771. */
  111772. textureAdderPostProcess: Nullable<PostProcess>;
  111773. /**
  111774. * Post-process used to create volumetric lighting effect
  111775. */
  111776. volumetricLightPostProcess: Nullable<PostProcess>;
  111777. /**
  111778. * Post-process used to smooth the previous volumetric light post-process on the X axis
  111779. */
  111780. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  111781. /**
  111782. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  111783. */
  111784. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  111785. /**
  111786. * Post-process used to merge the volumetric light effect and the real scene color
  111787. */
  111788. volumetricLightMergePostProces: Nullable<PostProcess>;
  111789. /**
  111790. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  111791. */
  111792. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  111793. /**
  111794. * Base post-process used to calculate the average luminance of the final image for HDR
  111795. */
  111796. luminancePostProcess: Nullable<PostProcess>;
  111797. /**
  111798. * Post-processes used to create down sample post-processes in order to get
  111799. * the average luminance of the final image for HDR
  111800. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  111801. */
  111802. luminanceDownSamplePostProcesses: PostProcess[];
  111803. /**
  111804. * Post-process used to create a HDR effect (light adaptation)
  111805. */
  111806. hdrPostProcess: Nullable<PostProcess>;
  111807. /**
  111808. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  111809. */
  111810. textureAdderFinalPostProcess: Nullable<PostProcess>;
  111811. /**
  111812. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  111813. */
  111814. lensFlareFinalPostProcess: Nullable<PostProcess>;
  111815. /**
  111816. * Post-process used to merge the final HDR post-process and the real scene color
  111817. */
  111818. hdrFinalPostProcess: Nullable<PostProcess>;
  111819. /**
  111820. * Post-process used to create a lens flare effect
  111821. */
  111822. lensFlarePostProcess: Nullable<PostProcess>;
  111823. /**
  111824. * Post-process that merges the result of the lens flare post-process and the real scene color
  111825. */
  111826. lensFlareComposePostProcess: Nullable<PostProcess>;
  111827. /**
  111828. * Post-process used to create a motion blur effect
  111829. */
  111830. motionBlurPostProcess: Nullable<PostProcess>;
  111831. /**
  111832. * Post-process used to create a depth of field effect
  111833. */
  111834. depthOfFieldPostProcess: Nullable<PostProcess>;
  111835. /**
  111836. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111837. */
  111838. fxaaPostProcess: Nullable<FxaaPostProcess>;
  111839. /**
  111840. * Represents the brightness threshold in order to configure the illuminated surfaces
  111841. */
  111842. brightThreshold: number;
  111843. /**
  111844. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  111845. */
  111846. blurWidth: number;
  111847. /**
  111848. * Sets if the blur for highlighted surfaces must be only horizontal
  111849. */
  111850. horizontalBlur: boolean;
  111851. /**
  111852. * Sets the overall exposure used by the pipeline
  111853. */
  111854. exposure: number;
  111855. /**
  111856. * Texture used typically to simulate "dirty" on camera lens
  111857. */
  111858. lensTexture: Nullable<Texture>;
  111859. /**
  111860. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  111861. */
  111862. volumetricLightCoefficient: number;
  111863. /**
  111864. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  111865. */
  111866. volumetricLightPower: number;
  111867. /**
  111868. * Used the set the blur intensity to smooth the volumetric lights
  111869. */
  111870. volumetricLightBlurScale: number;
  111871. /**
  111872. * Light (spot or directional) used to generate the volumetric lights rays
  111873. * The source light must have a shadow generate so the pipeline can get its
  111874. * depth map
  111875. */
  111876. sourceLight: Nullable<SpotLight | DirectionalLight>;
  111877. /**
  111878. * For eye adaptation, represents the minimum luminance the eye can see
  111879. */
  111880. hdrMinimumLuminance: number;
  111881. /**
  111882. * For eye adaptation, represents the decrease luminance speed
  111883. */
  111884. hdrDecreaseRate: number;
  111885. /**
  111886. * For eye adaptation, represents the increase luminance speed
  111887. */
  111888. hdrIncreaseRate: number;
  111889. /**
  111890. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  111891. */
  111892. lensColorTexture: Nullable<Texture>;
  111893. /**
  111894. * The overall strengh for the lens flare effect
  111895. */
  111896. lensFlareStrength: number;
  111897. /**
  111898. * Dispersion coefficient for lens flare ghosts
  111899. */
  111900. lensFlareGhostDispersal: number;
  111901. /**
  111902. * Main lens flare halo width
  111903. */
  111904. lensFlareHaloWidth: number;
  111905. /**
  111906. * Based on the lens distortion effect, defines how much the lens flare result
  111907. * is distorted
  111908. */
  111909. lensFlareDistortionStrength: number;
  111910. /**
  111911. * Lens star texture must be used to simulate rays on the flares and is available
  111912. * in the documentation
  111913. */
  111914. lensStarTexture: Nullable<Texture>;
  111915. /**
  111916. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  111917. * flare effect by taking account of the dirt texture
  111918. */
  111919. lensFlareDirtTexture: Nullable<Texture>;
  111920. /**
  111921. * Represents the focal length for the depth of field effect
  111922. */
  111923. depthOfFieldDistance: number;
  111924. /**
  111925. * Represents the blur intensity for the blurred part of the depth of field effect
  111926. */
  111927. depthOfFieldBlurWidth: number;
  111928. /**
  111929. * For motion blur, defines how much the image is blurred by the movement
  111930. */
  111931. motionStrength: number;
  111932. /**
  111933. * List of animations for the pipeline (IAnimatable implementation)
  111934. */
  111935. animations: Animation[];
  111936. /**
  111937. * Private members
  111938. */
  111939. private _scene;
  111940. private _currentDepthOfFieldSource;
  111941. private _basePostProcess;
  111942. private _hdrCurrentLuminance;
  111943. private _floatTextureType;
  111944. private _ratio;
  111945. private _bloomEnabled;
  111946. private _depthOfFieldEnabled;
  111947. private _vlsEnabled;
  111948. private _lensFlareEnabled;
  111949. private _hdrEnabled;
  111950. private _motionBlurEnabled;
  111951. private _fxaaEnabled;
  111952. private _motionBlurSamples;
  111953. private _volumetricLightStepsCount;
  111954. private _samples;
  111955. /**
  111956. * @ignore
  111957. * Specifies if the bloom pipeline is enabled
  111958. */
  111959. BloomEnabled: boolean;
  111960. /**
  111961. * @ignore
  111962. * Specifies if the depth of field pipeline is enabed
  111963. */
  111964. DepthOfFieldEnabled: boolean;
  111965. /**
  111966. * @ignore
  111967. * Specifies if the lens flare pipeline is enabed
  111968. */
  111969. LensFlareEnabled: boolean;
  111970. /**
  111971. * @ignore
  111972. * Specifies if the HDR pipeline is enabled
  111973. */
  111974. HDREnabled: boolean;
  111975. /**
  111976. * @ignore
  111977. * Specifies if the volumetric lights scattering effect is enabled
  111978. */
  111979. VLSEnabled: boolean;
  111980. /**
  111981. * @ignore
  111982. * Specifies if the motion blur effect is enabled
  111983. */
  111984. MotionBlurEnabled: boolean;
  111985. /**
  111986. * Specifies if anti-aliasing is enabled
  111987. */
  111988. fxaaEnabled: boolean;
  111989. /**
  111990. * Specifies the number of steps used to calculate the volumetric lights
  111991. * Typically in interval [50, 200]
  111992. */
  111993. volumetricLightStepsCount: number;
  111994. /**
  111995. * Specifies the number of samples used for the motion blur effect
  111996. * Typically in interval [16, 64]
  111997. */
  111998. motionBlurSamples: number;
  111999. /**
  112000. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112001. */
  112002. samples: number;
  112003. /**
  112004. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  112005. * @constructor
  112006. * @param name The rendering pipeline name
  112007. * @param scene The scene linked to this pipeline
  112008. * @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)
  112009. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  112010. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112011. */
  112012. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  112013. private _buildPipeline;
  112014. private _createDownSampleX4PostProcess;
  112015. private _createBrightPassPostProcess;
  112016. private _createBlurPostProcesses;
  112017. private _createTextureAdderPostProcess;
  112018. private _createVolumetricLightPostProcess;
  112019. private _createLuminancePostProcesses;
  112020. private _createHdrPostProcess;
  112021. private _createLensFlarePostProcess;
  112022. private _createDepthOfFieldPostProcess;
  112023. private _createMotionBlurPostProcess;
  112024. private _getDepthTexture;
  112025. private _disposePostProcesses;
  112026. /**
  112027. * Dispose of the pipeline and stop all post processes
  112028. */
  112029. dispose(): void;
  112030. /**
  112031. * Serialize the rendering pipeline (Used when exporting)
  112032. * @returns the serialized object
  112033. */
  112034. serialize(): any;
  112035. /**
  112036. * Parse the serialized pipeline
  112037. * @param source Source pipeline.
  112038. * @param scene The scene to load the pipeline to.
  112039. * @param rootUrl The URL of the serialized pipeline.
  112040. * @returns An instantiated pipeline from the serialized object.
  112041. */
  112042. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  112043. /**
  112044. * Luminance steps
  112045. */
  112046. static LuminanceSteps: number;
  112047. }
  112048. }
  112049. declare module BABYLON {
  112050. /** @hidden */
  112051. export var tonemapPixelShader: {
  112052. name: string;
  112053. shader: string;
  112054. };
  112055. }
  112056. declare module BABYLON {
  112057. /** Defines operator used for tonemapping */
  112058. export enum TonemappingOperator {
  112059. /** Hable */
  112060. Hable = 0,
  112061. /** Reinhard */
  112062. Reinhard = 1,
  112063. /** HejiDawson */
  112064. HejiDawson = 2,
  112065. /** Photographic */
  112066. Photographic = 3
  112067. }
  112068. /**
  112069. * Defines a post process to apply tone mapping
  112070. */
  112071. export class TonemapPostProcess extends PostProcess {
  112072. private _operator;
  112073. /** Defines the required exposure adjustement */
  112074. exposureAdjustment: number;
  112075. /**
  112076. * Creates a new TonemapPostProcess
  112077. * @param name defines the name of the postprocess
  112078. * @param _operator defines the operator to use
  112079. * @param exposureAdjustment defines the required exposure adjustement
  112080. * @param camera defines the camera to use (can be null)
  112081. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  112082. * @param engine defines the hosting engine (can be ignore if camera is set)
  112083. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112084. */
  112085. constructor(name: string, _operator: TonemappingOperator,
  112086. /** Defines the required exposure adjustement */
  112087. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  112088. }
  112089. }
  112090. declare module BABYLON {
  112091. /** @hidden */
  112092. export var depthVertexShader: {
  112093. name: string;
  112094. shader: string;
  112095. };
  112096. }
  112097. declare module BABYLON {
  112098. /** @hidden */
  112099. export var volumetricLightScatteringPixelShader: {
  112100. name: string;
  112101. shader: string;
  112102. };
  112103. }
  112104. declare module BABYLON {
  112105. /** @hidden */
  112106. export var volumetricLightScatteringPassPixelShader: {
  112107. name: string;
  112108. shader: string;
  112109. };
  112110. }
  112111. declare module BABYLON {
  112112. /**
  112113. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  112114. */
  112115. export class VolumetricLightScatteringPostProcess extends PostProcess {
  112116. private _volumetricLightScatteringPass;
  112117. private _volumetricLightScatteringRTT;
  112118. private _viewPort;
  112119. private _screenCoordinates;
  112120. private _cachedDefines;
  112121. /**
  112122. * If not undefined, the mesh position is computed from the attached node position
  112123. */
  112124. attachedNode: {
  112125. position: Vector3;
  112126. };
  112127. /**
  112128. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  112129. */
  112130. customMeshPosition: Vector3;
  112131. /**
  112132. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  112133. */
  112134. useCustomMeshPosition: boolean;
  112135. /**
  112136. * If the post-process should inverse the light scattering direction
  112137. */
  112138. invert: boolean;
  112139. /**
  112140. * The internal mesh used by the post-process
  112141. */
  112142. mesh: Mesh;
  112143. /**
  112144. * @hidden
  112145. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  112146. */
  112147. useDiffuseColor: boolean;
  112148. /**
  112149. * Array containing the excluded meshes not rendered in the internal pass
  112150. */
  112151. excludedMeshes: AbstractMesh[];
  112152. /**
  112153. * Controls the overall intensity of the post-process
  112154. */
  112155. exposure: number;
  112156. /**
  112157. * Dissipates each sample's contribution in range [0, 1]
  112158. */
  112159. decay: number;
  112160. /**
  112161. * Controls the overall intensity of each sample
  112162. */
  112163. weight: number;
  112164. /**
  112165. * Controls the density of each sample
  112166. */
  112167. density: number;
  112168. /**
  112169. * @constructor
  112170. * @param name The post-process name
  112171. * @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)
  112172. * @param camera The camera that the post-process will be attached to
  112173. * @param mesh The mesh used to create the light scattering
  112174. * @param samples The post-process quality, default 100
  112175. * @param samplingModeThe post-process filtering mode
  112176. * @param engine The babylon engine
  112177. * @param reusable If the post-process is reusable
  112178. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  112179. */
  112180. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  112181. /**
  112182. * Returns the string "VolumetricLightScatteringPostProcess"
  112183. * @returns "VolumetricLightScatteringPostProcess"
  112184. */
  112185. getClassName(): string;
  112186. private _isReady;
  112187. /**
  112188. * Sets the new light position for light scattering effect
  112189. * @param position The new custom light position
  112190. */
  112191. setCustomMeshPosition(position: Vector3): void;
  112192. /**
  112193. * Returns the light position for light scattering effect
  112194. * @return Vector3 The custom light position
  112195. */
  112196. getCustomMeshPosition(): Vector3;
  112197. /**
  112198. * Disposes the internal assets and detaches the post-process from the camera
  112199. */
  112200. dispose(camera: Camera): void;
  112201. /**
  112202. * Returns the render target texture used by the post-process
  112203. * @return the render target texture used by the post-process
  112204. */
  112205. getPass(): RenderTargetTexture;
  112206. private _meshExcluded;
  112207. private _createPass;
  112208. private _updateMeshScreenCoordinates;
  112209. /**
  112210. * Creates a default mesh for the Volumeric Light Scattering post-process
  112211. * @param name The mesh name
  112212. * @param scene The scene where to create the mesh
  112213. * @return the default mesh
  112214. */
  112215. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  112216. }
  112217. }
  112218. declare module BABYLON {
  112219. interface Scene {
  112220. /** @hidden (Backing field) */
  112221. _boundingBoxRenderer: BoundingBoxRenderer;
  112222. /** @hidden (Backing field) */
  112223. _forceShowBoundingBoxes: boolean;
  112224. /**
  112225. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  112226. */
  112227. forceShowBoundingBoxes: boolean;
  112228. /**
  112229. * Gets the bounding box renderer associated with the scene
  112230. * @returns a BoundingBoxRenderer
  112231. */
  112232. getBoundingBoxRenderer(): BoundingBoxRenderer;
  112233. }
  112234. interface AbstractMesh {
  112235. /** @hidden (Backing field) */
  112236. _showBoundingBox: boolean;
  112237. /**
  112238. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  112239. */
  112240. showBoundingBox: boolean;
  112241. }
  112242. /**
  112243. * Component responsible of rendering the bounding box of the meshes in a scene.
  112244. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  112245. */
  112246. export class BoundingBoxRenderer implements ISceneComponent {
  112247. /**
  112248. * The component name helpfull to identify the component in the list of scene components.
  112249. */
  112250. readonly name: string;
  112251. /**
  112252. * The scene the component belongs to.
  112253. */
  112254. scene: Scene;
  112255. /**
  112256. * Color of the bounding box lines placed in front of an object
  112257. */
  112258. frontColor: Color3;
  112259. /**
  112260. * Color of the bounding box lines placed behind an object
  112261. */
  112262. backColor: Color3;
  112263. /**
  112264. * Defines if the renderer should show the back lines or not
  112265. */
  112266. showBackLines: boolean;
  112267. /**
  112268. * @hidden
  112269. */
  112270. renderList: SmartArray<BoundingBox>;
  112271. private _colorShader;
  112272. private _vertexBuffers;
  112273. private _indexBuffer;
  112274. /**
  112275. * Instantiates a new bounding box renderer in a scene.
  112276. * @param scene the scene the renderer renders in
  112277. */
  112278. constructor(scene: Scene);
  112279. /**
  112280. * Registers the component in a given scene
  112281. */
  112282. register(): void;
  112283. private _evaluateSubMesh;
  112284. private _activeMesh;
  112285. private _prepareRessources;
  112286. private _createIndexBuffer;
  112287. /**
  112288. * Rebuilds the elements related to this component in case of
  112289. * context lost for instance.
  112290. */
  112291. rebuild(): void;
  112292. /**
  112293. * @hidden
  112294. */
  112295. reset(): void;
  112296. /**
  112297. * Render the bounding boxes of a specific rendering group
  112298. * @param renderingGroupId defines the rendering group to render
  112299. */
  112300. render(renderingGroupId: number): void;
  112301. /**
  112302. * In case of occlusion queries, we can render the occlusion bounding box through this method
  112303. * @param mesh Define the mesh to render the occlusion bounding box for
  112304. */
  112305. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  112306. /**
  112307. * Dispose and release the resources attached to this renderer.
  112308. */
  112309. dispose(): void;
  112310. }
  112311. }
  112312. declare module BABYLON {
  112313. /** @hidden */
  112314. export var depthPixelShader: {
  112315. name: string;
  112316. shader: string;
  112317. };
  112318. }
  112319. declare module BABYLON {
  112320. /**
  112321. * This represents a depth renderer in Babylon.
  112322. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  112323. */
  112324. export class DepthRenderer {
  112325. private _scene;
  112326. private _depthMap;
  112327. private _effect;
  112328. private _cachedDefines;
  112329. private _camera;
  112330. /**
  112331. * Specifiess that the depth renderer will only be used within
  112332. * the camera it is created for.
  112333. * This can help forcing its rendering during the camera processing.
  112334. */
  112335. useOnlyInActiveCamera: boolean;
  112336. /** @hidden */
  112337. static _SceneComponentInitialization: (scene: Scene) => void;
  112338. /**
  112339. * Instantiates a depth renderer
  112340. * @param scene The scene the renderer belongs to
  112341. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  112342. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  112343. */
  112344. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  112345. /**
  112346. * Creates the depth rendering effect and checks if the effect is ready.
  112347. * @param subMesh The submesh to be used to render the depth map of
  112348. * @param useInstances If multiple world instances should be used
  112349. * @returns if the depth renderer is ready to render the depth map
  112350. */
  112351. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112352. /**
  112353. * Gets the texture which the depth map will be written to.
  112354. * @returns The depth map texture
  112355. */
  112356. getDepthMap(): RenderTargetTexture;
  112357. /**
  112358. * Disposes of the depth renderer.
  112359. */
  112360. dispose(): void;
  112361. }
  112362. }
  112363. declare module BABYLON {
  112364. interface Scene {
  112365. /** @hidden (Backing field) */
  112366. _depthRenderer: {
  112367. [id: string]: DepthRenderer;
  112368. };
  112369. /**
  112370. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  112371. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  112372. * @returns the created depth renderer
  112373. */
  112374. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  112375. /**
  112376. * Disables a depth renderer for a given camera
  112377. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  112378. */
  112379. disableDepthRenderer(camera?: Nullable<Camera>): void;
  112380. }
  112381. /**
  112382. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  112383. * in several rendering techniques.
  112384. */
  112385. export class DepthRendererSceneComponent implements ISceneComponent {
  112386. /**
  112387. * The component name helpfull to identify the component in the list of scene components.
  112388. */
  112389. readonly name: string;
  112390. /**
  112391. * The scene the component belongs to.
  112392. */
  112393. scene: Scene;
  112394. /**
  112395. * Creates a new instance of the component for the given scene
  112396. * @param scene Defines the scene to register the component in
  112397. */
  112398. constructor(scene: Scene);
  112399. /**
  112400. * Registers the component in a given scene
  112401. */
  112402. register(): void;
  112403. /**
  112404. * Rebuilds the elements related to this component in case of
  112405. * context lost for instance.
  112406. */
  112407. rebuild(): void;
  112408. /**
  112409. * Disposes the component and the associated ressources
  112410. */
  112411. dispose(): void;
  112412. private _gatherRenderTargets;
  112413. private _gatherActiveCameraRenderTargets;
  112414. }
  112415. }
  112416. declare module BABYLON {
  112417. /** @hidden */
  112418. export var outlinePixelShader: {
  112419. name: string;
  112420. shader: string;
  112421. };
  112422. }
  112423. declare module BABYLON {
  112424. /** @hidden */
  112425. export var outlineVertexShader: {
  112426. name: string;
  112427. shader: string;
  112428. };
  112429. }
  112430. declare module BABYLON {
  112431. interface Scene {
  112432. /** @hidden */
  112433. _outlineRenderer: OutlineRenderer;
  112434. /**
  112435. * Gets the outline renderer associated with the scene
  112436. * @returns a OutlineRenderer
  112437. */
  112438. getOutlineRenderer(): OutlineRenderer;
  112439. }
  112440. interface AbstractMesh {
  112441. /** @hidden (Backing field) */
  112442. _renderOutline: boolean;
  112443. /**
  112444. * Gets or sets a boolean indicating if the outline must be rendered as well
  112445. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  112446. */
  112447. renderOutline: boolean;
  112448. /** @hidden (Backing field) */
  112449. _renderOverlay: boolean;
  112450. /**
  112451. * Gets or sets a boolean indicating if the overlay must be rendered as well
  112452. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  112453. */
  112454. renderOverlay: boolean;
  112455. }
  112456. /**
  112457. * This class is responsible to draw bothe outline/overlay of meshes.
  112458. * It should not be used directly but through the available method on mesh.
  112459. */
  112460. export class OutlineRenderer implements ISceneComponent {
  112461. /**
  112462. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  112463. */
  112464. private static _StencilReference;
  112465. /**
  112466. * The name of the component. Each component must have a unique name.
  112467. */
  112468. name: string;
  112469. /**
  112470. * The scene the component belongs to.
  112471. */
  112472. scene: Scene;
  112473. /**
  112474. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  112475. */
  112476. zOffset: number;
  112477. private _engine;
  112478. private _effect;
  112479. private _cachedDefines;
  112480. private _savedDepthWrite;
  112481. /**
  112482. * Instantiates a new outline renderer. (There could be only one per scene).
  112483. * @param scene Defines the scene it belongs to
  112484. */
  112485. constructor(scene: Scene);
  112486. /**
  112487. * Register the component to one instance of a scene.
  112488. */
  112489. register(): void;
  112490. /**
  112491. * Rebuilds the elements related to this component in case of
  112492. * context lost for instance.
  112493. */
  112494. rebuild(): void;
  112495. /**
  112496. * Disposes the component and the associated ressources.
  112497. */
  112498. dispose(): void;
  112499. /**
  112500. * Renders the outline in the canvas.
  112501. * @param subMesh Defines the sumesh to render
  112502. * @param batch Defines the batch of meshes in case of instances
  112503. * @param useOverlay Defines if the rendering is for the overlay or the outline
  112504. */
  112505. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  112506. /**
  112507. * Returns whether or not the outline renderer is ready for a given submesh.
  112508. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  112509. * @param subMesh Defines the submesh to check readyness for
  112510. * @param useInstances Defines wheter wee are trying to render instances or not
  112511. * @returns true if ready otherwise false
  112512. */
  112513. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112514. private _beforeRenderingMesh;
  112515. private _afterRenderingMesh;
  112516. }
  112517. }
  112518. declare module BABYLON {
  112519. /**
  112520. * Defines the list of states available for a task inside a AssetsManager
  112521. */
  112522. export enum AssetTaskState {
  112523. /**
  112524. * Initialization
  112525. */
  112526. INIT = 0,
  112527. /**
  112528. * Running
  112529. */
  112530. RUNNING = 1,
  112531. /**
  112532. * Done
  112533. */
  112534. DONE = 2,
  112535. /**
  112536. * Error
  112537. */
  112538. ERROR = 3
  112539. }
  112540. /**
  112541. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  112542. */
  112543. export abstract class AbstractAssetTask {
  112544. /**
  112545. * Task name
  112546. */ name: string;
  112547. /**
  112548. * Callback called when the task is successful
  112549. */
  112550. onSuccess: (task: any) => void;
  112551. /**
  112552. * Callback called when the task is not successful
  112553. */
  112554. onError: (task: any, message?: string, exception?: any) => void;
  112555. /**
  112556. * Creates a new AssetsManager
  112557. * @param name defines the name of the task
  112558. */
  112559. constructor(
  112560. /**
  112561. * Task name
  112562. */ name: string);
  112563. private _isCompleted;
  112564. private _taskState;
  112565. private _errorObject;
  112566. /**
  112567. * Get if the task is completed
  112568. */
  112569. readonly isCompleted: boolean;
  112570. /**
  112571. * Gets the current state of the task
  112572. */
  112573. readonly taskState: AssetTaskState;
  112574. /**
  112575. * Gets the current error object (if task is in error)
  112576. */
  112577. readonly errorObject: {
  112578. message?: string;
  112579. exception?: any;
  112580. };
  112581. /**
  112582. * Internal only
  112583. * @hidden
  112584. */
  112585. _setErrorObject(message?: string, exception?: any): void;
  112586. /**
  112587. * Execute the current task
  112588. * @param scene defines the scene where you want your assets to be loaded
  112589. * @param onSuccess is a callback called when the task is successfully executed
  112590. * @param onError is a callback called if an error occurs
  112591. */
  112592. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112593. /**
  112594. * Execute the current task
  112595. * @param scene defines the scene where you want your assets to be loaded
  112596. * @param onSuccess is a callback called when the task is successfully executed
  112597. * @param onError is a callback called if an error occurs
  112598. */
  112599. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112600. /**
  112601. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  112602. * This can be used with failed tasks that have the reason for failure fixed.
  112603. */
  112604. reset(): void;
  112605. private onErrorCallback;
  112606. private onDoneCallback;
  112607. }
  112608. /**
  112609. * Define the interface used by progress events raised during assets loading
  112610. */
  112611. export interface IAssetsProgressEvent {
  112612. /**
  112613. * Defines the number of remaining tasks to process
  112614. */
  112615. remainingCount: number;
  112616. /**
  112617. * Defines the total number of tasks
  112618. */
  112619. totalCount: number;
  112620. /**
  112621. * Defines the task that was just processed
  112622. */
  112623. task: AbstractAssetTask;
  112624. }
  112625. /**
  112626. * Class used to share progress information about assets loading
  112627. */
  112628. export class AssetsProgressEvent implements IAssetsProgressEvent {
  112629. /**
  112630. * Defines the number of remaining tasks to process
  112631. */
  112632. remainingCount: number;
  112633. /**
  112634. * Defines the total number of tasks
  112635. */
  112636. totalCount: number;
  112637. /**
  112638. * Defines the task that was just processed
  112639. */
  112640. task: AbstractAssetTask;
  112641. /**
  112642. * Creates a AssetsProgressEvent
  112643. * @param remainingCount defines the number of remaining tasks to process
  112644. * @param totalCount defines the total number of tasks
  112645. * @param task defines the task that was just processed
  112646. */
  112647. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  112648. }
  112649. /**
  112650. * Define a task used by AssetsManager to load meshes
  112651. */
  112652. export class MeshAssetTask extends AbstractAssetTask {
  112653. /**
  112654. * Defines the name of the task
  112655. */
  112656. name: string;
  112657. /**
  112658. * Defines the list of mesh's names you want to load
  112659. */
  112660. meshesNames: any;
  112661. /**
  112662. * Defines the root url to use as a base to load your meshes and associated resources
  112663. */
  112664. rootUrl: string;
  112665. /**
  112666. * Defines the filename of the scene to load from
  112667. */
  112668. sceneFilename: string;
  112669. /**
  112670. * Gets the list of loaded meshes
  112671. */
  112672. loadedMeshes: Array<AbstractMesh>;
  112673. /**
  112674. * Gets the list of loaded particle systems
  112675. */
  112676. loadedParticleSystems: Array<IParticleSystem>;
  112677. /**
  112678. * Gets the list of loaded skeletons
  112679. */
  112680. loadedSkeletons: Array<Skeleton>;
  112681. /**
  112682. * Gets the list of loaded animation groups
  112683. */
  112684. loadedAnimationGroups: Array<AnimationGroup>;
  112685. /**
  112686. * Callback called when the task is successful
  112687. */
  112688. onSuccess: (task: MeshAssetTask) => void;
  112689. /**
  112690. * Callback called when the task is successful
  112691. */
  112692. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  112693. /**
  112694. * Creates a new MeshAssetTask
  112695. * @param name defines the name of the task
  112696. * @param meshesNames defines the list of mesh's names you want to load
  112697. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  112698. * @param sceneFilename defines the filename of the scene to load from
  112699. */
  112700. constructor(
  112701. /**
  112702. * Defines the name of the task
  112703. */
  112704. name: string,
  112705. /**
  112706. * Defines the list of mesh's names you want to load
  112707. */
  112708. meshesNames: any,
  112709. /**
  112710. * Defines the root url to use as a base to load your meshes and associated resources
  112711. */
  112712. rootUrl: string,
  112713. /**
  112714. * Defines the filename of the scene to load from
  112715. */
  112716. sceneFilename: string);
  112717. /**
  112718. * Execute the current task
  112719. * @param scene defines the scene where you want your assets to be loaded
  112720. * @param onSuccess is a callback called when the task is successfully executed
  112721. * @param onError is a callback called if an error occurs
  112722. */
  112723. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112724. }
  112725. /**
  112726. * Define a task used by AssetsManager to load text content
  112727. */
  112728. export class TextFileAssetTask extends AbstractAssetTask {
  112729. /**
  112730. * Defines the name of the task
  112731. */
  112732. name: string;
  112733. /**
  112734. * Defines the location of the file to load
  112735. */
  112736. url: string;
  112737. /**
  112738. * Gets the loaded text string
  112739. */
  112740. text: string;
  112741. /**
  112742. * Callback called when the task is successful
  112743. */
  112744. onSuccess: (task: TextFileAssetTask) => void;
  112745. /**
  112746. * Callback called when the task is successful
  112747. */
  112748. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  112749. /**
  112750. * Creates a new TextFileAssetTask object
  112751. * @param name defines the name of the task
  112752. * @param url defines the location of the file to load
  112753. */
  112754. constructor(
  112755. /**
  112756. * Defines the name of the task
  112757. */
  112758. name: string,
  112759. /**
  112760. * Defines the location of the file to load
  112761. */
  112762. url: string);
  112763. /**
  112764. * Execute the current task
  112765. * @param scene defines the scene where you want your assets to be loaded
  112766. * @param onSuccess is a callback called when the task is successfully executed
  112767. * @param onError is a callback called if an error occurs
  112768. */
  112769. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112770. }
  112771. /**
  112772. * Define a task used by AssetsManager to load binary data
  112773. */
  112774. export class BinaryFileAssetTask extends AbstractAssetTask {
  112775. /**
  112776. * Defines the name of the task
  112777. */
  112778. name: string;
  112779. /**
  112780. * Defines the location of the file to load
  112781. */
  112782. url: string;
  112783. /**
  112784. * Gets the lodaded data (as an array buffer)
  112785. */
  112786. data: ArrayBuffer;
  112787. /**
  112788. * Callback called when the task is successful
  112789. */
  112790. onSuccess: (task: BinaryFileAssetTask) => void;
  112791. /**
  112792. * Callback called when the task is successful
  112793. */
  112794. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  112795. /**
  112796. * Creates a new BinaryFileAssetTask object
  112797. * @param name defines the name of the new task
  112798. * @param url defines the location of the file to load
  112799. */
  112800. constructor(
  112801. /**
  112802. * Defines the name of the task
  112803. */
  112804. name: string,
  112805. /**
  112806. * Defines the location of the file to load
  112807. */
  112808. url: string);
  112809. /**
  112810. * Execute the current task
  112811. * @param scene defines the scene where you want your assets to be loaded
  112812. * @param onSuccess is a callback called when the task is successfully executed
  112813. * @param onError is a callback called if an error occurs
  112814. */
  112815. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112816. }
  112817. /**
  112818. * Define a task used by AssetsManager to load images
  112819. */
  112820. export class ImageAssetTask extends AbstractAssetTask {
  112821. /**
  112822. * Defines the name of the task
  112823. */
  112824. name: string;
  112825. /**
  112826. * Defines the location of the image to load
  112827. */
  112828. url: string;
  112829. /**
  112830. * Gets the loaded images
  112831. */
  112832. image: HTMLImageElement;
  112833. /**
  112834. * Callback called when the task is successful
  112835. */
  112836. onSuccess: (task: ImageAssetTask) => void;
  112837. /**
  112838. * Callback called when the task is successful
  112839. */
  112840. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  112841. /**
  112842. * Creates a new ImageAssetTask
  112843. * @param name defines the name of the task
  112844. * @param url defines the location of the image to load
  112845. */
  112846. constructor(
  112847. /**
  112848. * Defines the name of the task
  112849. */
  112850. name: string,
  112851. /**
  112852. * Defines the location of the image to load
  112853. */
  112854. url: string);
  112855. /**
  112856. * Execute the current task
  112857. * @param scene defines the scene where you want your assets to be loaded
  112858. * @param onSuccess is a callback called when the task is successfully executed
  112859. * @param onError is a callback called if an error occurs
  112860. */
  112861. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112862. }
  112863. /**
  112864. * Defines the interface used by texture loading tasks
  112865. */
  112866. export interface ITextureAssetTask<TEX extends BaseTexture> {
  112867. /**
  112868. * Gets the loaded texture
  112869. */
  112870. texture: TEX;
  112871. }
  112872. /**
  112873. * Define a task used by AssetsManager to load 2D textures
  112874. */
  112875. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  112876. /**
  112877. * Defines the name of the task
  112878. */
  112879. name: string;
  112880. /**
  112881. * Defines the location of the file to load
  112882. */
  112883. url: string;
  112884. /**
  112885. * Defines if mipmap should not be generated (default is false)
  112886. */
  112887. noMipmap?: boolean | undefined;
  112888. /**
  112889. * Defines if texture must be inverted on Y axis (default is false)
  112890. */
  112891. invertY?: boolean | undefined;
  112892. /**
  112893. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112894. */
  112895. samplingMode: number;
  112896. /**
  112897. * Gets the loaded texture
  112898. */
  112899. texture: Texture;
  112900. /**
  112901. * Callback called when the task is successful
  112902. */
  112903. onSuccess: (task: TextureAssetTask) => void;
  112904. /**
  112905. * Callback called when the task is successful
  112906. */
  112907. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  112908. /**
  112909. * Creates a new TextureAssetTask object
  112910. * @param name defines the name of the task
  112911. * @param url defines the location of the file to load
  112912. * @param noMipmap defines if mipmap should not be generated (default is false)
  112913. * @param invertY defines if texture must be inverted on Y axis (default is false)
  112914. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112915. */
  112916. constructor(
  112917. /**
  112918. * Defines the name of the task
  112919. */
  112920. name: string,
  112921. /**
  112922. * Defines the location of the file to load
  112923. */
  112924. url: string,
  112925. /**
  112926. * Defines if mipmap should not be generated (default is false)
  112927. */
  112928. noMipmap?: boolean | undefined,
  112929. /**
  112930. * Defines if texture must be inverted on Y axis (default is false)
  112931. */
  112932. invertY?: boolean | undefined,
  112933. /**
  112934. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112935. */
  112936. samplingMode?: number);
  112937. /**
  112938. * Execute the current task
  112939. * @param scene defines the scene where you want your assets to be loaded
  112940. * @param onSuccess is a callback called when the task is successfully executed
  112941. * @param onError is a callback called if an error occurs
  112942. */
  112943. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112944. }
  112945. /**
  112946. * Define a task used by AssetsManager to load cube textures
  112947. */
  112948. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  112949. /**
  112950. * Defines the name of the task
  112951. */
  112952. name: string;
  112953. /**
  112954. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112955. */
  112956. url: string;
  112957. /**
  112958. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112959. */
  112960. extensions?: string[] | undefined;
  112961. /**
  112962. * Defines if mipmaps should not be generated (default is false)
  112963. */
  112964. noMipmap?: boolean | undefined;
  112965. /**
  112966. * Defines the explicit list of files (undefined by default)
  112967. */
  112968. files?: string[] | undefined;
  112969. /**
  112970. * Gets the loaded texture
  112971. */
  112972. texture: CubeTexture;
  112973. /**
  112974. * Callback called when the task is successful
  112975. */
  112976. onSuccess: (task: CubeTextureAssetTask) => void;
  112977. /**
  112978. * Callback called when the task is successful
  112979. */
  112980. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  112981. /**
  112982. * Creates a new CubeTextureAssetTask
  112983. * @param name defines the name of the task
  112984. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112985. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112986. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112987. * @param files defines the explicit list of files (undefined by default)
  112988. */
  112989. constructor(
  112990. /**
  112991. * Defines the name of the task
  112992. */
  112993. name: string,
  112994. /**
  112995. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112996. */
  112997. url: string,
  112998. /**
  112999. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  113000. */
  113001. extensions?: string[] | undefined,
  113002. /**
  113003. * Defines if mipmaps should not be generated (default is false)
  113004. */
  113005. noMipmap?: boolean | undefined,
  113006. /**
  113007. * Defines the explicit list of files (undefined by default)
  113008. */
  113009. files?: string[] | undefined);
  113010. /**
  113011. * Execute the current task
  113012. * @param scene defines the scene where you want your assets to be loaded
  113013. * @param onSuccess is a callback called when the task is successfully executed
  113014. * @param onError is a callback called if an error occurs
  113015. */
  113016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113017. }
  113018. /**
  113019. * Define a task used by AssetsManager to load HDR cube textures
  113020. */
  113021. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  113022. /**
  113023. * Defines the name of the task
  113024. */
  113025. name: string;
  113026. /**
  113027. * Defines the location of the file to load
  113028. */
  113029. url: string;
  113030. /**
  113031. * Defines the desired size (the more it increases the longer the generation will be)
  113032. */
  113033. size: number;
  113034. /**
  113035. * Defines if mipmaps should not be generated (default is false)
  113036. */
  113037. noMipmap: boolean;
  113038. /**
  113039. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113040. */
  113041. generateHarmonics: boolean;
  113042. /**
  113043. * 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)
  113044. */
  113045. gammaSpace: boolean;
  113046. /**
  113047. * Internal Use Only
  113048. */
  113049. reserved: boolean;
  113050. /**
  113051. * Gets the loaded texture
  113052. */
  113053. texture: HDRCubeTexture;
  113054. /**
  113055. * Callback called when the task is successful
  113056. */
  113057. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  113058. /**
  113059. * Callback called when the task is successful
  113060. */
  113061. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  113062. /**
  113063. * Creates a new HDRCubeTextureAssetTask object
  113064. * @param name defines the name of the task
  113065. * @param url defines the location of the file to load
  113066. * @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.
  113067. * @param noMipmap defines if mipmaps should not be generated (default is false)
  113068. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113069. * @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)
  113070. * @param reserved Internal use only
  113071. */
  113072. constructor(
  113073. /**
  113074. * Defines the name of the task
  113075. */
  113076. name: string,
  113077. /**
  113078. * Defines the location of the file to load
  113079. */
  113080. url: string,
  113081. /**
  113082. * Defines the desired size (the more it increases the longer the generation will be)
  113083. */
  113084. size: number,
  113085. /**
  113086. * Defines if mipmaps should not be generated (default is false)
  113087. */
  113088. noMipmap?: boolean,
  113089. /**
  113090. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113091. */
  113092. generateHarmonics?: boolean,
  113093. /**
  113094. * 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)
  113095. */
  113096. gammaSpace?: boolean,
  113097. /**
  113098. * Internal Use Only
  113099. */
  113100. reserved?: boolean);
  113101. /**
  113102. * Execute the current task
  113103. * @param scene defines the scene where you want your assets to be loaded
  113104. * @param onSuccess is a callback called when the task is successfully executed
  113105. * @param onError is a callback called if an error occurs
  113106. */
  113107. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113108. }
  113109. /**
  113110. * This class can be used to easily import assets into a scene
  113111. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  113112. */
  113113. export class AssetsManager {
  113114. private _scene;
  113115. private _isLoading;
  113116. protected _tasks: AbstractAssetTask[];
  113117. protected _waitingTasksCount: number;
  113118. protected _totalTasksCount: number;
  113119. /**
  113120. * Callback called when all tasks are processed
  113121. */
  113122. onFinish: (tasks: AbstractAssetTask[]) => void;
  113123. /**
  113124. * Callback called when a task is successful
  113125. */
  113126. onTaskSuccess: (task: AbstractAssetTask) => void;
  113127. /**
  113128. * Callback called when a task had an error
  113129. */
  113130. onTaskError: (task: AbstractAssetTask) => void;
  113131. /**
  113132. * Callback called when a task is done (whatever the result is)
  113133. */
  113134. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  113135. /**
  113136. * Observable called when all tasks are processed
  113137. */
  113138. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  113139. /**
  113140. * Observable called when a task had an error
  113141. */
  113142. onTaskErrorObservable: Observable<AbstractAssetTask>;
  113143. /**
  113144. * Observable called when all tasks were executed
  113145. */
  113146. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  113147. /**
  113148. * Observable called when a task is done (whatever the result is)
  113149. */
  113150. onProgressObservable: Observable<IAssetsProgressEvent>;
  113151. /**
  113152. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  113153. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113154. */
  113155. useDefaultLoadingScreen: boolean;
  113156. /**
  113157. * Creates a new AssetsManager
  113158. * @param scene defines the scene to work on
  113159. */
  113160. constructor(scene: Scene);
  113161. /**
  113162. * Add a MeshAssetTask to the list of active tasks
  113163. * @param taskName defines the name of the new task
  113164. * @param meshesNames defines the name of meshes to load
  113165. * @param rootUrl defines the root url to use to locate files
  113166. * @param sceneFilename defines the filename of the scene file
  113167. * @returns a new MeshAssetTask object
  113168. */
  113169. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  113170. /**
  113171. * Add a TextFileAssetTask to the list of active tasks
  113172. * @param taskName defines the name of the new task
  113173. * @param url defines the url of the file to load
  113174. * @returns a new TextFileAssetTask object
  113175. */
  113176. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  113177. /**
  113178. * Add a BinaryFileAssetTask to the list of active tasks
  113179. * @param taskName defines the name of the new task
  113180. * @param url defines the url of the file to load
  113181. * @returns a new BinaryFileAssetTask object
  113182. */
  113183. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  113184. /**
  113185. * Add a ImageAssetTask to the list of active tasks
  113186. * @param taskName defines the name of the new task
  113187. * @param url defines the url of the file to load
  113188. * @returns a new ImageAssetTask object
  113189. */
  113190. addImageTask(taskName: string, url: string): ImageAssetTask;
  113191. /**
  113192. * Add a TextureAssetTask to the list of active tasks
  113193. * @param taskName defines the name of the new task
  113194. * @param url defines the url of the file to load
  113195. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  113196. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  113197. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113198. * @returns a new TextureAssetTask object
  113199. */
  113200. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  113201. /**
  113202. * Add a CubeTextureAssetTask to the list of active tasks
  113203. * @param taskName defines the name of the new task
  113204. * @param url defines the url of the file to load
  113205. * @param extensions defines the extension to use to load the cube map (can be null)
  113206. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  113207. * @param files defines the list of files to load (can be null)
  113208. * @returns a new CubeTextureAssetTask object
  113209. */
  113210. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  113211. /**
  113212. *
  113213. * Add a HDRCubeTextureAssetTask to the list of active tasks
  113214. * @param taskName defines the name of the new task
  113215. * @param url defines the url of the file to load
  113216. * @param size defines the size you want for the cubemap (can be null)
  113217. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  113218. * @param generateHarmonics defines if you want to automatically generate (true by default)
  113219. * @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)
  113220. * @param reserved Internal use only
  113221. * @returns a new HDRCubeTextureAssetTask object
  113222. */
  113223. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  113224. /**
  113225. * Remove a task from the assets manager.
  113226. * @param task the task to remove
  113227. */
  113228. removeTask(task: AbstractAssetTask): void;
  113229. private _decreaseWaitingTasksCount;
  113230. private _runTask;
  113231. /**
  113232. * Reset the AssetsManager and remove all tasks
  113233. * @return the current instance of the AssetsManager
  113234. */
  113235. reset(): AssetsManager;
  113236. /**
  113237. * Start the loading process
  113238. * @return the current instance of the AssetsManager
  113239. */
  113240. load(): AssetsManager;
  113241. /**
  113242. * Start the loading process as an async operation
  113243. * @return a promise returning the list of failed tasks
  113244. */
  113245. loadAsync(): Promise<void>;
  113246. }
  113247. }
  113248. declare module BABYLON {
  113249. /**
  113250. * Wrapper class for promise with external resolve and reject.
  113251. */
  113252. export class Deferred<T> {
  113253. /**
  113254. * The promise associated with this deferred object.
  113255. */
  113256. readonly promise: Promise<T>;
  113257. private _resolve;
  113258. private _reject;
  113259. /**
  113260. * The resolve method of the promise associated with this deferred object.
  113261. */
  113262. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  113263. /**
  113264. * The reject method of the promise associated with this deferred object.
  113265. */
  113266. readonly reject: (reason?: any) => void;
  113267. /**
  113268. * Constructor for this deferred object.
  113269. */
  113270. constructor();
  113271. }
  113272. }
  113273. declare module BABYLON {
  113274. /**
  113275. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  113276. */
  113277. export class MeshExploder {
  113278. private _centerMesh;
  113279. private _meshes;
  113280. private _meshesOrigins;
  113281. private _toCenterVectors;
  113282. private _scaledDirection;
  113283. private _newPosition;
  113284. private _centerPosition;
  113285. /**
  113286. * Explodes meshes from a center mesh.
  113287. * @param meshes The meshes to explode.
  113288. * @param centerMesh The mesh to be center of explosion.
  113289. */
  113290. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  113291. private _setCenterMesh;
  113292. /**
  113293. * Get class name
  113294. * @returns "MeshExploder"
  113295. */
  113296. getClassName(): string;
  113297. /**
  113298. * "Exploded meshes"
  113299. * @returns Array of meshes with the centerMesh at index 0.
  113300. */
  113301. getMeshes(): Array<Mesh>;
  113302. /**
  113303. * Explodes meshes giving a specific direction
  113304. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  113305. */
  113306. explode(direction?: number): void;
  113307. }
  113308. }
  113309. declare module BABYLON {
  113310. /**
  113311. * Class used to help managing file picking and drag'n'drop
  113312. */
  113313. export class FilesInput {
  113314. /**
  113315. * List of files ready to be loaded
  113316. */
  113317. static readonly FilesToLoad: {
  113318. [key: string]: File;
  113319. };
  113320. /**
  113321. * Callback called when a file is processed
  113322. */
  113323. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  113324. private _engine;
  113325. private _currentScene;
  113326. private _sceneLoadedCallback;
  113327. private _progressCallback;
  113328. private _additionalRenderLoopLogicCallback;
  113329. private _textureLoadingCallback;
  113330. private _startingProcessingFilesCallback;
  113331. private _onReloadCallback;
  113332. private _errorCallback;
  113333. private _elementToMonitor;
  113334. private _sceneFileToLoad;
  113335. private _filesToLoad;
  113336. /**
  113337. * Creates a new FilesInput
  113338. * @param engine defines the rendering engine
  113339. * @param scene defines the hosting scene
  113340. * @param sceneLoadedCallback callback called when scene is loaded
  113341. * @param progressCallback callback called to track progress
  113342. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  113343. * @param textureLoadingCallback callback called when a texture is loading
  113344. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  113345. * @param onReloadCallback callback called when a reload is requested
  113346. * @param errorCallback callback call if an error occurs
  113347. */
  113348. 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);
  113349. private _dragEnterHandler;
  113350. private _dragOverHandler;
  113351. private _dropHandler;
  113352. /**
  113353. * Calls this function to listen to drag'n'drop events on a specific DOM element
  113354. * @param elementToMonitor defines the DOM element to track
  113355. */
  113356. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  113357. /**
  113358. * Release all associated resources
  113359. */
  113360. dispose(): void;
  113361. private renderFunction;
  113362. private drag;
  113363. private drop;
  113364. private _traverseFolder;
  113365. private _processFiles;
  113366. /**
  113367. * Load files from a drop event
  113368. * @param event defines the drop event to use as source
  113369. */
  113370. loadFiles(event: any): void;
  113371. private _processReload;
  113372. /**
  113373. * Reload the current scene from the loaded files
  113374. */
  113375. reload(): void;
  113376. }
  113377. }
  113378. declare module BABYLON {
  113379. /**
  113380. * Defines the root class used to create scene optimization to use with SceneOptimizer
  113381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113382. */
  113383. export class SceneOptimization {
  113384. /**
  113385. * Defines the priority of this optimization (0 by default which means first in the list)
  113386. */
  113387. priority: number;
  113388. /**
  113389. * Gets a string describing the action executed by the current optimization
  113390. * @returns description string
  113391. */
  113392. getDescription(): string;
  113393. /**
  113394. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113395. * @param scene defines the current scene where to apply this optimization
  113396. * @param optimizer defines the current optimizer
  113397. * @returns true if everything that can be done was applied
  113398. */
  113399. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113400. /**
  113401. * Creates the SceneOptimization object
  113402. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113403. * @param desc defines the description associated with the optimization
  113404. */
  113405. constructor(
  113406. /**
  113407. * Defines the priority of this optimization (0 by default which means first in the list)
  113408. */
  113409. priority?: number);
  113410. }
  113411. /**
  113412. * Defines an optimization used to reduce the size of render target textures
  113413. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113414. */
  113415. export class TextureOptimization extends SceneOptimization {
  113416. /**
  113417. * Defines the priority of this optimization (0 by default which means first in the list)
  113418. */
  113419. priority: number;
  113420. /**
  113421. * 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
  113422. */
  113423. maximumSize: number;
  113424. /**
  113425. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113426. */
  113427. step: number;
  113428. /**
  113429. * Gets a string describing the action executed by the current optimization
  113430. * @returns description string
  113431. */
  113432. getDescription(): string;
  113433. /**
  113434. * Creates the TextureOptimization object
  113435. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113436. * @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
  113437. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113438. */
  113439. constructor(
  113440. /**
  113441. * Defines the priority of this optimization (0 by default which means first in the list)
  113442. */
  113443. priority?: number,
  113444. /**
  113445. * 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
  113446. */
  113447. maximumSize?: number,
  113448. /**
  113449. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113450. */
  113451. step?: number);
  113452. /**
  113453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113454. * @param scene defines the current scene where to apply this optimization
  113455. * @param optimizer defines the current optimizer
  113456. * @returns true if everything that can be done was applied
  113457. */
  113458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113459. }
  113460. /**
  113461. * Defines an optimization used to increase or decrease the rendering resolution
  113462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113463. */
  113464. export class HardwareScalingOptimization extends SceneOptimization {
  113465. /**
  113466. * Defines the priority of this optimization (0 by default which means first in the list)
  113467. */
  113468. priority: number;
  113469. /**
  113470. * Defines the maximum scale to use (2 by default)
  113471. */
  113472. maximumScale: number;
  113473. /**
  113474. * Defines the step to use between two passes (0.5 by default)
  113475. */
  113476. step: number;
  113477. private _currentScale;
  113478. private _directionOffset;
  113479. /**
  113480. * Gets a string describing the action executed by the current optimization
  113481. * @return description string
  113482. */
  113483. getDescription(): string;
  113484. /**
  113485. * Creates the HardwareScalingOptimization object
  113486. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113487. * @param maximumScale defines the maximum scale to use (2 by default)
  113488. * @param step defines the step to use between two passes (0.5 by default)
  113489. */
  113490. constructor(
  113491. /**
  113492. * Defines the priority of this optimization (0 by default which means first in the list)
  113493. */
  113494. priority?: number,
  113495. /**
  113496. * Defines the maximum scale to use (2 by default)
  113497. */
  113498. maximumScale?: number,
  113499. /**
  113500. * Defines the step to use between two passes (0.5 by default)
  113501. */
  113502. step?: number);
  113503. /**
  113504. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113505. * @param scene defines the current scene where to apply this optimization
  113506. * @param optimizer defines the current optimizer
  113507. * @returns true if everything that can be done was applied
  113508. */
  113509. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113510. }
  113511. /**
  113512. * Defines an optimization used to remove shadows
  113513. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113514. */
  113515. export class ShadowsOptimization extends SceneOptimization {
  113516. /**
  113517. * Gets a string describing the action executed by the current optimization
  113518. * @return description string
  113519. */
  113520. getDescription(): string;
  113521. /**
  113522. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113523. * @param scene defines the current scene where to apply this optimization
  113524. * @param optimizer defines the current optimizer
  113525. * @returns true if everything that can be done was applied
  113526. */
  113527. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113528. }
  113529. /**
  113530. * Defines an optimization used to turn post-processes off
  113531. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113532. */
  113533. export class PostProcessesOptimization extends SceneOptimization {
  113534. /**
  113535. * Gets a string describing the action executed by the current optimization
  113536. * @return description string
  113537. */
  113538. getDescription(): string;
  113539. /**
  113540. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113541. * @param scene defines the current scene where to apply this optimization
  113542. * @param optimizer defines the current optimizer
  113543. * @returns true if everything that can be done was applied
  113544. */
  113545. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113546. }
  113547. /**
  113548. * Defines an optimization used to turn lens flares off
  113549. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113550. */
  113551. export class LensFlaresOptimization extends SceneOptimization {
  113552. /**
  113553. * Gets a string describing the action executed by the current optimization
  113554. * @return description string
  113555. */
  113556. getDescription(): string;
  113557. /**
  113558. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113559. * @param scene defines the current scene where to apply this optimization
  113560. * @param optimizer defines the current optimizer
  113561. * @returns true if everything that can be done was applied
  113562. */
  113563. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113564. }
  113565. /**
  113566. * Defines an optimization based on user defined callback.
  113567. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113568. */
  113569. export class CustomOptimization extends SceneOptimization {
  113570. /**
  113571. * Callback called to apply the custom optimization.
  113572. */
  113573. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  113574. /**
  113575. * Callback called to get custom description
  113576. */
  113577. onGetDescription: () => string;
  113578. /**
  113579. * Gets a string describing the action executed by the current optimization
  113580. * @returns description string
  113581. */
  113582. getDescription(): string;
  113583. /**
  113584. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113585. * @param scene defines the current scene where to apply this optimization
  113586. * @param optimizer defines the current optimizer
  113587. * @returns true if everything that can be done was applied
  113588. */
  113589. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113590. }
  113591. /**
  113592. * Defines an optimization used to turn particles off
  113593. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113594. */
  113595. export class ParticlesOptimization extends SceneOptimization {
  113596. /**
  113597. * Gets a string describing the action executed by the current optimization
  113598. * @return description string
  113599. */
  113600. getDescription(): string;
  113601. /**
  113602. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113603. * @param scene defines the current scene where to apply this optimization
  113604. * @param optimizer defines the current optimizer
  113605. * @returns true if everything that can be done was applied
  113606. */
  113607. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113608. }
  113609. /**
  113610. * Defines an optimization used to turn render targets off
  113611. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113612. */
  113613. export class RenderTargetsOptimization extends SceneOptimization {
  113614. /**
  113615. * Gets a string describing the action executed by the current optimization
  113616. * @return description string
  113617. */
  113618. getDescription(): string;
  113619. /**
  113620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113621. * @param scene defines the current scene where to apply this optimization
  113622. * @param optimizer defines the current optimizer
  113623. * @returns true if everything that can be done was applied
  113624. */
  113625. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113626. }
  113627. /**
  113628. * Defines an optimization used to merge meshes with compatible materials
  113629. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113630. */
  113631. export class MergeMeshesOptimization extends SceneOptimization {
  113632. private static _UpdateSelectionTree;
  113633. /**
  113634. * Gets or sets a boolean which defines if optimization octree has to be updated
  113635. */
  113636. /**
  113637. * Gets or sets a boolean which defines if optimization octree has to be updated
  113638. */
  113639. static UpdateSelectionTree: boolean;
  113640. /**
  113641. * Gets a string describing the action executed by the current optimization
  113642. * @return description string
  113643. */
  113644. getDescription(): string;
  113645. private _canBeMerged;
  113646. /**
  113647. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113648. * @param scene defines the current scene where to apply this optimization
  113649. * @param optimizer defines the current optimizer
  113650. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  113651. * @returns true if everything that can be done was applied
  113652. */
  113653. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  113654. }
  113655. /**
  113656. * Defines a list of options used by SceneOptimizer
  113657. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113658. */
  113659. export class SceneOptimizerOptions {
  113660. /**
  113661. * Defines the target frame rate to reach (60 by default)
  113662. */
  113663. targetFrameRate: number;
  113664. /**
  113665. * Defines the interval between two checkes (2000ms by default)
  113666. */
  113667. trackerDuration: number;
  113668. /**
  113669. * Gets the list of optimizations to apply
  113670. */
  113671. optimizations: SceneOptimization[];
  113672. /**
  113673. * Creates a new list of options used by SceneOptimizer
  113674. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  113675. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  113676. */
  113677. constructor(
  113678. /**
  113679. * Defines the target frame rate to reach (60 by default)
  113680. */
  113681. targetFrameRate?: number,
  113682. /**
  113683. * Defines the interval between two checkes (2000ms by default)
  113684. */
  113685. trackerDuration?: number);
  113686. /**
  113687. * Add a new optimization
  113688. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  113689. * @returns the current SceneOptimizerOptions
  113690. */
  113691. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  113692. /**
  113693. * Add a new custom optimization
  113694. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  113695. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  113696. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113697. * @returns the current SceneOptimizerOptions
  113698. */
  113699. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  113700. /**
  113701. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  113702. * @param targetFrameRate defines the target frame rate (60 by default)
  113703. * @returns a SceneOptimizerOptions object
  113704. */
  113705. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113706. /**
  113707. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  113708. * @param targetFrameRate defines the target frame rate (60 by default)
  113709. * @returns a SceneOptimizerOptions object
  113710. */
  113711. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113712. /**
  113713. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  113714. * @param targetFrameRate defines the target frame rate (60 by default)
  113715. * @returns a SceneOptimizerOptions object
  113716. */
  113717. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113718. }
  113719. /**
  113720. * Class used to run optimizations in order to reach a target frame rate
  113721. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113722. */
  113723. export class SceneOptimizer implements IDisposable {
  113724. private _isRunning;
  113725. private _options;
  113726. private _scene;
  113727. private _currentPriorityLevel;
  113728. private _targetFrameRate;
  113729. private _trackerDuration;
  113730. private _currentFrameRate;
  113731. private _sceneDisposeObserver;
  113732. private _improvementMode;
  113733. /**
  113734. * Defines an observable called when the optimizer reaches the target frame rate
  113735. */
  113736. onSuccessObservable: Observable<SceneOptimizer>;
  113737. /**
  113738. * Defines an observable called when the optimizer enables an optimization
  113739. */
  113740. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  113741. /**
  113742. * Defines an observable called when the optimizer is not able to reach the target frame rate
  113743. */
  113744. onFailureObservable: Observable<SceneOptimizer>;
  113745. /**
  113746. * Gets a boolean indicating if the optimizer is in improvement mode
  113747. */
  113748. readonly isInImprovementMode: boolean;
  113749. /**
  113750. * Gets the current priority level (0 at start)
  113751. */
  113752. readonly currentPriorityLevel: number;
  113753. /**
  113754. * Gets the current frame rate checked by the SceneOptimizer
  113755. */
  113756. readonly currentFrameRate: number;
  113757. /**
  113758. * Gets or sets the current target frame rate (60 by default)
  113759. */
  113760. /**
  113761. * Gets or sets the current target frame rate (60 by default)
  113762. */
  113763. targetFrameRate: number;
  113764. /**
  113765. * Gets or sets the current interval between two checks (every 2000ms by default)
  113766. */
  113767. /**
  113768. * Gets or sets the current interval between two checks (every 2000ms by default)
  113769. */
  113770. trackerDuration: number;
  113771. /**
  113772. * Gets the list of active optimizations
  113773. */
  113774. readonly optimizations: SceneOptimization[];
  113775. /**
  113776. * Creates a new SceneOptimizer
  113777. * @param scene defines the scene to work on
  113778. * @param options defines the options to use with the SceneOptimizer
  113779. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  113780. * @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)
  113781. */
  113782. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  113783. /**
  113784. * Stops the current optimizer
  113785. */
  113786. stop(): void;
  113787. /**
  113788. * Reset the optimizer to initial step (current priority level = 0)
  113789. */
  113790. reset(): void;
  113791. /**
  113792. * Start the optimizer. By default it will try to reach a specific framerate
  113793. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  113794. */
  113795. start(): void;
  113796. private _checkCurrentState;
  113797. /**
  113798. * Release all resources
  113799. */
  113800. dispose(): void;
  113801. /**
  113802. * Helper function to create a SceneOptimizer with one single line of code
  113803. * @param scene defines the scene to work on
  113804. * @param options defines the options to use with the SceneOptimizer
  113805. * @param onSuccess defines a callback to call on success
  113806. * @param onFailure defines a callback to call on failure
  113807. * @returns the new SceneOptimizer object
  113808. */
  113809. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  113810. }
  113811. }
  113812. declare module BABYLON {
  113813. /**
  113814. * Class used to serialize a scene into a string
  113815. */
  113816. export class SceneSerializer {
  113817. /**
  113818. * Clear cache used by a previous serialization
  113819. */
  113820. static ClearCache(): void;
  113821. /**
  113822. * Serialize a scene into a JSON compatible object
  113823. * @param scene defines the scene to serialize
  113824. * @returns a JSON compatible object
  113825. */
  113826. static Serialize(scene: Scene): any;
  113827. /**
  113828. * Serialize a mesh into a JSON compatible object
  113829. * @param toSerialize defines the mesh to serialize
  113830. * @param withParents defines if parents must be serialized as well
  113831. * @param withChildren defines if children must be serialized as well
  113832. * @returns a JSON compatible object
  113833. */
  113834. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  113835. }
  113836. }
  113837. declare module BABYLON {
  113838. /**
  113839. * Class used to host texture specific utilities
  113840. */
  113841. export class TextureTools {
  113842. /**
  113843. * Uses the GPU to create a copy texture rescaled at a given size
  113844. * @param texture Texture to copy from
  113845. * @param width defines the desired width
  113846. * @param height defines the desired height
  113847. * @param useBilinearMode defines if bilinear mode has to be used
  113848. * @return the generated texture
  113849. */
  113850. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  113851. }
  113852. }
  113853. declare module BABYLON {
  113854. /**
  113855. * This represents the different options avilable for the video capture.
  113856. */
  113857. export interface VideoRecorderOptions {
  113858. /** Defines the mime type of the video */
  113859. mimeType: string;
  113860. /** Defines the video the video should be recorded at */
  113861. fps: number;
  113862. /** Defines the chunk size for the recording data */
  113863. recordChunckSize: number;
  113864. /** The audio tracks to attach to the record */
  113865. audioTracks?: MediaStreamTrack[];
  113866. }
  113867. /**
  113868. * This can helps recording videos from BabylonJS.
  113869. * This is based on the available WebRTC functionalities of the browser.
  113870. *
  113871. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  113872. */
  113873. export class VideoRecorder {
  113874. private static readonly _defaultOptions;
  113875. /**
  113876. * Returns wehther or not the VideoRecorder is available in your browser.
  113877. * @param engine Defines the Babylon Engine to check the support for
  113878. * @returns true if supported otherwise false
  113879. */
  113880. static IsSupported(engine: Engine): boolean;
  113881. private readonly _options;
  113882. private _canvas;
  113883. private _mediaRecorder;
  113884. private _recordedChunks;
  113885. private _fileName;
  113886. private _resolve;
  113887. private _reject;
  113888. /**
  113889. * True wether a recording is already in progress.
  113890. */
  113891. readonly isRecording: boolean;
  113892. /**
  113893. * Create a new VideoCapture object which can help converting what you see in Babylon to
  113894. * a video file.
  113895. * @param engine Defines the BabylonJS Engine you wish to record
  113896. * @param options Defines options that can be used to customized the capture
  113897. */
  113898. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  113899. /**
  113900. * Stops the current recording before the default capture timeout passed in the startRecording
  113901. * functions.
  113902. */
  113903. stopRecording(): void;
  113904. /**
  113905. * Starts recording the canvas for a max duration specified in parameters.
  113906. * @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.
  113907. * @param maxDuration Defines the maximum recording time in seconds.
  113908. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  113909. * @return a promise callback at the end of the recording with the video data in Blob.
  113910. */
  113911. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  113912. /**
  113913. * Releases internal resources used during the recording.
  113914. */
  113915. dispose(): void;
  113916. private _handleDataAvailable;
  113917. private _handleError;
  113918. private _handleStop;
  113919. }
  113920. }
  113921. declare module BABYLON {
  113922. /**
  113923. * Helper class to push actions to a pool of workers.
  113924. */
  113925. export class WorkerPool implements IDisposable {
  113926. private _workerInfos;
  113927. private _pendingActions;
  113928. /**
  113929. * Constructor
  113930. * @param workers Array of workers to use for actions
  113931. */
  113932. constructor(workers: Array<Worker>);
  113933. /**
  113934. * Terminates all workers and clears any pending actions.
  113935. */
  113936. dispose(): void;
  113937. /**
  113938. * Pushes an action to the worker pool. If all the workers are active, the action will be
  113939. * pended until a worker has completed its action.
  113940. * @param action The action to perform. Call onComplete when the action is complete.
  113941. */
  113942. push(action: (worker: Worker, onComplete: () => void) => void): void;
  113943. private _execute;
  113944. }
  113945. }
  113946. declare module BABYLON {
  113947. /**
  113948. * Class containing a set of static utilities functions for screenshots
  113949. */
  113950. export class ScreenshotTools {
  113951. /**
  113952. * Captures a screenshot of the current rendering
  113953. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113954. * @param engine defines the rendering engine
  113955. * @param camera defines the source camera
  113956. * @param size This parameter can be set to a single number or to an object with the
  113957. * following (optional) properties: precision, width, height. If a single number is passed,
  113958. * it will be used for both width and height. If an object is passed, the screenshot size
  113959. * will be derived from the parameters. The precision property is a multiplier allowing
  113960. * rendering at a higher or lower resolution
  113961. * @param successCallback defines the callback receives a single parameter which contains the
  113962. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113963. * src parameter of an <img> to display it
  113964. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  113965. * Check your browser for supported MIME types
  113966. */
  113967. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  113968. /**
  113969. * Generates an image screenshot from the specified camera.
  113970. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113971. * @param engine The engine to use for rendering
  113972. * @param camera The camera to use for rendering
  113973. * @param size This parameter can be set to a single number or to an object with the
  113974. * following (optional) properties: precision, width, height. If a single number is passed,
  113975. * it will be used for both width and height. If an object is passed, the screenshot size
  113976. * will be derived from the parameters. The precision property is a multiplier allowing
  113977. * rendering at a higher or lower resolution
  113978. * @param successCallback The callback receives a single parameter which contains the
  113979. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113980. * src parameter of an <img> to display it
  113981. * @param mimeType The MIME type of the screenshot image (default: image/png).
  113982. * Check your browser for supported MIME types
  113983. * @param samples Texture samples (default: 1)
  113984. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  113985. * @param fileName A name for for the downloaded file.
  113986. */
  113987. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  113988. }
  113989. }
  113990. declare module BABYLON {
  113991. /**
  113992. * A cursor which tracks a point on a path
  113993. */
  113994. export class PathCursor {
  113995. private path;
  113996. /**
  113997. * Stores path cursor callbacks for when an onchange event is triggered
  113998. */
  113999. private _onchange;
  114000. /**
  114001. * The value of the path cursor
  114002. */
  114003. value: number;
  114004. /**
  114005. * The animation array of the path cursor
  114006. */
  114007. animations: Animation[];
  114008. /**
  114009. * Initializes the path cursor
  114010. * @param path The path to track
  114011. */
  114012. constructor(path: Path2);
  114013. /**
  114014. * Gets the cursor point on the path
  114015. * @returns A point on the path cursor at the cursor location
  114016. */
  114017. getPoint(): Vector3;
  114018. /**
  114019. * Moves the cursor ahead by the step amount
  114020. * @param step The amount to move the cursor forward
  114021. * @returns This path cursor
  114022. */
  114023. moveAhead(step?: number): PathCursor;
  114024. /**
  114025. * Moves the cursor behind by the step amount
  114026. * @param step The amount to move the cursor back
  114027. * @returns This path cursor
  114028. */
  114029. moveBack(step?: number): PathCursor;
  114030. /**
  114031. * Moves the cursor by the step amount
  114032. * If the step amount is greater than one, an exception is thrown
  114033. * @param step The amount to move the cursor
  114034. * @returns This path cursor
  114035. */
  114036. move(step: number): PathCursor;
  114037. /**
  114038. * Ensures that the value is limited between zero and one
  114039. * @returns This path cursor
  114040. */
  114041. private ensureLimits;
  114042. /**
  114043. * Runs onchange callbacks on change (used by the animation engine)
  114044. * @returns This path cursor
  114045. */
  114046. private raiseOnChange;
  114047. /**
  114048. * Executes a function on change
  114049. * @param f A path cursor onchange callback
  114050. * @returns This path cursor
  114051. */
  114052. onchange(f: (cursor: PathCursor) => void): PathCursor;
  114053. }
  114054. }
  114055. declare module BABYLON {
  114056. /** @hidden */
  114057. export var blurPixelShader: {
  114058. name: string;
  114059. shader: string;
  114060. };
  114061. }
  114062. declare module BABYLON {
  114063. /** @hidden */
  114064. export var vrMultiviewToSingleviewPixelShader: {
  114065. name: string;
  114066. shader: string;
  114067. };
  114068. }
  114069. declare module BABYLON {
  114070. /** @hidden */
  114071. export var bones300Declaration: {
  114072. name: string;
  114073. shader: string;
  114074. };
  114075. }
  114076. declare module BABYLON {
  114077. /** @hidden */
  114078. export var instances300Declaration: {
  114079. name: string;
  114080. shader: string;
  114081. };
  114082. }
  114083. declare module BABYLON {
  114084. /** @hidden */
  114085. export var pointCloudVertexDeclaration: {
  114086. name: string;
  114087. shader: string;
  114088. };
  114089. }
  114090. // Mixins
  114091. interface Window {
  114092. mozIndexedDB: IDBFactory;
  114093. webkitIndexedDB: IDBFactory;
  114094. msIndexedDB: IDBFactory;
  114095. webkitURL: typeof URL;
  114096. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  114097. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  114098. WebGLRenderingContext: WebGLRenderingContext;
  114099. MSGesture: MSGesture;
  114100. CANNON: any;
  114101. AudioContext: AudioContext;
  114102. webkitAudioContext: AudioContext;
  114103. PointerEvent: any;
  114104. Math: Math;
  114105. Uint8Array: Uint8ArrayConstructor;
  114106. Float32Array: Float32ArrayConstructor;
  114107. mozURL: typeof URL;
  114108. msURL: typeof URL;
  114109. VRFrameData: any; // WebVR, from specs 1.1
  114110. DracoDecoderModule: any;
  114111. setImmediate(handler: (...args: any[]) => void): number;
  114112. }
  114113. interface HTMLCanvasElement {
  114114. requestPointerLock(): void;
  114115. msRequestPointerLock?(): void;
  114116. mozRequestPointerLock?(): void;
  114117. webkitRequestPointerLock?(): void;
  114118. /** Track wether a record is in progress */
  114119. isRecording: boolean;
  114120. /** Capture Stream method defined by some browsers */
  114121. captureStream(fps?: number): MediaStream;
  114122. }
  114123. interface CanvasRenderingContext2D {
  114124. msImageSmoothingEnabled: boolean;
  114125. }
  114126. interface MouseEvent {
  114127. mozMovementX: number;
  114128. mozMovementY: number;
  114129. webkitMovementX: number;
  114130. webkitMovementY: number;
  114131. msMovementX: number;
  114132. msMovementY: number;
  114133. }
  114134. interface Navigator {
  114135. mozGetVRDevices: (any: any) => any;
  114136. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  114137. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  114138. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  114139. webkitGetGamepads(): Gamepad[];
  114140. msGetGamepads(): Gamepad[];
  114141. webkitGamepads(): Gamepad[];
  114142. }
  114143. interface HTMLVideoElement {
  114144. mozSrcObject: any;
  114145. }
  114146. interface Math {
  114147. fround(x: number): number;
  114148. imul(a: number, b: number): number;
  114149. }
  114150. interface WebGLProgram {
  114151. context?: WebGLRenderingContext;
  114152. vertexShader?: WebGLShader;
  114153. fragmentShader?: WebGLShader;
  114154. isParallelCompiled: boolean;
  114155. onCompiled?: () => void;
  114156. }
  114157. interface WebGLRenderingContext {
  114158. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  114159. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  114160. vertexAttribDivisor(index: number, divisor: number): void;
  114161. createVertexArray(): any;
  114162. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  114163. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  114164. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  114165. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  114166. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  114167. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  114168. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  114169. // Queries
  114170. createQuery(): WebGLQuery;
  114171. deleteQuery(query: WebGLQuery): void;
  114172. beginQuery(target: number, query: WebGLQuery): void;
  114173. endQuery(target: number): void;
  114174. getQueryParameter(query: WebGLQuery, pname: number): any;
  114175. getQuery(target: number, pname: number): any;
  114176. MAX_SAMPLES: number;
  114177. RGBA8: number;
  114178. READ_FRAMEBUFFER: number;
  114179. DRAW_FRAMEBUFFER: number;
  114180. UNIFORM_BUFFER: number;
  114181. HALF_FLOAT_OES: number;
  114182. RGBA16F: number;
  114183. RGBA32F: number;
  114184. R32F: number;
  114185. RG32F: number;
  114186. RGB32F: number;
  114187. R16F: number;
  114188. RG16F: number;
  114189. RGB16F: number;
  114190. RED: number;
  114191. RG: number;
  114192. R8: number;
  114193. RG8: number;
  114194. UNSIGNED_INT_24_8: number;
  114195. DEPTH24_STENCIL8: number;
  114196. /* Multiple Render Targets */
  114197. drawBuffers(buffers: number[]): void;
  114198. readBuffer(src: number): void;
  114199. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  114200. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  114201. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  114202. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  114203. // Occlusion Query
  114204. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  114205. ANY_SAMPLES_PASSED: number;
  114206. QUERY_RESULT_AVAILABLE: number;
  114207. QUERY_RESULT: number;
  114208. }
  114209. interface WebGLBuffer {
  114210. references: number;
  114211. capacity: number;
  114212. is32Bits: boolean;
  114213. }
  114214. interface WebGLProgram {
  114215. transformFeedback?: WebGLTransformFeedback | null;
  114216. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  114217. }
  114218. interface EXT_disjoint_timer_query {
  114219. QUERY_COUNTER_BITS_EXT: number;
  114220. TIME_ELAPSED_EXT: number;
  114221. TIMESTAMP_EXT: number;
  114222. GPU_DISJOINT_EXT: number;
  114223. QUERY_RESULT_EXT: number;
  114224. QUERY_RESULT_AVAILABLE_EXT: number;
  114225. queryCounterEXT(query: WebGLQuery, target: number): void;
  114226. createQueryEXT(): WebGLQuery;
  114227. beginQueryEXT(target: number, query: WebGLQuery): void;
  114228. endQueryEXT(target: number): void;
  114229. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  114230. deleteQueryEXT(query: WebGLQuery): void;
  114231. }
  114232. interface WebGLUniformLocation {
  114233. _currentState: any;
  114234. }
  114235. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  114236. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  114237. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  114238. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  114239. interface WebGLRenderingContext {
  114240. readonly RASTERIZER_DISCARD: number;
  114241. readonly DEPTH_COMPONENT24: number;
  114242. readonly TEXTURE_3D: number;
  114243. readonly TEXTURE_2D_ARRAY: number;
  114244. readonly TEXTURE_COMPARE_FUNC: number;
  114245. readonly TEXTURE_COMPARE_MODE: number;
  114246. readonly COMPARE_REF_TO_TEXTURE: number;
  114247. readonly TEXTURE_WRAP_R: number;
  114248. readonly HALF_FLOAT: number;
  114249. readonly RGB8: number;
  114250. readonly RED_INTEGER: number;
  114251. readonly RG_INTEGER: number;
  114252. readonly RGB_INTEGER: number;
  114253. readonly RGBA_INTEGER: number;
  114254. readonly R8_SNORM: number;
  114255. readonly RG8_SNORM: number;
  114256. readonly RGB8_SNORM: number;
  114257. readonly RGBA8_SNORM: number;
  114258. readonly R8I: number;
  114259. readonly RG8I: number;
  114260. readonly RGB8I: number;
  114261. readonly RGBA8I: number;
  114262. readonly R8UI: number;
  114263. readonly RG8UI: number;
  114264. readonly RGB8UI: number;
  114265. readonly RGBA8UI: number;
  114266. readonly R16I: number;
  114267. readonly RG16I: number;
  114268. readonly RGB16I: number;
  114269. readonly RGBA16I: number;
  114270. readonly R16UI: number;
  114271. readonly RG16UI: number;
  114272. readonly RGB16UI: number;
  114273. readonly RGBA16UI: number;
  114274. readonly R32I: number;
  114275. readonly RG32I: number;
  114276. readonly RGB32I: number;
  114277. readonly RGBA32I: number;
  114278. readonly R32UI: number;
  114279. readonly RG32UI: number;
  114280. readonly RGB32UI: number;
  114281. readonly RGBA32UI: number;
  114282. readonly RGB10_A2UI: number;
  114283. readonly R11F_G11F_B10F: number;
  114284. readonly RGB9_E5: number;
  114285. readonly RGB10_A2: number;
  114286. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  114287. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  114288. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  114289. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114290. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  114291. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  114292. 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;
  114293. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  114294. readonly TRANSFORM_FEEDBACK: number;
  114295. readonly INTERLEAVED_ATTRIBS: number;
  114296. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  114297. createTransformFeedback(): WebGLTransformFeedback;
  114298. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  114299. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  114300. beginTransformFeedback(primitiveMode: number): void;
  114301. endTransformFeedback(): void;
  114302. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  114303. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114304. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114305. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114306. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  114307. }
  114308. interface ImageBitmap {
  114309. readonly width: number;
  114310. readonly height: number;
  114311. close(): void;
  114312. }
  114313. interface WebGLQuery extends WebGLObject {
  114314. }
  114315. declare var WebGLQuery: {
  114316. prototype: WebGLQuery;
  114317. new(): WebGLQuery;
  114318. };
  114319. interface WebGLSampler extends WebGLObject {
  114320. }
  114321. declare var WebGLSampler: {
  114322. prototype: WebGLSampler;
  114323. new(): WebGLSampler;
  114324. };
  114325. interface WebGLSync extends WebGLObject {
  114326. }
  114327. declare var WebGLSync: {
  114328. prototype: WebGLSync;
  114329. new(): WebGLSync;
  114330. };
  114331. interface WebGLTransformFeedback extends WebGLObject {
  114332. }
  114333. declare var WebGLTransformFeedback: {
  114334. prototype: WebGLTransformFeedback;
  114335. new(): WebGLTransformFeedback;
  114336. };
  114337. interface WebGLVertexArrayObject extends WebGLObject {
  114338. }
  114339. declare var WebGLVertexArrayObject: {
  114340. prototype: WebGLVertexArrayObject;
  114341. new(): WebGLVertexArrayObject;
  114342. };
  114343. // Type definitions for WebVR API
  114344. // Project: https://w3c.github.io/webvr/
  114345. // Definitions by: six a <https://github.com/lostfictions>
  114346. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  114347. interface VRDisplay extends EventTarget {
  114348. /**
  114349. * Dictionary of capabilities describing the VRDisplay.
  114350. */
  114351. readonly capabilities: VRDisplayCapabilities;
  114352. /**
  114353. * z-depth defining the far plane of the eye view frustum
  114354. * enables mapping of values in the render target depth
  114355. * attachment to scene coordinates. Initially set to 10000.0.
  114356. */
  114357. depthFar: number;
  114358. /**
  114359. * z-depth defining the near plane of the eye view frustum
  114360. * enables mapping of values in the render target depth
  114361. * attachment to scene coordinates. Initially set to 0.01.
  114362. */
  114363. depthNear: number;
  114364. /**
  114365. * An identifier for this distinct VRDisplay. Used as an
  114366. * association point in the Gamepad API.
  114367. */
  114368. readonly displayId: number;
  114369. /**
  114370. * A display name, a user-readable name identifying it.
  114371. */
  114372. readonly displayName: string;
  114373. readonly isConnected: boolean;
  114374. readonly isPresenting: boolean;
  114375. /**
  114376. * If this VRDisplay supports room-scale experiences, the optional
  114377. * stage attribute contains details on the room-scale parameters.
  114378. */
  114379. readonly stageParameters: VRStageParameters | null;
  114380. /**
  114381. * Passing the value returned by `requestAnimationFrame` to
  114382. * `cancelAnimationFrame` will unregister the callback.
  114383. * @param handle Define the hanle of the request to cancel
  114384. */
  114385. cancelAnimationFrame(handle: number): void;
  114386. /**
  114387. * Stops presenting to the VRDisplay.
  114388. * @returns a promise to know when it stopped
  114389. */
  114390. exitPresent(): Promise<void>;
  114391. /**
  114392. * Return the current VREyeParameters for the given eye.
  114393. * @param whichEye Define the eye we want the parameter for
  114394. * @returns the eye parameters
  114395. */
  114396. getEyeParameters(whichEye: string): VREyeParameters;
  114397. /**
  114398. * Populates the passed VRFrameData with the information required to render
  114399. * the current frame.
  114400. * @param frameData Define the data structure to populate
  114401. * @returns true if ok otherwise false
  114402. */
  114403. getFrameData(frameData: VRFrameData): boolean;
  114404. /**
  114405. * Get the layers currently being presented.
  114406. * @returns the list of VR layers
  114407. */
  114408. getLayers(): VRLayer[];
  114409. /**
  114410. * Return a VRPose containing the future predicted pose of the VRDisplay
  114411. * when the current frame will be presented. The value returned will not
  114412. * change until JavaScript has returned control to the browser.
  114413. *
  114414. * The VRPose will contain the position, orientation, velocity,
  114415. * and acceleration of each of these properties.
  114416. * @returns the pose object
  114417. */
  114418. getPose(): VRPose;
  114419. /**
  114420. * Return the current instantaneous pose of the VRDisplay, with no
  114421. * prediction applied.
  114422. * @returns the current instantaneous pose
  114423. */
  114424. getImmediatePose(): VRPose;
  114425. /**
  114426. * The callback passed to `requestAnimationFrame` will be called
  114427. * any time a new frame should be rendered. When the VRDisplay is
  114428. * presenting the callback will be called at the native refresh
  114429. * rate of the HMD. When not presenting this function acts
  114430. * identically to how window.requestAnimationFrame acts. Content should
  114431. * make no assumptions of frame rate or vsync behavior as the HMD runs
  114432. * asynchronously from other displays and at differing refresh rates.
  114433. * @param callback Define the eaction to run next frame
  114434. * @returns the request handle it
  114435. */
  114436. requestAnimationFrame(callback: FrameRequestCallback): number;
  114437. /**
  114438. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  114439. * Repeat calls while already presenting will update the VRLayers being displayed.
  114440. * @param layers Define the list of layer to present
  114441. * @returns a promise to know when the request has been fulfilled
  114442. */
  114443. requestPresent(layers: VRLayer[]): Promise<void>;
  114444. /**
  114445. * Reset the pose for this display, treating its current position and
  114446. * orientation as the "origin/zero" values. VRPose.position,
  114447. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  114448. * updated when calling resetPose(). This should be called in only
  114449. * sitting-space experiences.
  114450. */
  114451. resetPose(): void;
  114452. /**
  114453. * The VRLayer provided to the VRDisplay will be captured and presented
  114454. * in the HMD. Calling this function has the same effect on the source
  114455. * canvas as any other operation that uses its source image, and canvases
  114456. * created without preserveDrawingBuffer set to true will be cleared.
  114457. * @param pose Define the pose to submit
  114458. */
  114459. submitFrame(pose?: VRPose): void;
  114460. }
  114461. declare var VRDisplay: {
  114462. prototype: VRDisplay;
  114463. new(): VRDisplay;
  114464. };
  114465. interface VRLayer {
  114466. leftBounds?: number[] | Float32Array | null;
  114467. rightBounds?: number[] | Float32Array | null;
  114468. source?: HTMLCanvasElement | null;
  114469. }
  114470. interface VRDisplayCapabilities {
  114471. readonly canPresent: boolean;
  114472. readonly hasExternalDisplay: boolean;
  114473. readonly hasOrientation: boolean;
  114474. readonly hasPosition: boolean;
  114475. readonly maxLayers: number;
  114476. }
  114477. interface VREyeParameters {
  114478. /** @deprecated */
  114479. readonly fieldOfView: VRFieldOfView;
  114480. readonly offset: Float32Array;
  114481. readonly renderHeight: number;
  114482. readonly renderWidth: number;
  114483. }
  114484. interface VRFieldOfView {
  114485. readonly downDegrees: number;
  114486. readonly leftDegrees: number;
  114487. readonly rightDegrees: number;
  114488. readonly upDegrees: number;
  114489. }
  114490. interface VRFrameData {
  114491. readonly leftProjectionMatrix: Float32Array;
  114492. readonly leftViewMatrix: Float32Array;
  114493. readonly pose: VRPose;
  114494. readonly rightProjectionMatrix: Float32Array;
  114495. readonly rightViewMatrix: Float32Array;
  114496. readonly timestamp: number;
  114497. }
  114498. interface VRPose {
  114499. readonly angularAcceleration: Float32Array | null;
  114500. readonly angularVelocity: Float32Array | null;
  114501. readonly linearAcceleration: Float32Array | null;
  114502. readonly linearVelocity: Float32Array | null;
  114503. readonly orientation: Float32Array | null;
  114504. readonly position: Float32Array | null;
  114505. readonly timestamp: number;
  114506. }
  114507. interface VRStageParameters {
  114508. sittingToStandingTransform?: Float32Array;
  114509. sizeX?: number;
  114510. sizeY?: number;
  114511. }
  114512. interface Navigator {
  114513. getVRDisplays(): Promise<VRDisplay[]>;
  114514. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  114515. }
  114516. interface Window {
  114517. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  114518. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  114519. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  114520. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114521. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114522. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  114523. }
  114524. interface Gamepad {
  114525. readonly displayId: number;
  114526. }
  114527. interface XRDevice {
  114528. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  114529. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  114530. }
  114531. interface XRSession {
  114532. getInputSources(): Array<any>;
  114533. baseLayer: XRWebGLLayer;
  114534. requestFrameOfReference(type: string): Promise<void>;
  114535. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  114536. end(): Promise<void>;
  114537. requestAnimationFrame: Function;
  114538. addEventListener: Function;
  114539. }
  114540. interface XRSessionCreationOptions {
  114541. outputContext?: WebGLRenderingContext | null;
  114542. immersive?: boolean;
  114543. environmentIntegration?: boolean;
  114544. }
  114545. interface XRLayer {
  114546. getViewport: Function;
  114547. framebufferWidth: number;
  114548. framebufferHeight: number;
  114549. }
  114550. interface XRView {
  114551. projectionMatrix: Float32Array;
  114552. }
  114553. interface XRFrame {
  114554. getDevicePose: Function;
  114555. getInputPose: Function;
  114556. views: Array<XRView>;
  114557. baseLayer: XRLayer;
  114558. }
  114559. interface XRFrameOfReference {
  114560. }
  114561. interface XRWebGLLayer extends XRLayer {
  114562. framebuffer: WebGLFramebuffer;
  114563. }
  114564. declare var XRWebGLLayer: {
  114565. prototype: XRWebGLLayer;
  114566. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  114567. };